more fixes for new link info code.

This commit is contained in:
Matt Wells
2014-02-25 13:53:41 -08:00
parent 9c486c77ed
commit 33c8123288
2 changed files with 49 additions and 19 deletions

@ -625,34 +625,49 @@ static void sendReplyWrapper ( void *state ) {
// the original request
Msg25Request *mr = m25->m_req25;
// get udp slot for sending back reply
UdpSlot *slot = mr->m_udpSlot;
UdpSlot *slot2 = mr->m_udpSlot;
// shortcut
SafeBuf *info = m25->m_linkInfoBuf;
// steal this buffer
char *reply = info->getBufStart();
char *reply1 = info->getBufStart();
long replySize = info->length();
long replyAllocSize = info->getCapacity();
// do not let m25 free it, UdpServer.cpp will free it on destruction
info->detachBuf();
// sanity
if ( replySize <= 0 ) { char *xx=NULL;*xx=0; }
// get original request
Msg25Request *req = (Msg25Request *)slot2->m_readBuf;
// sanity
if ( req->m_udpSlot != slot2 ) { char *xx=NULL;*xx=0;}
nextLink:
UdpSlot *udpSlot = req->m_udpSlot;
// just dup the reply for each one
char *reply2 = (char *)mdup(reply1,replySize,"m25repd");
// error?
if ( saved || ! reply2 ) {
long err = saved;
if ( ! err ) err = g_errno;
if ( ! err ) { char *xx=NULL;*xx=0; }
g_udpServer.sendErrorReply(udpSlot,err);
}
else {
// send it back to requester
g_udpServer.sendReply_ass ( reply2 ,
replySize ,
reply2 ,
replySize,
udpSlot );
}
// if we had a link
req = req->m_next;
if ( req ) goto nextLink;
// the destructor
mdelete ( m25 ,sizeof(Msg25),"msg25");
delete ( m25 );
// error?
if ( saved ) {
g_udpServer.sendErrorReply(slot,saved);
return;
}
// send it back to requester
g_udpServer.sendReply_ass ( reply ,
replySize ,
reply ,
replyAllocSize ,
slot );
}
@ -664,6 +679,9 @@ void handleRequest25 ( UdpSlot *slot , long netnice ) {
req->deserialize();
// make sure this always NULL for our linked list logic
req->m_next = NULL;
// set up the hashtable if our first time
if ( ! g_lineTable.isInitialized() )
g_lineTable.set ( 8,4,256,NULL,0,false,MAX_NICENESS,"lht25");
@ -686,11 +704,19 @@ void handleRequest25 ( UdpSlot *slot , long netnice ) {
if ( head->m_next )
req->m_next = head->m_next;
head->m_next = req;
// note it for debugging
log("build: msg25 request waiting in line for %s slot=0x%lx",
req->ptr_url,(long)slot);
// we will send a reply back for this guy when done
// getting the reply for the head msg25request
return;
}
if ( isSiteLinkInfo ) {
// add the initial entry
g_lineTable.addKey ( &req->m_siteHash64 , &req );
}
// make a new Msg25
Msg25 *m25;
try { m25 = new ( Msg25 ); }

@ -4011,7 +4011,11 @@ bool getSpiderRequestMetaList ( char *doc ,
// finally, we can set the key. isDel = false
sreq.setKey ( sreq.m_firstIp , probDocId , false );
if ( ! listBuf->reserve ( 100 + sreq.getRecSize() ) )
long oldBufSize = listBuf->getCapacity();
long need = listBuf->getLength() + 100 + sreq.getRecSize();
long newBufSize = 0;
if ( need > oldBufSize ) newBufSize = oldBufSize + 100000;
if ( newBufSize && ! listBuf->reserve ( newBufSize ) )
// return false with g_errno set
return false;