Patch: http-timeout support

"Nikos Balkanas" <[email protected]>
Newsgroups gmane.comp.mobile.kannel.devel
Message-ID <5CBFED09DCDB47528A3A054EA12E3D13@tardis>
Hi,

This patch adds configurable http-timeout support for outgoing http client connections. Patch provided for bearerbox, wapbox, smsbox & userguide.

BR,
Nikos
kannel.diff (application/octet-stream, 4.9 KB)
Index: gw/bearerbox.c
===================================================================
RCS file: /home/cvs/gateway/gw/bearerbox.c,v
retrieving revision 1.172
diff -a -u -r1.172 bearerbox.c
--- gw/bearerbox.c	1 Sep 2009 21:45:44 -0000	1.172
+++ gw/bearerbox.c	3 Dec 2009 21:53:30 -0000
@@ -360,7 +360,7 @@
 {
     CfgGroup *grp;
     Octstr *log, *val;
-    long loglevel, store_dump_freq;
+    long loglevel, store_dump_freq, value;
     int lf, m;
 #ifdef HAVE_LIBSSL
     Octstr *ssl_server_cert_file;
@@ -498,6 +498,9 @@
     if (max_outgoing_sms_qlength < 0)
         max_outgoing_sms_qlength = DEFAULT_OUTGOING_SMS_QLENGTH;
 
+    if (cfg_get_integer(&value, grp, octstr_imm("http-timeout"))
+         == 0)
+        http_set_client_timeout(value);
 #ifndef NO_SMS    
     {
         List *list;
Index: gw/wapbox.c
===================================================================
RCS file: /home/cvs/gateway/gw/wapbox.c,v
retrieving revision 1.187
diff -a -u -r1.187 wapbox.c
--- gw/wapbox.c	12 Jan 2009 16:46:57 -0000	1.187
+++ gw/wapbox.c	3 Dec 2009 21:53:30 -0000
@@ -126,6 +126,7 @@
     Octstr *s;
     Octstr *logfile;
     int lf, m;
+    long value;
 
     lf = m = 1;
 
@@ -200,6 +201,9 @@
         octstr_destroy(s);
     }
 
+    if (cfg_get_integer(&value, grp, octstr_imm("http-timeout")) == 0)
+       http_set_client_timeout(value);
+
     /* configure the 'wtls' group */
 #if (HAVE_WTLS_OPENSSL)
     /* Load up the necessary keys */
Index: gw/smsbox.c
===================================================================
RCS file: /home/cvs/gateway/gw/smsbox.c,v
retrieving revision 1.283
diff -a -u -r1.283 smsbox.c
--- gw/smsbox.c	20 May 2009 10:12:46 -0000	1.283
+++ gw/smsbox.c	3 Dec 2009 21:53:30 -0000
@@ -3340,7 +3340,7 @@
     CfgGroup *grp;
     Octstr *logfile;
     Octstr *p;
-    long lvl;
+    long lvl, value;
     Octstr *http_proxy_host = NULL;
     long http_proxy_port = -1;
     int http_proxy_ssl = 0;
@@ -3540,6 +3540,9 @@
         max_req = HTTP_MAX_PENDING; 
     max_pending_requests = semaphore_create(max_req);
 
+    if (cfg_get_integer(&value, grp, octstr_imm("http-timeout")) == 0)
+       http_set_client_timeout(value);
+
     /*
      * Reading the name we are using for ppg services from ppg core group
      */
Index: gwlib/cfg.def
===================================================================
RCS file: /home/cvs/gateway/gwlib/cfg.def,v
retrieving revision 1.141
diff -a -u -r1.141 cfg.def
--- gwlib/cfg.def	23 Jun 2009 07:19:58 -0000	1.141
+++ gwlib/cfg.def	3 Dec 2009 21:53:30 -0000
@@ -126,6 +126,7 @@
     OCTSTR(sms-resend-retry)
     OCTSTR(sms-combine-concatenated-mo)
     OCTSTR(sms-combine-concatenated-mo-timeout)
+    OCTSTR(http-timeout)
 )
 
 
@@ -159,6 +160,7 @@
     OCTSTR(concatenation)
     OCTSTR(max-messages)
     OCTSTR(wml-strict)
+    OCTSTR(http-timeout)
 )
 
 
@@ -280,6 +282,7 @@
     OCTSTR(black-list-regex)
     OCTSTR(immediate-sendsms-reply)
     OCTSTR(max-pending-requests)
+    OCTSTR(http-timeout)
 )
 
 
Index: gwlib/http.c
===================================================================
RCS file: /home/cvs/gateway/gwlib/http.c,v
retrieving revision 1.262
diff -a -u -r1.262 http.c
--- gwlib/http.c	18 Jun 2009 07:25:59 -0000	1.262
+++ gwlib/http.c	3 Dec 2009 21:53:32 -0000
@@ -88,7 +88,7 @@
 #define DUMP_RESPONSE 1
 
 /* define http client connections timeout in seconds (set to -1 for disable) */
-static int http_client_timeout = 240;
+static int http_client_timeout = 60;
 
 /* define http server connections timeout in seconds (set to -1 for disable) */
 #define HTTP_SERVER_TIMEOUT 60
Index: doc/userguide/userguide.xml
===================================================================
RCS file: /home/cvs/gateway/doc/userguide/userguide.xml,v
retrieving revision 1.357
diff -a -u -r1.357 userguide.xml
--- doc/userguide/userguide.xml	17 Sep 2009 21:53:55 -0000	1.357
+++ doc/userguide/userguide.xml	3 Dec 2009 21:53:34 -0000
@@ -1557,6 +1557,13 @@
         </entry>   
      </row>
 
+    <row><entry><literal>http-timeout</literal></entry>
+     <entry>seconds</entry>
+     <entry valign="bottom">
+        Sets socket timeout in seconds for outgoing client http
+        connections. Optional. Defaults to 60 seconds.
+     </entry></row>
+
   </tbody>
   </tgroup>
  </table>
@@ -2155,11 +2162,16 @@
 	 is assumed.
 	 </entry></row>
 
+    <row><entry><literal>http-timeout</literal></entry>
+     <entry>seconds</entry>
+     <entry valign="bottom">
+        Sets socket timeout in seconds for outgoing client http
+        connections. Optional. Defaults to 60 seconds.
+     </entry></row>
   </tbody>
   </tgroup>
  </table>
 
-
 <programlisting>
 </programlisting>
 </sect2>
@@ -5734,6 +5746,12 @@
         </entry>
      </row>
 
+    <row><entry><literal>http-timeout</literal></entry>
+     <entry>seconds</entry>
+     <entry valign="bottom">
+        Sets socket timeout in seconds for outgoing client http
+        connections. Optional. Defaults to 60 seconds.
+     </entry></row>
   </tbody>
   </tgroup>
  </table>
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.