msta = curl_multi_remove_handle(mhnd, chnd);
if (msta)
CtdlLogPrintf(CTDL_ERR, "EVCURL: warning problem detaching completed handle from curl multi: %s\n", curl_multi_strerror(msta));
+
IO->HttpReq.attached = 0;
IO->SendDone(IO);
- curl_multi_cleanup(msta);
+ curl_easy_cleanup(IO->HttpReq.chnd);
+ curl_slist_free_all(IO->HttpReq.headers);
+ FreeStrBuf(&IO->HttpReq.ReplyData);
+ FreeURL(&IO->ConnectMe);
+ RemoveContext(IO->CitContext);
+ free(IO);
}
}
}
}
if (CURL_POLL_REMOVE == action) {
CtdlLogPrintf(CTDL_ERR,"EVCURL: called last time to unregister this sockwatcher\n");
+ ev_io_stop(event_base, &sockwatcher->ioev);
free(sockwatcher);
} else {
int events = (action & CURL_POLL_IN ? EV_READ : 0) | (action & CURL_POLL_OUT ? EV_WRITE : 0);
curl_multi_perform(&global, CURL_POLL_NONE);
}
+static void evcurl_shutdown (void)
+{
+ curl_multi_cleanup(global.mhnd);
+}
/*****************************************************************************
* libevent integration *
*****************************************************************************/
DeleteHash(&InboundEventQueues[0]);
DeleteHash(&InboundEventQueues[1]);
citthread_mutex_destroy(&EventQueueMutex);
-
+ evcurl_shutdown();
return(NULL);
}
}
-StrBuf** GetNotifyHosts(void)
+int GetNotifyHosts(NotifyContext *Ctx)
{
char NotifyHostsBuf[SIZ];
StrBuf *Host;
int notify;
const char *pchs, *pche;
const char *NextHost = NULL;
- StrBuf **NotifyHostList;
- int num_notify;
/* See if we have any Notification Hosts configured */
- num_notify = get_hosts(NotifyHostsBuf, "notify");
- if (num_notify < 1)
- return(NULL);
+ Ctx->nNotifyHosts = get_hosts(NotifyHostsBuf, "notify");
+ if (Ctx->nNotifyHosts < 1)
+ return 0;
- NotifyHostList = malloc(sizeof(StrBuf*) * 2 * (num_notify + 1));
- memset(NotifyHostList, 0, sizeof(StrBuf*) * 2 * (num_notify + 1));
+ Ctx->NotifyHostList = malloc(sizeof(StrBuf*) * 2 * (Ctx->nNotifyHosts + 1));
+ memset(Ctx->NotifyHostList, 0, sizeof(StrBuf*) * 2 * (Ctx->nNotifyHosts + 1));
NotifyBuf = NewStrBufPlain(NotifyHostsBuf, -1);
/* get all configured notifiers's */
- for (notify=0; notify<num_notify; notify++) {
+ for (notify=0; notify<Ctx->nNotifyHosts; notify++) {
- Host = GetNHBuf(notify * 2, 1, NotifyHostList);
+ Host = GetNHBuf(notify * 2, 1, Ctx->NotifyHostList);
StrBufExtract_NextToken(Host, NotifyBuf, &NextHost, '|');
pchs = ChrPtr(Host);
pche = strchr(pchs, ':');
pchs);
continue;
}
- File = GetNHBuf(notify * 2 + 1, 1, NotifyHostList);
+ File = GetNHBuf(notify * 2 + 1, 1, Ctx->NotifyHostList);
StrBufPlain(File, pchs, pche - pchs);
StrBufCutLeft(Host, pche - pchs + 1);
}
- return NotifyHostList;
+ FreeStrBuf(&NotifyBuf);
+ return Ctx->nNotifyHosts;
}
}
}
+ free(msglist);
if (msg == NULL)
return eNone;
StrBuf *File;
StrBuf *FileBuf = NewStrBuf();
- while(1)
+ for (i = 0; i < Ctx->nNotifyHosts; i++)
{
URL = GetNHBuf(i*2, 0, Ctx->NotifyHostList);
msg->cm_fields['I'],
msgnum,
NULL);
- i++;
}
FreeStrBuf(&FileBuf);
}
*/
void do_extnotify_queue(void)
{
- CitContext *CCC = CC;
-
NotifyContext Ctx;
static int doing_queue = 0;
- //int i = 0;
+ int i = 0;
/*
* This is a simple concurrency check to make sure only one queue run
CtdlLogPrintf(CTDL_DEBUG, "serv_extnotify: processing notify queue\n");
memset(&Ctx, 0, sizeof(NotifyContext));
- Ctx.NotifyHostList = GetNotifyHosts();
- if (CtdlGetRoom(&CC->room, FNBL_QUEUE_ROOM) != 0) {
+ if ((GetNotifyHosts(&Ctx) > 0) &&
+ (CtdlGetRoom(&CC->room, FNBL_QUEUE_ROOM) != 0))
+ {
CtdlLogPrintf(CTDL_ERR, "Cannot find room <%s>\n", FNBL_QUEUE_ROOM);
CtdlClearSystemContext();
+ if (Ctx.nNotifyHosts > 0)
+ {
+ for (i = 0; i < Ctx.nNotifyHosts * 2; i++)
+ FreeStrBuf(&Ctx.NotifyHostList[i]);
+ free(Ctx.NotifyHostList);
+ }
return;
}
CtdlForEachMessage(MSGS_ALL, 0L, NULL,
SPOOLMIME, NULL, process_notify, &Ctx);
CtdlLogPrintf(CTDL_DEBUG, "serv_extnotify: queue run completed\n");
doing_queue = 0;
+ if (Ctx.nNotifyHosts > 0)
+ {
+ for (i = 0; i < Ctx.nNotifyHosts * 2; i++)
+ FreeStrBuf(&Ctx.NotifyHostList[i]);
+ free(Ctx.NotifyHostList);
+ }
}