X-Kannel-DLR-Mask problem
Edwin Pratomo <[email protected]>
| Newsgroups | gmane.comp.mobile.kannel.devel |
|---|---|
| Message-ID | <[email protected]> |
Dear kannel developers,
I encountered a problem when using X-Kannel-DLR-Mask as well as X-Kannel-DLR-URL headers in a response sent by a sms-service application. In that case, no message sent back to sender by kannel.
After looking into gw/smsbox.c (from recent cvs repos) to get some idea of what's happened, it's obvious that after invoking get_x_kannel_from_headers() in url_result_thread(), msg->sms.dlr_mask got set according to the value of X-Kannel-DLR-Mask. Then here comes a condition (line 1060):
if (msg->sms.dlr_mask == 0 && !queued) {
if (send_message(trans, msg) < 0)
error(0, "failed to send message to phone");
}
This way the message was never sent. I think it was confused between dlr_mask which comes from get_x_kannel_headers() and the one from get_receiver(), so my fix is to add a flag to distinguish between these, and change the above condition to regard this flag.
An output of diff -u is attached.
rgds,
Edwin.
smsbox.c.patch
(text/x-diff, 1.2 KB)
--- gw/smsbox.c~ Wed Apr 23 10:14:49 2003
+++ gw/smsbox.c Wed Apr 23 10:18:45 2003
@@ -950,6 +950,7 @@
int validity, deferred;
unsigned long retries;
unsigned int queued; /* indicate if processes reply is requeued */
+ int from_receiver;
dlr_mask = 0;
dlr_url = NULL;
@@ -960,6 +961,7 @@
octet_stream = octstr_imm("application/octet-stream");
for (;;) {
+ from_receiver = 0;
queued = 0;
id = http_receive_result(caller, &status, &final_url, &reply_headers,
&reply_body);
@@ -967,6 +969,7 @@
break;
get_receiver(id, &msg, &trans, &method, &req_url, &req_headers, &req_body, &retries);
+ from_receiver = msg->sms.dlr_mask;
from = to = udh = smsc = NULL;
octets = mclass = mwi = coding = compress = pid = alt_dcs = rpi = 0;
@@ -1057,7 +1060,7 @@
http_destroy_headers(req_headers);
octstr_destroy(req_body);
- if (msg->sms.dlr_mask == 0 && !queued) {
+ if ((msg->sms.dlr_mask == 0 || !from_receiver) && !queued) {
if (send_message(trans, msg) < 0)
error(0, "failed to send message to phone");
}