- properly cleanup pop3 client hashes
- properly hook in the event cleanup stuff
- move all cleanup into serv_eventclient.c
-int ShutDownEventQueue(void)
-{
- pthread_mutex_lock(&DBEventQueueMutex);
- ev_async_send (event_db, &DBExitEventLoop);
- pthread_mutex_unlock(&DBEventQueueMutex);
-
- pthread_mutex_lock(&EventQueueMutex);
- ev_async_send (EV_DEFAULT_ &ExitEventLoop);
- pthread_mutex_unlock(&EventQueueMutex);
- return 0;
-}
-
void FreeAsyncIOContents(AsyncIO *IO)
{
FreeStrBuf(&IO->IOBuf);
void FreeAsyncIOContents(AsyncIO *IO)
{
FreeStrBuf(&IO->IOBuf);
eNextState QueueDBOperation(AsyncIO *IO, IO_CallBack CB);
eNextState QueueEventContext(AsyncIO *IO, IO_CallBack CB);
eNextState QueueCurlContext(AsyncIO *IO);
eNextState QueueDBOperation(AsyncIO *IO, IO_CallBack CB);
eNextState QueueEventContext(AsyncIO *IO, IO_CallBack CB);
eNextState QueueCurlContext(AsyncIO *IO);
-int ShutDownEventQueue(void);
eNextState InitEventIO(AsyncIO *IO,
void *pData,
eNextState InitEventIO(AsyncIO *IO,
void *pData,
static void evcurl_shutdown (void)
{
static void evcurl_shutdown (void)
{
curl_multi_cleanup(global.mhnd);
curl_multi_cleanup(global.mhnd);
+ syslog(LOG_DEBUG, "client_event_thread() initializing\n");
}
/*****************************************************************************
* libevent integration *
}
/*****************************************************************************
* libevent integration *
CtdlFillSystemContext(&libev_client_CC, "LibEv Thread");
// citthread_setspecific(MyConKey, (void *)&smtp_queue_CC);
CtdlFillSystemContext(&libev_client_CC, "LibEv Thread");
// citthread_setspecific(MyConKey, (void *)&smtp_queue_CC);
- syslog(LOG_DEBUG, "client_ev_thread() initializing\n");
+ syslog(LOG_DEBUG, "client_event_thread() initializing\n");
event_base = ev_default_loop (EVFLAG_AUTO);
ev_async_init(&AddJob, QueueEventAddCallback);
event_base = ev_default_loop (EVFLAG_AUTO);
ev_async_init(&AddJob, QueueEventAddCallback);
+ syslog(LOG_DEBUG, "client_event_thread() exiting\n");
///what todo here? CtdlClearSystemContext();
ev_loop_destroy (EV_DEFAULT_UC);
///what todo here? CtdlClearSystemContext();
ev_loop_destroy (EV_DEFAULT_UC);
- curl_global_cleanup();
- curl_multi_cleanup(global.mhnd);
DeleteHash(&QueueEvents);
InboundEventQueue = NULL;
DeleteHash(&InboundEventQueues[0]);
DeleteHash(&QueueEvents);
InboundEventQueue = NULL;
DeleteHash(&InboundEventQueues[0]);
static void DBEventExitCallback(EV_P_ ev_async *w, int revents)
{
static void DBEventExitCallback(EV_P_ ev_async *w, int revents)
{
- syslog(LOG_DEBUG, "EVENT Q exiting.\n");
+ syslog(LOG_DEBUG, "DB EVENT Q exiting.\n");
ev_break(event_db, EVBREAK_ALL);
}
ev_break(event_db, EVBREAK_ALL);
}
CtdlFillSystemContext(&libev_msg_CC, "LibEv DB IO Thread");
// citthread_setspecific(MyConKey, (void *)&smtp_queue_CC);
CtdlFillSystemContext(&libev_msg_CC, "LibEv DB IO Thread");
// citthread_setspecific(MyConKey, (void *)&smtp_queue_CC);
- syslog(LOG_DEBUG, "client_msgev_thread() initializing\n");
+ syslog(LOG_DEBUG, "dbevent_thread() initializing\n");
event_db = ev_loop_new (EVFLAG_AUTO);
event_db = ev_loop_new (EVFLAG_AUTO);
+ syslog(LOG_DEBUG, "dbevent_thread() exiting\n");
//// what to do here? CtdlClearSystemContext();
ev_loop_destroy (event_db);
//// what to do here? CtdlClearSystemContext();
ev_loop_destroy (event_db);
+void ShutDownEventQueues(void)
+{
+ syslog(LOG_DEBUG, "EVENT Qs triggering exits.\n");
+
+ pthread_mutex_lock(&DBEventQueueMutex);
+ ev_async_send (event_db, &DBExitEventLoop);
+ pthread_mutex_unlock(&DBEventQueueMutex);
+
+ pthread_mutex_lock(&EventQueueMutex);
+ ev_async_send (EV_DEFAULT_ &ExitEventLoop);
+ pthread_mutex_unlock(&EventQueueMutex);
+}
+
CTDL_MODULE_INIT(event_client)
{
if (!threading)
{
CTDL_MODULE_INIT(event_client)
{
if (!threading)
{
+ CtdlRegisterCleanupHook(ShutDownEventQueues);
InitEventQueue();
DBInitEventQueue();
CtdlThreadCreate(/*"Client event", */ client_event_thread);
InitEventQueue();
DBInitEventQueue();
CtdlThreadCreate(/*"Client event", */ client_event_thread);
+static int doing_pop3client = 0;
void pop3client_scan(void) {
static time_t last_run = 0L;
void pop3client_scan(void) {
static time_t last_run = 0L;
- static int doing_pop3client = 0;
/// struct pop3aggr *pptr;
time_t fastest_scan;
HashPos *it;
/// struct pop3aggr *pptr;
time_t fastest_scan;
HashPos *it;
void pop3_cleanup(void)
{
/* citthread_mutex_destroy(&POP3QueueMutex); TODO */
void pop3_cleanup(void)
{
/* citthread_mutex_destroy(&POP3QueueMutex); TODO */
-// DeleteHash(&POP3FetchUrls);
+ while (doing_pop3client != 0) ;
+ DeleteHash(&POP3FetchUrls);
DeleteHash(&POP3QueueRooms);
}
DeleteHash(&POP3QueueRooms);
}