- struct CtdlMessage *prefMsg;
- // Do a simple string search to see if 'funambol' is selected as the
- // type. This string would be at the very top of the message contents.
- if (configMsgNum == -1) {
- CtdlLogPrintf(CTDL_ERR, "extNotify_isAllowedByPrefs was passed a non-existant config message id\n");
+ NotifyContext Ctx;
+ static int doing_queue = 0;
+ int i = 0;
+
+ /*
+ * This is a simple concurrency check to make sure only one queue run
+ * is done at a time. We could do this with a mutex, but since we
+ * don't really require extremely fine granularity here, we'll do it
+ * with a static variable instead.
+ */
+ if (IsEmptyStr(config.c_pager_program) &&
+ IsEmptyStr(config.c_funambol_host))
+ {
+ syslog(LOG_ERR, "No external notifiers configured on system/user\n");
+ return;
+ }
+
+ if (doing_queue) return;
+ doing_queue = 1;
+
+ become_session(&extnotify_queue_CC);
+
+ pthread_setspecific(MyConKey, (void *)&extnotify_queue_CC);
+
+ /*
+ * Go ahead and run the queue
+ */
+ syslog(LOG_DEBUG, "serv_extnotify: processing notify queue\n");
+
+ memset(&Ctx, 0, sizeof(NotifyContext));
+ if ((GetNotifyHosts(&Ctx) > 0) &&
+ (CtdlGetRoom(&CC->room, FNBL_QUEUE_ROOM) != 0))
+ {
+ syslog(LOG_ERR, "Cannot find room <%s>\n", FNBL_QUEUE_ROOM);
+ if (Ctx.nNotifyHosts > 0)
+ {
+ for (i = 0; i < Ctx.nNotifyHosts * 2; i++)
+ FreeStrBuf(&Ctx.NotifyHostList[i]);
+ free(Ctx.NotifyHostList);
+ }