fix core from sending a url alert, then customer deleting

collection before email alert reply comes back. then it
comes back to a delete collrec and cores.
This commit is contained in:
Matt Wells
2015-09-08 15:57:46 -07:00
parent 47795f4c70
commit 647d004c04
6 changed files with 49 additions and 18 deletions

@ -1847,6 +1847,8 @@ void CollectionRec::reset() {
m_hasucr = false;
m_hasupr = false;
m_sendingAlertInProgress = false;
// make sure we do not leave spiders "hanging" waiting for their
// callback to be called... and it never gets called
//if ( m_callbackQueue.length() > 0 ) { char *xx=NULL;*xx=0; }

@ -766,7 +766,7 @@ class CollectionRec {
// last time we computed global crawl info
//time_t m_globalCrawlInfoUpdateTime;
EmailInfo m_emailInfo;
//EmailInfo m_emailInfo;
// for counting replies
//int32_t m_replies;
//int32_t m_requests;
@ -974,6 +974,8 @@ class CollectionRec {
// NARROW SEARCH
char m_doNarrowSearch;
char m_sendingAlertInProgress;
// Allow Links: searches on the collection
//char m_allowLinksSearch;
// . reference pages parameters

@ -3228,9 +3228,11 @@ void doneSendingNotifyEmailWrapper ( void *state ) {
// wait for post url to get done
if ( ei->m_notifyBlocked > 0 ) return;
// unmark it
ei->m_inUse = false;
//ei->m_inUse = false;
// all done
ei->m_finalCallback ( ei->m_finalState );
// nuke it
mfree ( ei , sizeof(EmailInfo) ,"eialrt" );
}
void doneGettingNotifyUrlWrapper ( void *state , TcpSocket *sock ) {
@ -3242,9 +3244,11 @@ void doneGettingNotifyUrlWrapper ( void *state , TcpSocket *sock ) {
// wait for email to get done
if ( ei->m_notifyBlocked > 0 ) return;
// unmark it
ei->m_inUse = false;
//ei->m_inUse = false;
// all done
ei->m_finalCallback ( ei->m_finalState );
// nuke it
mfree ( ei , sizeof(EmailInfo) ,"eialrt" );
}
// for printCrawlDetailsInJson()
@ -3259,7 +3263,7 @@ bool sendNotification ( EmailInfo *ei ) {
//log("ping: NOT SENDING NOTIFICATION -- DEBUG!!");
//return true;
if ( ei->m_inUse ) { char *xx=NULL;*xx=0; }
//if ( ei->m_inUse ) { char *xx=NULL;*xx=0; }
// caller must set this, as well as m_finalCallback/m_finalState
CollectionRec *cr = g_collectiondb.m_recs[ei->m_collnum];
@ -3275,7 +3279,7 @@ bool sendNotification ( EmailInfo *ei ) {
// sanity check, can only call once
if ( ei->m_notifyBlocked != 0 ) { char *xx=NULL;*xx=0; }
ei->m_inUse = true;
//ei->m_inUse = true;
if ( email && email[0] ) {
@ -3371,7 +3375,9 @@ bool sendNotification ( EmailInfo *ei ) {
}
if ( ei->m_notifyBlocked == 0 ) {
ei->m_inUse = false;
//ei->m_inUse = false;
// nuke it
mfree ( ei , sizeof(EmailInfo) ,"eialrt" );
return true;
}

@ -30,16 +30,17 @@ public:
// ip address of MX record for this domain
int32_t m_mxIp;
int32_t m_notifyBlocked;
bool m_inUse;
class CollectionRec *m_collRec;
//bool m_inUse;
EmailInfo() {
memset ( this,0,sizeof(EmailInfo) );
};
void reset() {
if ( m_inUse ) { char *xx=NULL;*xx=0; }
if ( m_notifyBlocked ) { char *xx=NULL;*xx=0; }
memset ( this,0,sizeof(EmailInfo) );
};
//EmailInfo() {
// memset ( this,0,sizeof(EmailInfo) );
//};
//void reset() {
// if ( m_inUse ) { char *xx=NULL;*xx=0; }
// if ( m_notifyBlocked ) { char *xx=NULL;*xx=0; }
// memset ( this,0,sizeof(EmailInfo) );
//};
};
class PingServer {

@ -1132,6 +1132,8 @@ bool RdbBase::incorporateMerge ( ) {
if ( ! m_files[i]->unlink ( doneWrapper , this ) ) {
m_numThreads++; g_numThreads++; }
// debug msg
// MDW this cores if file is bad... if collection
// got delete from under us i guess!!
else log(LOG_INFO,"merge: Unlinked %s (#%"INT32").",
m_files[i]->getFilename(),i);
// debug msg

@ -6106,13 +6106,18 @@ void doneSendingNotification ( void *state ) {
EmailInfo *ei = (EmailInfo *)state;
collnum_t collnum = ei->m_collnum;
CollectionRec *cr = g_collectiondb.m_recs[collnum];
if ( cr != ei->m_collRec ) cr = NULL;
char *coll = "lostcoll";
if ( cr ) coll = cr->m_coll;
log(LOG_INFO,"spider: done sending notifications for coll=%s", coll);
log(LOG_INFO,"spider: done sending notifications for coll=%s (%i)",
coll,(int)ei->m_collnum);
// all done if collection was deleted from under us
if ( ! cr ) return;
// do not re-call this stuff
cr->m_sendingAlertInProgress = false;
// we can re-use the EmailInfo class now
// pingserver.cpp sets this
//ei->m_inUse = false;
@ -6268,11 +6273,19 @@ bool sendNotificationForCollRec ( CollectionRec *cr ) {
// since we reset global.
//if ( cr->m_localCrawlInfo.m_sentCrawlDoneAlert ) return true;
if ( cr->m_sendingAlertInProgress ) return true;
// ok, send it
EmailInfo *ei = &cr->m_emailInfo;
//EmailInfo *ei = &cr->m_emailInfo;
EmailInfo *ei = (EmailInfo *)mcalloc ( sizeof(EmailInfo),"eialrt");
if ( ! ei ) {
log("spider: could not send email alert: %s",
mstrerror(g_errno));
return true;
}
// in use already?
if ( ei->m_inUse ) return true;
//if ( ei->m_inUse ) return true;
// pingserver.cpp sets this
//ei->m_inUse = true;
@ -6281,6 +6294,8 @@ bool sendNotificationForCollRec ( CollectionRec *cr ) {
ei->m_finalCallback = doneSendingNotification;
ei->m_finalState = ei;
ei->m_collnum = cr->m_collnum;
// collnums can be recycled, so ensure collection with the ptr
ei->m_collRec = cr;
SafeBuf *buf = &ei->m_spiderStatusMsg;
// stop it from accumulating status msgs
@ -6293,6 +6308,9 @@ bool sendNotificationForCollRec ( CollectionRec *cr ) {
//log("spider: SENDING EMAIL NOT");
// do not re-call this stuff
cr->m_sendingAlertInProgress = true;
// ok, put it back...
if ( ! sendNotification ( ei ) ) return false;