smsbox - url_result_thread
"fred" <[email protected]>
| Newsgroups | gmane.comp.mobile.kannel.devel |
|---|---|
| Message-ID | <002401c5f9fd$d9cf97f0$0401a8c0@FRED4> |
I have a problem with kannel sending mt messages without the application knowing about it...i am not sure what
the reasoning for this is, but it seems a whole lot of code in url_result_thread() is quite incongruous to me!!
here is my revamped version
static void url_result_thread(void *arg)
{
Octstr *final_url, *req_body, *type, *replytext;
List *reply_headers;
List *req_headers;
int status, method;
void *id;
Msg *msg;
Msg *mack;
URLTranslation *trans;
Octstr *req_url;
Octstr *text_html, *text_plain, *text_wml, *text_xml;
Octstr *octet_stream;
int octets;
unsigned long retries;
Octstr *reply_body;
for (;;)
{
id = http_receive_result(caller, &status, &final_url, &reply_headers,
&reply_body);
if (id == NULL)
break;
get_receiver(id, &msg, &trans, &method, &req_url, &req_headers, &req_body, &retries);
if (status == HTTP_OK || status == HTTP_ACCEPTED)
{
mack = msg_create(ack); /* now that successfully sent, write ack back to bearer (fz)*/
gw_assert(mack != NULL);
uuid_copy(mack->ack.id, msg->sms.id);
mack->ack.time = msg->sms.time;
mack->ack.nack = ack_success;
write_to_bearerbox(mack); /* implicit msg_destroy */
}
else if (max_http_retries > retries)
{
id = remember_receiver(msg, trans, method, req_url, req_headers, req_body, retries);
gwlist_produce(smsbox_http_requests, id);
goto requeued;
}
else
{
warning(0,"could not fetch url:%s;retried %d, msg; receiver %s, sender %s",
octstr_get_cstr(req_url),
retries,octstr_get_cstr(msg->sms.receiver),octstr_get_cstr(msg->sms.sender)
);
}
requeued:
octstr_destroy(final_url);
http_destroy_headers(reply_headers);
octstr_destroy(reply_body);
octstr_destroy(req_url);
http_destroy_headers(req_headers);
octstr_destroy(req_body);
req_body=req_url=NULL;
req_headers=reply_headers=NULL;
msg_destroy(msg);
}
}
Yes, it has also been changed so that the ack goes back to bearerbox only after smsbox has successfully
passed the message on, which is how it should be.
So this function is now much cleaner, have I lost the plot about something ?? please advise ?