- specialy the EV_TIMER callbacks were suffering from wrong order execution which caused bad behaviours:
- network queueing now is executed before mail queue handling -> mailinglist posts are sent in < 60s instead of < 120s as before
- network spool consolidation is done before running the citadel networkers; that way the NTT-list won't be locked by running networkers
/*
* Hook functions available to modules.
*/
-
-void CtdlRegisterSessionHook(void (*fcn_ptr)(void), int EventType);
+/* Priorities for */
+#define PRIO_QUEUE 500
+#define PRIO_AGGR 1000
+#define PRIO_SEND 1500
+#define PRIO_CLEANUP 2000
+/* Priorities for EVT_HOUSE */
+#define PRIO_HOUSE 3000
+/* Priorities for EVT_LOGIN */
+#define PRIO_CREATE 10000
+/* Priorities for EVT_LOGOUT */
+#define PRIO_LOGOUT 15000
+/* Priorities for EVT_LOGIN */
+#define PRIO_LOGIN 20000
+/* Priorities for EVT_START */
+#define PRIO_START 25000
+/* Priorities for EVT_STOP */
+#define PRIO_STOP 30000
+/* Priorities for EVT_ASYNC */
+#define PRIO_ASYNC 35000
+/* Priorities for EVT_SHUTDOWN */
+#define PRIO_SHUTDOWN 40000
+/* Priorities for EVT_UNSTEALTH */
+#define PRIO_UNSTEALTH 45000
+/* Priorities for EVT_STEALTH */
+#define PRIO_STEALTH 50000
+void CtdlRegisterSessionHook(void (*fcn_ptr)(void), int EventType, int Priority);
void CtdlUnregisterSessionHook(void (*fcn_ptr)(void), int EventType);
void CtdlShutdownServiceHooks(void);
/* Initialize our hook functions */
CtdlRegisterMessageHook(ical_obj_beforesave, EVT_BEFORESAVE);
CtdlRegisterMessageHook(ical_obj_aftersave, EVT_AFTERSAVE);
- CtdlRegisterSessionHook(ical_CtdlCreateRoom, EVT_LOGIN);
+ CtdlRegisterSessionHook(ical_CtdlCreateRoom, EVT_LOGIN, PRIO_LOGIN + 1);
CtdlRegisterProtoHook(cmd_ical, "ICAL", "Citadel iCal commands");
- CtdlRegisterSessionHook(ical_session_startup, EVT_START);
- CtdlRegisterSessionHook(ical_session_shutdown, EVT_STOP);
+ CtdlRegisterSessionHook(ical_session_startup, EVT_START, PRIO_START + 1);
+ CtdlRegisterSessionHook(ical_session_shutdown, EVT_STOP, PRIO_STOP + 80);
CtdlRegisterFixedOutputHook("text/calendar", ical_fixed_output);
CtdlRegisterFixedOutputHook("application/ics", ical_fixed_output);
CtdlRegisterCleanupHook(serv_calendar_destroy);
CTDL_MODULE_INIT(checkpoint) {
if (threading)
{
- CtdlRegisterSessionHook(cdb_checkpoint, EVT_TIMER);
+ CtdlRegisterSessionHook(cdb_checkpoint, EVT_TIMER, PRIO_CLEANUP + 10);
}
/* return our module name for the log */
return "checkpoint";
CtdlRegisterProtoHook(cmd_stls, "STLS", "Start SSL/TLS session");
CtdlRegisterProtoHook(cmd_gtls, "GTLS",
"Get SSL/TLS session status");
- CtdlRegisterSessionHook(endtls, EVT_STOP);
+ CtdlRegisterSessionHook(endtls, EVT_STOP, PRIO_STOP + 10);
}
CtdlRegisterProtoHook(cmd_tdap, "TDAP", "Manually initiate auto-purger");
CtdlRegisterProtoHook(cmd_gpex, "GPEX", "Get expire policy");
CtdlRegisterProtoHook(cmd_spex, "SPEX", "Set expire policy");
- CtdlRegisterSessionHook(purge_databases, EVT_TIMER);
+ CtdlRegisterSessionHook(purge_databases, EVT_TIMER, PRIO_CLEANUP + 20);
}
/* return our module name for the log */
if (!threading)
{
create_extnotify_queue();
- CtdlRegisterSessionHook(do_extnotify_queue, EVT_TIMER);
+ CtdlRegisterSessionHook(do_extnotify_queue, EVT_TIMER, PRIO_SEND + 10);
}
/* return our module name for the log */
return "extnotify";
CtdlRegisterDeleteHook(ft_delete_remove);
CtdlRegisterSearchFuncHook(ft_search, "fulltext");
CtdlRegisterCleanupHook(noise_word_cleanup);
- CtdlRegisterSessionHook(do_fulltext_indexing, EVT_TIMER);
+ CtdlRegisterSessionHook(do_fulltext_indexing, EVT_TIMER, PRIO_CLEANUP + 300);
}
/* return our module name for the log */
return "fulltext";
CtdlRegisterServiceHook(config.c_imaps_port,
NULL, imaps_greeting, imap_command_loop, NULL, CitadelServiceIMAPS);
#endif
- CtdlRegisterSessionHook(imap_cleanup_function, EVT_STOP);
+ CtdlRegisterSessionHook(imap_cleanup_function, EVT_STOP, PRIO_STOP + 30);
CtdlRegisterCleanupHook(imap_cleanup);
}
CtdlRegisterProtoHook(cmd_sexp, "SEXP", "Send an instant message");
CtdlRegisterProtoHook(cmd_dexp, "DEXP", "Disable instant messages");
CtdlRegisterProtoHook(cmd_reqt, "REQT", "Request client termination");
- CtdlRegisterSessionHook(cmd_gexp_async, EVT_ASYNC);
- CtdlRegisterSessionHook(delete_instant_messages, EVT_STOP);
+ CtdlRegisterSessionHook(cmd_gexp_async, EVT_ASYNC, PRIO_ASYNC + 1);
+ CtdlRegisterSessionHook(delete_instant_messages, EVT_STOP, PRIO_STOP + 1);
CtdlRegisterXmsgHook(send_instant_message, XMSG_PRI_LOCAL);
- CtdlRegisterSessionHook(instmsg_timer, EVT_TIMER);
- CtdlRegisterSessionHook(instmsg_shutdown, EVT_SHUTDOWN);
+ CtdlRegisterSessionHook(instmsg_timer, EVT_TIMER, PRIO_CLEANUP + 400);
+ CtdlRegisterSessionHook(instmsg_shutdown, EVT_SHUTDOWN, PRIO_SHUTDOWN + 10);
}
/* return our module name for the log */
managesieve_command_loop,
NULL,
CitadelServiceManageSieve);
- CtdlRegisterSessionHook(managesieve_cleanup_function, EVT_STOP);
+ CtdlRegisterSessionHook(managesieve_cleanup_function, EVT_STOP, PRIO_STOP + 30);
}
/* return our module name for the log */
{
CtdlRegisterDebugFlagHook(HKEY("networktalkingto"), SetNTTDebugEnabled, &NTTDebugEnabled);
CtdlRegisterCleanupHook(cleanup_nttlist);
- CtdlRegisterSessionHook(network_cleanup_function, EVT_STOP);
- CtdlRegisterSessionHook(network_logout_hook, EVT_LOGOUT);
+ CtdlRegisterSessionHook(network_cleanup_function, EVT_STOP, PRIO_STOP + 30);
+ CtdlRegisterSessionHook(network_logout_hook, EVT_LOGOUT, PRIO_LOGOUT + 10);
CtdlRegisterProtoHook(cmd_nsyn, "NSYN", "Synchronize room to node");
CtdlRegisterRoomHook(network_room_handler);
CtdlRegisterCleanupHook(destroy_network_queue_room_locked);
- CtdlRegisterSessionHook(network_do_queue, EVT_TIMER);
+ CtdlRegisterSessionHook(network_do_queue, EVT_TIMER, PRIO_QUEUE + 10);
}
return "network";
}
{
CtdlFillSystemContext(&networker_client_CC, "CitNetworker");
- CtdlRegisterSessionHook(network_do_clientqueue, EVT_TIMER);
+ CtdlRegisterSessionHook(network_do_clientqueue, EVT_TIMER, PRIO_SEND + 10);
CtdlRegisterDebugFlagHook(HKEY("networkclient"), LogDebugEnableNetworkClient, &NetworkClientDebugEnabled);
}
{
if (!threading)
{
- CtdlRegisterSessionHook(CopyNewUserGreetings, EVT_LOGIN);
+ CtdlRegisterSessionHook(CopyNewUserGreetings, EVT_LOGIN, PRIO_LOGIN + 1);
}
/* return our module name for the log */
CtdlRegisterProtoHook(cmd_oidc, "OIDC", "Create new user after validating OpenID");
CtdlRegisterProtoHook(cmd_oida, "OIDA", "List all OpenIDs in the database");
}
- CtdlRegisterSessionHook(openid_cleanup_function, EVT_LOGOUT);
+ CtdlRegisterSessionHook(openid_cleanup_function, EVT_LOGOUT, PRIO_LOGOUT + 10);
CtdlRegisterUserHook(openid_purge, EVT_PURGEUSER);
openid_level_supported = 1; /* This module supports OpenID 1.0 only */
}
NULL,
CitadelServicePop3S);
#endif
- CtdlRegisterSessionHook(pop3_cleanup_function, EVT_STOP);
+ CtdlRegisterSessionHook(pop3_cleanup_function, EVT_STOP, PRIO_STOP + 30);
}
/* return our module name for the log */
pthread_mutex_init(&POP3QueueMutex, NULL);
POP3QueueRooms = NewHash(1, lFlathash);
POP3FetchUrls = NewHash(1, NULL);
- CtdlRegisterSessionHook(pop3client_scan, EVT_TIMER);
+ CtdlRegisterSessionHook(pop3client_scan, EVT_TIMER, PRIO_AGGR + 50);
CtdlRegisterEVCleanupHook(pop3_cleanup);
CtdlRegisterDebugFlagHook(HKEY("pop3client"), LogDebugEnablePOP3Client, &POP3ClientDebugEnabled);
}
if (!threading)
{
CtdlRegisterProtoHook(cmd_rcht, "RCHT", "Participate in real time chat in a room");
- CtdlRegisterSessionHook(roomchat_timer, EVT_TIMER);
- CtdlRegisterSessionHook(roomchat_shutdown, EVT_SHUTDOWN);
+ CtdlRegisterSessionHook(roomchat_timer, EVT_TIMER, PRIO_CLEANUP + 400);
+ CtdlRegisterSessionHook(roomchat_shutdown, EVT_SHUTDOWN, PRIO_SHUTDOWN + 55);
}
/* return our module name for the log */
RSSQueueRooms = NewHash(1, lFlathash);
RSSFetchUrls = NewHash(1, NULL);
syslog(LOG_INFO, "%s\n", curl_version());
- CtdlRegisterSessionHook(rssclient_scan, EVT_TIMER);
+ CtdlRegisterSessionHook(rssclient_scan, EVT_TIMER, PRIO_AGGR + 300);
CtdlRegisterEVCleanupHook(rss_cleanup);
CtdlRegisterDebugFlagHook(HKEY("rssclient"), LogDebugEnableRSSClient, &RSSClientDebugEnabled);
}
ctdl_sieve_init();
CtdlRegisterProtoHook(cmd_msiv, "MSIV", "Manage Sieve scripts");
CtdlRegisterRoomHook(serv_sieve_room);
- CtdlRegisterSessionHook(perform_sieve_processing, EVT_HOUSE);
+ CtdlRegisterSessionHook(perform_sieve_processing, EVT_HOUSE, PRIO_HOUSE + 10);
CtdlRegisterCleanupHook(cleanup_sieve);
}
NULL,
CitadelServiceSMTP_LMTP_UNF);
- CtdlRegisterSessionHook(smtp_cleanup_function, EVT_STOP);
+ CtdlRegisterSessionHook(smtp_cleanup_function, EVT_STOP, PRIO_STOP + 250);
}
/* return our module name for the log */
CtdlRegisterEVCleanupHook(smtp_evq_cleanup);
CtdlRegisterProtoHook(cmd_smtp, "SMTP", "SMTP utility commands");
- CtdlRegisterSessionHook(smtp_do_queue, EVT_TIMER);
+ CtdlRegisterSessionHook(smtp_do_queue, EVT_TIMER, PRIO_SEND + 10);
}
/* return our Subversion id for the Log */
if (!threading)
{
CtdlRegisterCleanupHook(CleanupTest);
- CtdlRegisterSessionHook(NewRoomTest, EVT_NEWROOM);
- CtdlRegisterSessionHook(SessionStartTest, EVT_START);
- CtdlRegisterSessionHook(SessionStopTest, EVT_STOP);
- CtdlRegisterSessionHook(LoginTest, EVT_LOGIN);
+ CtdlRegisterSessionHook(NewRoomTest, EVT_NEWROOM, 1);
+ CtdlRegisterSessionHook(SessionStartTest, EVT_START, 1);
+ CtdlRegisterSessionHook(SessionStopTest, EVT_STOP, 1);
+ CtdlRegisterSessionHook(LoginTest, EVT_LOGIN, 1);
}
#endif
if (!threading)
{
- CtdlRegisterSessionHook(vcard_session_login_hook, EVT_LOGIN);
+ CtdlRegisterSessionHook(vcard_session_login_hook, EVT_LOGIN, PRIO_LOGIN + 70);
CtdlRegisterMessageHook(vcard_upload_beforesave, EVT_BEFORESAVE);
CtdlRegisterMessageHook(vcard_upload_aftersave, EVT_AFTERSAVE);
CtdlRegisterDeleteHook(vcard_delete_remove);
CtdlRegisterUserHook(vcard_newuser, EVT_NEWUSER);
CtdlRegisterUserHook(vcard_purge, EVT_PURGEUSER);
CtdlRegisterNetprocHook(vcard_extract_from_network);
- CtdlRegisterSessionHook(store_harvested_addresses, EVT_TIMER);
+ CtdlRegisterSessionHook(store_harvested_addresses, EVT_TIMER, PRIO_CLEANUP + 470);
CtdlRegisterFixedOutputHook("text/x-vcard", vcard_fixed_output);
CtdlRegisterFixedOutputHook("text/vcard", vcard_fixed_output);
CitadelServiceXMPP
);
CtdlRegisterDebugFlagHook(HKEY("serv_xmpp"), LogXMPPSrvDebugEnable, &XMPPSrvDebugEnable);
- CtdlRegisterSessionHook(xmpp_cleanup_function, EVT_STOP);
- CtdlRegisterSessionHook(xmpp_login_hook, EVT_LOGIN);
- CtdlRegisterSessionHook(xmpp_logout_hook, EVT_LOGOUT);
- CtdlRegisterSessionHook(xmpp_login_hook, EVT_UNSTEALTH);
- CtdlRegisterSessionHook(xmpp_logout_hook, EVT_STEALTH);
+ CtdlRegisterSessionHook(xmpp_cleanup_function, EVT_STOP, PRIO_STOP + 70);
+ CtdlRegisterSessionHook(xmpp_login_hook, EVT_LOGIN, PRIO_LOGIN + 90);
+ CtdlRegisterSessionHook(xmpp_logout_hook, EVT_LOGOUT, PRIO_LOGOUT + 90);
+ CtdlRegisterSessionHook(xmpp_login_hook, EVT_UNSTEALTH, PRIO_UNSTEALTH + 1);
+ CtdlRegisterSessionHook(xmpp_logout_hook, EVT_STEALTH, PRIO_STEALTH + 1);
CtdlRegisterCleanupHook(xmpp_cleanup_events);
}
typedef struct SessionFunctionHook SessionFunctionHook;
struct SessionFunctionHook {
SessionFunctionHook *next;
+ int Priority;
void (*h_function_pointer) (void);
int eventtype;
};
}
-void CtdlRegisterSessionHook(void (*fcn_ptr) (void), int EventType)
+void CtdlRegisterSessionHook(void (*fcn_ptr) (void), int EventType, int Priority)
{
-
SessionFunctionHook *newfcn;
newfcn = (SessionFunctionHook *)
malloc(sizeof(SessionFunctionHook));
- newfcn->next = SessionHookTable;
+ newfcn->Priority = Priority;
newfcn->h_function_pointer = fcn_ptr;
newfcn->eventtype = EventType;
- SessionHookTable = newfcn;
- MOD_syslog(LOG_DEBUG, "Registered a new session function (type %d)\n",
- EventType);
+ SessionFunctionHook **pfcn;
+ pfcn = &SessionHookTable;
+ while ((*pfcn != NULL) &&
+ ((*pfcn)->Priority < newfcn->Priority) &&
+ ((*pfcn)->next != NULL))
+ pfcn = &(*pfcn)->next;
+
+ newfcn->next = *pfcn;
+ *pfcn = newfcn;
+
+ MOD_syslog(LOG_DEBUG, "Registered a new session function (type %d Priority %d)\n",
+ EventType, Priority);
}
}
/* We want to check for idle sessions once per minute */
- CtdlRegisterSessionHook(terminate_idle_sessions, EVT_TIMER);
+ CtdlRegisterSessionHook(terminate_idle_sessions, EVT_TIMER, PRIO_CLEANUP + 1);
go_threading();