[PATCH]: HTTP reply from sendota fixes (#1)
"Dziugas Baltrunas" <[email protected]>
| Newsgroups | gmane.comp.mobile.kannel.devel |
|---|---|
| Message-ID | <[email protected]> |
Hi, list, attached patch fixes freeing of msg structure in smsbox.c sendota stuff before extracting it's uuid with store_uuid(). Without patch applied you can see the following in the logs: 2006-03-20 18:35:36 [29721] [3] DEBUG: Stored UUID 00000000-0000-0000-0000-000000000000 However, current patch does not solve HTTP reply from sendota completely, since it's related how fast we get an ACK from bearerbox. If we're successful, we'll get "0: Accepted for delivery", and if not, no answer will be sent at all. This can be illustrated by these snippets: 1. We got an ACK from bearerbox (read_messages_from_bearerbox()) before store_uuid() was called: 2006-03-21 12:47:37 [19015] [3] INFO: /cgi-bin/sendota <<default>> <XXX> 2006-03-21 12:47:37 [19015] [3] DEBUG: message length 446, sending 4 messages 2006-03-21 12:47:37 [19015] [0] DEBUG: Got ACK (0) of 8b37ca04-896f-4510-8d2d-000289b6b8b2 2006-03-21 12:47:37 [19015] [0] DEBUG: No client - multi-send or ACK to pull-reply 2006-03-21 12:47:37 [19015] [3] DEBUG: Stored UUID 8b37ca04-896f-4510-8d2d-000289b6b8b2 2006-03-21 12:47:37 [19015] [3] DEBUG: Status: 202 Answer: <Sent.> 2006-03-21 12:47:37 [19015] [3] DEBUG: Delayed reply - wait for bearerbox 2. We got an ACK from bearerbox after store_uuid() was called (as expected): 2006-03-21 12:47:09 [19015] [3] INFO: /cgi-bin/sendota <<default>> <XXX> 2006-03-21 12:47:09 [19015] [3] DEBUG: message length 446, sending 4 messages 2006-03-21 12:47:09 [19015] [3] DEBUG: Stored UUID f6b0cb63-b561-49fa-951b-09aa5177067e 2006-03-21 12:47:09 [19015] [3] DEBUG: Status: 202 Answer: <Sent.> 2006-03-21 12:47:09 [19015] [3] DEBUG: Delayed reply - wait for bearerbox 2006-03-21 12:47:09 [19015] [0] DEBUG: Got ACK (0) of f6b0cb63-b561-49fa-951b-09aa5177067e This is relevant only when immediate_sendsms_reply is false (which is default!), so I should ask Kalle, the author of introducing this feature, comment on possible thread synchronisation issues, which IMHO sometimes could also arise for ordinary sendsms request. Thanks, Dziugas
immediate_sendsms_reply.patch
(text/plain, 1.8 KB)
Index: smsbox.c
===================================================================
RCS file: /home/cvs/gateway/gw/smsbox.c,v
retrieving revision 1.260
diff -u -r1.260 smsbox.c
--- smsbox.c 9 Dec 2005 02:14:31 -0000 1.260
+++ smsbox.c 21 Mar 2006 10:53:57 -0000
@@ -2316,7 +2316,7 @@
/* Store id if needed for a delayed HTTP reply */
if (!immediate_sendsms_reply) {
- *stored_uuid = store_uuid(msg);
+ *stored_uuid = store_uuid(msg);
}
@@ -2793,6 +2793,7 @@
{
Octstr *id, *from, *phonenumber, *smsc, *ota_doc, *doc_type, *account;
CfgGroup *grp;
+ Octstr *returnerror;
List *grplist;
Octstr *p;
URLTranslation *t;
@@ -2945,20 +2946,22 @@
id ? octstr_get_cstr(id) : "<default>", octstr_get_cstr(phonenumber));
ret = send_message(t, msg);
- msg_destroy(msg);
+
+ *status = HTTP_ACCEPTED;
+ returnerror = octstr_create("Sent.");
if (ret == -1) {
error(0, "sendota_request: failed");
*status = HTTP_INTERNAL_SERVER_ERROR;
- return octstr_create("Sending failed.");
+ returnerror = octstr_create("Sending failed.");
}
else if (!immediate_sendsms_reply) {
- *stored_uuid = store_uuid(msg);
+ *stored_uuid = store_uuid(msg);
}
-
- *status = HTTP_ACCEPTED;
- return octstr_create("Sent.");
+ msg_destroy(msg);
+
+ return returnerror;
}
@@ -3126,7 +3129,9 @@
id ? octstr_get_cstr(id) : "XML", octstr_get_cstr(to));
r = send_message(t, msg);
- msg_destroy(msg);
+
+ *status = HTTP_ACCEPTED;
+ ret = octstr_create("Sent.");
if (r == -1) {
error(0, "sendota_request: failed");
@@ -3137,8 +3142,8 @@
*stored_uuid = store_uuid(msg);
}
- *status = HTTP_ACCEPTED;
- ret = octstr_create("Sent.");
+ msg_destroy(msg);
+
}
}