Hi list, attached patch adds missing restart functionality to smsbox and wapbox. So you can now really use this functionality over http-admin interface :)
Comments and votes please ... -- Best Regards / Mit besten Grüßen aus Köln Dipl.-Ing. Alexander Malysh ___________________________________ Centrium GmbH Ehrenstrasse 2 50672 Köln Fon: +49 (0221) 277 49 240 Fax: +49 (0221) 277 49 109 email: [EMAIL PROTECTED] web: http://www.centrium.de msn: [EMAIL PROTECTED]
Index: gw/bb_boxc.c =================================================================== RCS file: /home/cvs/gateway/gw/bb_boxc.c,v retrieving revision 1.64 diff -a -u -r1.64 bb_boxc.c --- gw/bb_boxc.c 11 Mar 2003 15:28:23 -0000 1.64 +++ gw/bb_boxc.c 22 Mar 2003 20:01:06 -0000 @@ -26,6 +26,7 @@ /* passed from bearerbox core */ extern volatile sig_atomic_t bb_status; +extern volatile sig_atomic_t restart; extern List *incoming_sms; extern List *outgoing_sms; extern List *incoming_wdp; @@ -307,7 +308,7 @@ /* tell sms/wapbox to die */ msg = msg_create(admin); - msg->admin.command = cmd_shutdown; + msg->admin.command = (restart==1?cmd_restart:cmd_shutdown); send_msg(conn, msg); msg_destroy(msg); break; Index: gw/bearerbox.c =================================================================== RCS file: /home/cvs/gateway/gw/bearerbox.c,v retrieving revision 1.136 diff -a -u -r1.136 bearerbox.c --- gw/bearerbox.c 9 Mar 2003 22:36:18 -0000 1.136 +++ gw/bearerbox.c 22 Mar 2003 20:01:07 -0000 @@ -65,7 +65,7 @@ static Mutex *status_mutex; Mutex *boxid_mutex; static time_t start_time; -int restart = 0; +volatile sig_atomic_t restart = 0; /* to avoid copied code */ Index: gw/msg.h =================================================================== RCS file: /home/cvs/gateway/gw/msg.h,v retrieving revision 1.14 diff -a -u -r1.14 msg.h --- gw/msg.h 11 Mar 2003 15:28:23 -0000 1.14 +++ gw/msg.h 22 Mar 2003 20:01:07 -0000 @@ -44,7 +44,8 @@ cmd_shutdown = 0, cmd_suspend = 1, cmd_resume = 2, - cmd_identify = 3 + cmd_identify = 3, + cmd_restart = 4 }; /* ack message status */ Index: gw/smsbox.c =================================================================== RCS file: /home/cvs/gateway/gw/smsbox.c,v retrieving revision 1.219 diff -a -u -r1.219 smsbox.c --- gw/smsbox.c 11 Mar 2003 15:28:23 -0000 1.219 +++ gw/smsbox.c 22 Mar 2003 20:01:13 -0000 @@ -40,6 +40,9 @@ #define HTTP_MAX_RETRIES 0 #define HTTP_RETRY_DELAY 10 /* in sec. */ +/* have we received restart cmd from bearerbox? */ +volatile sig_atomic_t restart = 0; + static Cfg *cfg; static long bb_port; static int bb_ssl = 0; @@ -116,6 +119,10 @@ if (msg->admin.command == cmd_shutdown) { info(0, "Bearerbox told us to die"); program_status = shutting_down; + } else if (msg->admin.command == cmd_restart) { + info(0, "Bearerbox told us to restart"); + restart = 1; + program_status = shutting_down; } /* * XXXX here should be suspend/resume, add RSN @@ -3135,7 +3142,21 @@ numhash_destroy(black_list); numhash_destroy(white_list); cfg_destroy(cfg); + + /* + * Just sleep for a while to get bearerbox chance to restart. + * Otherwise we will fail while connect to bearerbox! + */ + if (restart == 1) { + gwthread_sleep(5.0); + } + gwlib_shutdown(); + + /* now really restart */ + if (restart == 1) + execvp(argv[0],argv); + return 0; } Index: gw/wapbox.c =================================================================== RCS file: /home/cvs/gateway/gw/wapbox.c,v retrieving revision 1.156 diff -a -u -r1.156 wapbox.c --- gw/wapbox.c 4 Mar 2003 15:16:08 -0000 1.156 +++ gw/wapbox.c 22 Mar 2003 20:01:14 -0000 @@ -415,6 +415,7 @@ int main(int argc, char **argv) { int cf_index; + int restart = 0; Msg *msg; Octstr *filename; Cfg *cfg; @@ -498,6 +499,10 @@ if (msg->admin.command == cmd_shutdown) { info(0, "Bearerbox told us to die"); program_status = shutting_down; + } else if (msg->admin.command == cmd_restart) { + info(0, "Bearerbox told us to restart"); + restart = 1; + program_status = shutting_down; } /* * XXXX here should be suspend/resume, add RSN @@ -560,7 +565,21 @@ wsp_http_map_destroy(); octstr_destroy(device_home); octstr_destroy(bearerbox_host); + + /* + * Just sleep for a while to get bearerbox chance to restart. + * Otherwise we will fail while connect to bearerbox! + */ + if (restart == 1) { + gwthread_sleep(5.0); + } + gwlib_shutdown(); + + /* now really restart */ + if (restart == 1) + execvp(argv[0],argv); + return 0; }
smime.p7s
Description: signature