projects
/
citadel.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
c67fb1c
)
Free all our allocated resources after notifying / sending a http request.
author
Wilfried Goesgens
<dothebart@citadel.org>
Sun, 5 Jun 2011 13:49:09 +0000
(13:49 +0000)
committer
Wilfried Goesgens
<dothebart@citadel.org>
Sun, 5 Jun 2011 13:49:09 +0000
(13:49 +0000)
citadel/modules/eventclient/serv_eventclient.c
patch
|
blob
|
history
citadel/modules/extnotify/extnotify.h
patch
|
blob
|
history
citadel/modules/extnotify/extnotify_main.c
patch
|
blob
|
history
citadel/modules/extnotify/funambol65.c
patch
|
blob
|
history
diff --git
a/citadel/modules/eventclient/serv_eventclient.c
b/citadel/modules/eventclient/serv_eventclient.c
index 873d1662852a664401a557b1607d05c957493e2c..f2fbef00a6d93bab1b9d43e9e3ddb1bc6f2ffb04 100644
(file)
--- a/
citadel/modules/eventclient/serv_eventclient.c
+++ b/
citadel/modules/eventclient/serv_eventclient.c
@@
-153,9
+153,15
@@
gotstatus(evcurl_global_data *global, int nnrun)
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));
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);
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);
}
}
}
}
}
}
@@
-235,6
+241,7
@@
gotwatchsock(CURL *easy, curl_socket_t fd, int action, void *cglobal, void *csoc
}
if (CURL_POLL_REMOVE == action) {
CtdlLogPrintf(CTDL_ERR,"EVCURL: called last time to unregister this sockwatcher\n");
}
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);
free(sockwatcher);
} else {
int events = (action & CURL_POLL_IN ? EV_READ : 0) | (action & CURL_POLL_OUT ? EV_WRITE : 0);
@@
-383,6
+390,10
@@
static void WakeupCurlCallback(EV_P_ ev_async *w, int revents)
curl_multi_perform(&global, CURL_POLL_NONE);
}
curl_multi_perform(&global, CURL_POLL_NONE);
}
+static void evcurl_shutdown (void)
+{
+ curl_multi_cleanup(global.mhnd);
+}
/*****************************************************************************
* libevent integration *
*****************************************************************************/
/*****************************************************************************
* libevent integration *
*****************************************************************************/
@@
-484,7
+495,7
@@
void *client_event_thread(void *arg)
DeleteHash(&InboundEventQueues[0]);
DeleteHash(&InboundEventQueues[1]);
citthread_mutex_destroy(&EventQueueMutex);
DeleteHash(&InboundEventQueues[0]);
DeleteHash(&InboundEventQueues[1]);
citthread_mutex_destroy(&EventQueueMutex);
-
+ evcurl_shutdown();
return(NULL);
}
return(NULL);
}
diff --git
a/citadel/modules/extnotify/extnotify.h
b/citadel/modules/extnotify/extnotify.h
index 63a8fcd8e13c23aadadde58e02cbba50a47e51ac..efe6b91364265b004a800d7617cbfdd1ed8cd971 100644
(file)
--- a/
citadel/modules/extnotify/extnotify.h
+++ b/
citadel/modules/extnotify/extnotify.h
@@
-36,6
+36,7
@@
typedef enum _eNotifyType {
typedef struct _NotifyContext {
StrBuf **NotifyHostList;
typedef struct _NotifyContext {
StrBuf **NotifyHostList;
+ int nNotifyHosts;
HashList *NotifyErrors;
AsyncIO IO;
} NotifyContext;
HashList *NotifyErrors;
AsyncIO IO;
} NotifyContext;
diff --git
a/citadel/modules/extnotify/extnotify_main.c
b/citadel/modules/extnotify/extnotify_main.c
index b26284af51f8221b99722509004135c36f5b88c9..5ab54c2c7d54aa28ff16d9a9bdfc27d6da5241b0 100644
(file)
--- a/
citadel/modules/extnotify/extnotify_main.c
+++ b/
citadel/modules/extnotify/extnotify_main.c
@@
-92,7
+92,7
@@
StrBuf* GetNHBuf(int i, int allocit, StrBuf **NotifyHostList)
}
}
-
StrBuf** GetNotifyHosts(void
)
+
int GetNotifyHosts(NotifyContext *Ctx
)
{
char NotifyHostsBuf[SIZ];
StrBuf *Host;
{
char NotifyHostsBuf[SIZ];
StrBuf *Host;
@@
-101,22
+101,20
@@
StrBuf** GetNotifyHosts(void)
int notify;
const char *pchs, *pche;
const char *NextHost = NULL;
int notify;
const char *pchs, *pche;
const char *NextHost = NULL;
- StrBuf **NotifyHostList;
- int num_notify;
/* See if we have any Notification Hosts configured */
/* 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 */
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, ':');
StrBufExtract_NextToken(Host, NotifyBuf, &NextHost, '|');
pchs = ChrPtr(Host);
pche = strchr(pchs, ':');
@@
-126,11
+124,12
@@
StrBuf** GetNotifyHosts(void)
pchs);
continue;
}
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);
}
StrBufPlain(File, pchs, pche - pchs);
StrBufCutLeft(Host, pche - pchs + 1);
}
- return NotifyHostList;
+ FreeStrBuf(&NotifyBuf);
+ return Ctx->nNotifyHosts;
}
}
@@
-183,6
+182,7
@@
eNotifyType extNotify_getConfigMessage(char *username, char **PagerNumber, char
}
}
}
}
+ free(msglist);
if (msg == NULL)
return eNone;
if (msg == NULL)
return eNone;
@@
-302,7
+302,7
@@
void process_notify(long NotifyMsgnum, void *usrdata)
StrBuf *File;
StrBuf *FileBuf = NewStrBuf();
StrBuf *File;
StrBuf *FileBuf = NewStrBuf();
-
while(1
)
+
for (i = 0; i < Ctx->nNotifyHosts; i++
)
{
URL = GetNHBuf(i*2, 0, Ctx->NotifyHostList);
{
URL = GetNHBuf(i*2, 0, Ctx->NotifyHostList);
@@
-327,7
+327,6
@@
void process_notify(long NotifyMsgnum, void *usrdata)
msg->cm_fields['I'],
msgnum,
NULL);
msg->cm_fields['I'],
msgnum,
NULL);
- i++;
}
FreeStrBuf(&FileBuf);
}
}
FreeStrBuf(&FileBuf);
}
@@
-365,11
+364,9
@@
void process_notify(long NotifyMsgnum, void *usrdata)
*/
void do_extnotify_queue(void)
{
*/
void do_extnotify_queue(void)
{
- CitContext *CCC = CC;
-
NotifyContext Ctx;
static int doing_queue = 0;
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
/*
* This is a simple concurrency check to make sure only one queue run
@@
-396,16
+393,29
@@
void do_extnotify_queue(void)
CtdlLogPrintf(CTDL_DEBUG, "serv_extnotify: processing notify queue\n");
memset(&Ctx, 0, sizeof(NotifyContext));
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();
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;
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);
+ }
}
}
diff --git
a/citadel/modules/extnotify/funambol65.c
b/citadel/modules/extnotify/funambol65.c
index 6049b179d2fbd8877286a476551a4a209eb094da..38499fafc3deddb3776e3b95582c214d7a05ed97 100644
(file)
--- a/
citadel/modules/extnotify/funambol65.c
+++ b/
citadel/modules/extnotify/funambol65.c
@@
-67,6
+67,7
@@
int notify_http_server(char *remoteurl,
char *SOAPMessage = NULL;
char *contenttype = NULL;
StrBuf *ReplyBuf;
char *SOAPMessage = NULL;
char *contenttype = NULL;
StrBuf *ReplyBuf;
+ StrBuf *Buf;
CURL *chnd;
AsyncIO *IO;
CURL *chnd;
AsyncIO *IO;
@@
-145,7
+146,9
@@
int notify_http_server(char *remoteurl,
IO->HttpReq.headers = curl_slist_append(IO->HttpReq.headers, "Pragma: no-cache");
}
IO->HttpReq.headers = curl_slist_append(IO->HttpReq.headers, "Pragma: no-cache");
}
- ParseURL(&IO->ConnectMe, NewStrBufPlain (remoteurl, -1), 80);
+ Buf = NewStrBufPlain (remoteurl, -1);
+ ParseURL(&IO->ConnectMe, Buf, 80);
+ FreeStrBuf(&Buf); /* TODO: this is uncool... */
CurlPrepareURL(IO->ConnectMe);
if (! evcurl_init(IO,
// Ctx,
CurlPrepareURL(IO->ConnectMe);
if (! evcurl_init(IO,
// Ctx,