[PATCH] bb_boxc retry on ack_failed_tmp (was Re: smsbox to bearerbox ack / nack)

"Alexander Malysh" <[email protected]>
Newsgroups gmane.comp.mobile.kannel.devel
Message-ID <[email protected]>
Hi Ben,

attached simple patch implements resend of MO/DLR messages if some box  
sent nack with ack_failed_tmp status.

Comments please?

Am 18.01.2007, 11:50 Uhr, schrieb Ben Suffolk <[email protected]>:

> Thanks Alex
>
> It will be most useful to have it in place.
>
> Regards
>
> Ben
> On 17 Jan 2007, at 10:15, Alexander Malysh wrote:
>
>> Hi Ben,
>>
>> no sorry, I did not managed to do it. I will try to do it this week.
>>
>> Am 17.01.2007, 10:48 Uhr, schrieb Ben Suffolk <[email protected]>:
>>
>>>> no you miss the point. ack_success and ac_failed are the final states  
>>>> and therefor bearerbox drops these messages from the store and queue.  
>>>> When I commited this patch I told that it misses ack_failed_tmp that  
>>>> is used for the purpose you describe. That means when bearerbox  
>>>> receive ack with ack_failed_tmp (temporarely) bearerbox will then do  
>>>> retry for this message.
>>>> I will try to merge this bit this week.
>>>
>>> Hi Alex,
>>>
>>> Just wondering if you managed to merge in the code for the retry from  
>>> bearerbox to smsbox when smsbox responds with  ack_failed_tmp?
>>>
>>> Regards
>>>
>>> Ben
>>>
>>>
>>>
>>>
>>
>>
>>
>> --Thanks,
>> Alex
>>
>>
>
>
>



-- 
Thanks,
Alex
bb_boxc-tmp-nack.patch (text/x-patch, 3.5 KB)
=== gw/bb_boxc.c
==================================================================
--- gw/bb_boxc.c	(revision 263)
+++ gw/bb_boxc.c	(local)
@@ -152,7 +152,7 @@
 static void sms_to_smsboxes(void *arg);
 static int send_msg(Boxc *boxconn, Msg *pmsg);
 static void boxc_sent_push(Boxc*, Msg*);
-static void boxc_sent_pop(Boxc*, Msg*);
+static void boxc_sent_pop(Boxc*, Msg*, Msg**);
 
 
 /*-------------------------------------------------
@@ -296,14 +296,14 @@
                 /* wakeup the dequeue thread */
                 gwthread_wakeup(sms_dequeue_thread);
             }
-        } else if (msg_type(msg) == wdp_datagram  && conn->is_wap) {
+        } else if (msg_type(msg) == wdp_datagram && conn->is_wap) {
             debug("bb.boxc", 0, "boxc_receiver: got wdp from wapbox");
 
             /* XXX we should block these in SHUTDOWN phase too, but
                we need ack/nack msgs implemented first. */
             gwlist_produce(conn->outgoing, msg);
 
-        } else if (msg_type(msg) == sms  && conn->is_wap) {
+        } else if (msg_type(msg) == sms && conn->is_wap) {
             debug("bb.boxc", 0, "boxc_receiver: got sms from wapbox");
 
             /* should be a WAP push message, so tried it the same way */
@@ -317,13 +317,20 @@
         } else {
             if (msg_type(msg) == heartbeat) {
                 if (msg->heartbeat.load != conn->load)
-		              debug("bb.boxc", 0, "boxc_receiver: heartbeat with "
-			                "load value %ld received", msg->heartbeat.load);
+                    debug("bb.boxc", 0, "boxc_receiver: heartbeat with "
+                          "load value %ld received", msg->heartbeat.load);
                 conn->load = msg->heartbeat.load;
             }
             else if (msg_type(msg) == ack) {
-                boxc_sent_pop(conn, msg);
-                store_save(msg);
+                if (msg->ack.nack == ack_failed_tmp) {
+                    Msg *orig;
+                    boxc_sent_pop(conn, msg, &orig);
+                    if (orig != NULL) /* retry this message */
+                        gwlist_append(conn->retry, orig);
+                } else {
+                    boxc_sent_pop(conn, msg, NULL);
+                    store_save(msg);
+                }
                 debug("bb.boxc", 0, "boxc_receiver: got ack");
             }
             /* if this is an identification message from an smsbox instance */
@@ -413,7 +420,11 @@
 }
 
 
-static void boxc_sent_pop(Boxc *conn, Msg *m)
+/*
+ * Remove msg from sent queue.
+ * Return 0 if message should be deleted from store and 1 if not (e.g. tmp nack)
+ */
+static void boxc_sent_pop(Boxc *conn, Msg *m, Msg **orig)
 {
     Octstr *os;
     char id[UUID_STR_LEN + 1];
@@ -422,6 +433,9 @@
     if (conn->is_wap || !conn->sent || !m || (msg_type(m) != ack && msg_type(m) != sms))
         return;
 
+    if (orig != NULL)
+        *orig = NULL;
+    
     uuid_unparse((msg_type(m) == sms ? m->sms.id : m->ack.id), id);
     os = octstr_create(id);
     msg = dict_remove(conn->sent, os);
@@ -432,7 +446,10 @@
         return;
     }
     semaphore_up(conn->pending);
-    msg_destroy(msg);
+    if (orig == NULL)
+        msg_destroy(msg);
+    else
+        *orig = msg;
 }
 
 
@@ -469,7 +486,7 @@
         boxc_sent_push(conn, msg);
         if (!conn->alive || send_msg(conn, msg) == -1) {
             /* we got message here */
-            boxc_sent_pop(conn, msg);
+            boxc_sent_pop(conn, msg, NULL);
             gwlist_produce(conn->retry, msg);
             break;
         }
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.