[PATCH] UCP/EMI keepalive/UCP31 bug.

Vincent CHAVANIS <[email protected]>
Newsgroups gmane.comp.mobile.kannel.devel
Message-ID <[email protected]>
Hi all,

A bug still exists on the UCP/EMI driver.
-Keepalive was wrong because the sender thread was awaken keepalive + 1
When you set keepalive=5 you will in reality have keepalive=6

-Then, the patch also fixes the UCP31 at login.
We don't need to send it beacause UCP60 already make an activity on the 
SMSC line. (The issue is that we need to wait_for_ack in order to send 
MT = waste of time). Note that UCP31 is an alert operation which can be 
used for a TCP keepalive.

 From the point of view of <Bruno Rodrigues> who dit the previous patch 
(2002-03-14) "a bug when Kannel couldn't connect to the server on the 
first time, and then on a later attempt, the last_activity was wrong and 
Kannel wouldn't send the 31's, or would send them at the wrong time. 
[...] As a work around I made Kannel always send a 31 after a successful 
login to make sure the timers were reset."
This does not seems to happens anymore.


Any comments ?


Vincent


-- 
Telemaque - 06560 SOPHIA-ANTIPOLIS - (FR)
Service Technique/Reseau - NOC
Direction du Developpement xMS+
http://www.telemaque.fr/
[email protected]
Tel : +33 4 92 90 99 84 (fax 9142)
keepalive_emiucp.txt (text/plain, 2 KB)
@@ -158,7 +159,7 @@
 #define emi2_needs_keepalive(conn)                                                     \
 (emi2_can_send(conn) &&                                                                        \
  (PRIVDATA(conn)->keepalive > 0) &&                                                    \
- (time(NULL) > (PRIVDATA(conn)->last_activity_time + PRIVDATA(conn)->keepalive)))
+ (time(NULL) >= (PRIVDATA(conn)->last_activity_time + PRIVDATA(conn)->keepalive)))
 
 /*
  * Send an EMI message and update the last_activity_time field.
@@ -366,7 +373,7 @@
             connect_error = 1;
             continue;
         }
-        privdata->last_activity_time = 0; /* to force keepalive after login */
+        privdata->last_activity_time = time (NULL); /* to *NOT* force keepalive after login */
         privdata->can_write = 1;
     }
@@ -1151,6 +1198,7 @@
                        /* } */
                    }
                } else if (emimsg->ot == 31) {
+                    PRIVDATA(conn)->last_activity_time = time (NULL);         
                    /* XXX Process error codes here
                    if (octstr_get_char(emimsg->fields[0], 0) == 'N') {
                        long errorcode;
@@ -1269,7 +1317,7 @@
  */
 static double emi2_get_timeouttime (SMSCConn *conn, Connection *server)
 {
-    double ka_timeouttime = PRIVDATA(conn)->keepalive ? PRIVDATA(conn)->keepalive + 1 : DBL_MAX;
+    double ka_timeouttime = PRIVDATA(conn)->keepalive ? PRIVDATA(conn)->keepalive : DBL_MAX;
     double idle_timeouttime = (PRIVDATA(conn)->idle_timeout && server) ? PRIVDATA(conn)->idle_timeout : DBL_MAX;
     double result = ka_timeouttime < idle_timeouttime ? ka_timeouttime : idle_timeouttime; 
@@ -1626,7 +1674,7 @@
     privdata->listening_socket = -1;
     privdata->can_write = 1;
     privdata->priv_nexttrn = 0;
-    privdata->last_activity_time = 0;
+    privdata->last_activity_time = time (NULL); /* to *NOT* force keepalive after login */
     privdata->check_time = 0;
     
     host = cfg_get(cfg, octstr_imm("host"));
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.