log an error and drop bad fwd packet rather than assert

This commit is contained in:
Andy2 2011-12-07 18:43:13 -08:00
parent 17edc79aaf
commit 0d4e839dba

View file

@ -1048,20 +1048,22 @@ void
CookieRef::forward_or_store( const CRefEvent* evt ) CookieRef::forward_or_store( const CRefEvent* evt )
{ {
unsigned char* buf = evt->u.fwd.buf; unsigned char* buf = evt->u.fwd.buf;
int buflen = evt->u.fwd.buflen; do {
HostID dest = evt->u.fwd.dest;
int destSocket = SocketForHost( dest );
/* This is an ugly hack!!!! */ /* This is an ugly hack!!!! */
if ( *buf == XWRELAY_MSG_TORELAY ) { if ( *buf == XWRELAY_MSG_TORELAY ) {
*buf = XWRELAY_MSG_FROMRELAY; *buf = XWRELAY_MSG_FROMRELAY;
} else if ( *buf == XWRELAY_MSG_TORELAY_NOCONN ) { } else if ( *buf == XWRELAY_MSG_TORELAY_NOCONN ) {
*buf = XWRELAY_MSG_FROMRELAY_NOCONN; *buf = XWRELAY_MSG_FROMRELAY_NOCONN;
} else { } else {
assert( 0 ); /* don't ship this */ logf( XW_LOGERROR, "%s: got XWRELAY type of %d", __func__,
*buf );
break;
} }
int buflen = evt->u.fwd.buflen;
HostID dest = evt->u.fwd.dest;
int destSocket = SocketForHost( dest );
if ( 0 < m_delayMicros && destSocket != -1 ) { if ( 0 < m_delayMicros && destSocket != -1 ) {
usleep( m_delayMicros ); usleep( m_delayMicros );
} }
@ -1076,6 +1078,7 @@ CookieRef::forward_or_store( const CRefEvent* evt )
HostID src = evt->u.fwd.src; HostID src = evt->u.fwd.src;
pushHeartbeatEvent( src, SocketForHost(src) ); pushHeartbeatEvent( src, SocketForHost(src) );
#endif #endif
} while ( 0 );
} /* forward_or_store */ } /* forward_or_store */
void void