Reset m_readBufMaxSize & m_readBufSize whenever m_readBuf is set to NULL

This commit is contained in:
Ai Lin Chia
2017-05-17 12:20:54 +02:00
parent 313b8ba544
commit 22b567617c
6 changed files with 20 additions and 5 deletions

@ -427,6 +427,8 @@ static void handleRequestfd(UdpSlot *slot, int32_t /*niceness*/) {
// so we have to be careful not to let UdpServer free it in the
// udpSlot because it will have been reallocated by PageDirectory.cpp
slot->m_readBuf = NULL;
slot->m_readBufSize = 0;
slot->m_readBufMaxSize = 0;
// HACK: this is used as a unique identifier for registering callbacks
// so let's set the high bit here to avoid conflicting with normal

@ -374,6 +374,8 @@ void gotSingleReplyWrapper ( void *state , UdpSlot *slot ) {
THIS->gotReply( reply , replySize , replyMaxSize );
// don't let UdpServer free this since we own it now
slot->m_readBuf = NULL;
slot->m_readBufSize = 0;
slot->m_readBufMaxSize = 0;
}
// never let m_request (sendBuf) be freed
slot->m_sendBufAlloc = NULL;

@ -304,7 +304,11 @@ bool Msg13::gotForwardedReply ( UdpSlot *slot ) {
if ( reply == (void *)-1 ) { gbshutdownAbort(true); }
// we are responsible for freeing reply now
if ( ! g_errno ) slot->m_readBuf = NULL;
if ( ! g_errno ) {
slot->m_readBuf = NULL;
slot->m_readBufSize = 0;
slot->m_readBufMaxSize = 0;
}
return gotFinalReply ( reply , replySize , replyAllocSize );
}
@ -1684,6 +1688,8 @@ void passOnReply ( void *state , UdpSlot *slot ) {
// as the send buf for "udpSlot"
slot->m_readBuf = NULL;
slot->m_readBufSize = 0;
slot->m_readBufMaxSize = 0;
// prevent udpserver from trying to free g_fakeReply
if ( reply == g_fakeReply ) replyAllocSize = 0;

@ -370,6 +370,8 @@ void handleRequest22 ( UdpSlot *slot , int32_t netnice ) {
st->m_slotAllocSize = slot->m_readBufMaxSize;
st->m_slotReadBuf = slot->m_readBuf;
slot->m_readBuf = NULL;
slot->m_readBufSize = 0;
slot->m_readBufMaxSize = 0;
// . if docId was explicitly specified...
// . we may get multiple tfndb recs

@ -950,6 +950,8 @@ void Multicast::closeUpShop ( UdpSlot *slot ) {
}
// don't let UdpServer free the readBuf now that we point to it
slot->m_readBuf = NULL;
slot->m_readBufSize = 0;
slot->m_readBufMaxSize = 0;
// save slot so msg4 knows what slot replied in udpserver
// for doing its flush callback logic

@ -520,12 +520,13 @@ void Proxy::gotReplyPage ( void *state, UdpSlot *slot ) {
// do not allow regular proxy to uncompress it though!
if ( ! (g_hostdb.m_myHost->m_type & HT_QCPROXY ) ) doUncompress=false;
// sanity check
if ( slot->m_readBufSize < 0 ) { g_process.shutdownAbort(true); }
// don't let udp server free the reply, we forward this to end user
slot->m_readBuf = NULL;
// sanity check
//if ( s->m_readOffset < 0 ) { g_process.shutdownAbort(true); }
if ( slot->m_readBufSize < 0 ) { g_process.shutdownAbort(true); }
slot->m_readBufSize = 0;
slot->m_readBufMaxSize = 0;
int64_t nowms = gettimeofdayInMilliseconds();