From 076aaf225bd8a8713cb16c99463f46518e20f118 Mon Sep 17 00:00:00 2001 From: Art Cancro Date: Thu, 25 Feb 2010 05:21:39 +0000 Subject: [PATCH] * Noticed that when serv_chat.c sets async_waiting to 1, it also checks to see if the target session is in CON_IDLE, and if so, switches it to CON_READY. serv_xmpp.c now does this as well. Also unified this action in both modules by creating a shared function called set_async_waiting(). --- citadel/context.c | 14 +++++++++++++- citadel/context.h | 1 + citadel/modules/chat/serv_chat.c | 7 +------ citadel/modules/xmpp/xmpp_queue.c | 2 +- 4 files changed, 16 insertions(+), 8 deletions(-) diff --git a/citadel/context.c b/citadel/context.c index 38394b7f4..6c6a20453 100644 --- a/citadel/context.c +++ b/citadel/context.c @@ -586,4 +586,16 @@ INLINE void become_session(CitContext *which_con) { } - +/* + * Set the "async waiting" flag for a session, if applicable + */ +void set_async_waiting(struct CitContext *ccptr) +{ + CtdlLogPrintf(CTDL_DEBUG, "Setting async_waiting flag for session %d\n", ccptr->cs_pid); + if (ccptr->is_async) { + ccptr->async_waiting = 1; + if (ccptr->state == CON_IDLE) { + ccptr->state = CON_READY; + } + } +} diff --git a/citadel/context.h b/citadel/context.h index 1e57f2f39..ddf8d6ca1 100644 --- a/citadel/context.h +++ b/citadel/context.h @@ -159,6 +159,7 @@ void kill_session (int session_to_kill); INLINE void become_session(struct CitContext *which_con); void InitializeMasterCC(void); void dead_session_purge(int force); +void set_async_waiting(struct CitContext *ccptr); /* Deprecated, user CtdlBumpNewMailCounter() instead */ void BumpNewMailCounter(long) __attribute__ ((deprecated)); diff --git a/citadel/modules/chat/serv_chat.c b/citadel/modules/chat/serv_chat.c index f0f1e7d6c..028f2833b 100644 --- a/citadel/modules/chat/serv_chat.c +++ b/citadel/modules/chat/serv_chat.c @@ -650,12 +650,7 @@ void add_xmsg_to_context(struct CitContext *ccptr, struct ExpressMessage *newmsg /* If the target context is a session which can handle asynchronous * messages, go ahead and set the flag for that. */ - if (ccptr->is_async) { - ccptr->async_waiting = 1; - if (ccptr->state == CON_IDLE) { - ccptr->state = CON_READY; - } - } + set_async_waiting(ccptr); } diff --git a/citadel/modules/xmpp/xmpp_queue.c b/citadel/modules/xmpp/xmpp_queue.c index 3bd8c95d7..24e474aa4 100644 --- a/citadel/modules/xmpp/xmpp_queue.c +++ b/citadel/modules/xmpp/xmpp_queue.c @@ -113,7 +113,7 @@ void xmpp_queue_event(int event_type, char *email_addr) { begin_critical_section(S_SESSION_TABLE); for (cptr = ContextList; cptr != NULL; cptr = cptr->next) { if ((cptr->logged_in) && (cptr->h_async_function == xmpp_async_loop)) { - cptr->async_waiting = 1; + set_async_waiting(cptr); } } end_critical_section(S_SESSION_TABLE); -- 2.30.2