Hi list, attached patch adds restart functionality to bearerbox and will fix small bug in bb_boxc.c (not closing of listen socket while shutting down).
Please look in it and vote ;) -- 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.61 diff -a -u -r1.61 bb_boxc.c --- gw/bb_boxc.c 5 Feb 2003 23:49:30 -0000 1.61 +++ gw/bb_boxc.c 22 Feb 2003 21:02:49 -0000 @@ -738,6 +738,8 @@ while(list_wait_until_nonempty(smsbox_list)!= -1) sleep(1); + /* close listen socket */ + close(fd); list_destroy(smsbox_list, NULL); smsbox_list = NULL; @@ -785,7 +787,9 @@ /* wait for wdp_to_wapboxes to exit */ while(list_consume(wapbox_list)!=NULL) ; - + + /* close listen socket */ + close(fd); list_destroy(wapbox_list, NULL); wapbox_list = NULL; Index: gw/bb_http.c =================================================================== RCS file: /home/cvs/gateway/gw/bb_http.c,v retrieving revision 1.41 diff -a -u -r1.41 bb_http.c --- gw/bb_http.c 20 Nov 2002 00:36:50 -0000 1.41 +++ gw/bb_http.c 22 Feb 2003 21:02:50 -0000 @@ -142,6 +142,21 @@ return octstr_create("Running resumed"); } +static Octstr *httpd_restart(List *cgivars) +{ + Octstr *reply; + if ((reply = httpd_check_authorization(cgivars, 0))!= NULL) return reply; + if ((reply = httpd_check_status())!= NULL) return reply; + + if (bb_status == BB_SHUTDOWN) { + bb_status = BB_DEAD; + gwthread_wakeup_all(); + return octstr_create("Trying harder to restart"); + } + bb_restart(); + return octstr_create("Restarting....."); +} + static Octstr *httpd_flush_dlr(List *cgivars) { Octstr *reply; @@ -258,6 +273,9 @@ } else if (octstr_str_compare(url, "/cgi-bin/resume")==0 || octstr_str_compare(url, "/resume")==0) { reply = httpd_resume(cgivars); + } else if (octstr_str_compare(url, "/cgi-bin/restart")==0 + || octstr_str_compare(url, "/restart")==0) { + reply = httpd_restart(cgivars); } else if (octstr_str_compare(url, "/cgi-bin/flush-dlr")==0 || octstr_str_compare(url, "/flush-dlr")==0) { reply = httpd_flush_dlr(cgivars); @@ -268,7 +286,7 @@ || octstr_str_compare(url, "/start-smsc")==0) { reply = httpd_restart_smsc(cgivars); /* - * reconfig? restart? + * reconfig? */ } else { reply = octstr_format("Unknown command %S", url); Index: gw/bearerbox.c =================================================================== RCS file: /home/cvs/gateway/gw/bearerbox.c,v retrieving revision 1.132 diff -a -u -r1.132 bearerbox.c --- gw/bearerbox.c 6 Sep 2002 12:01:27 -0000 1.132 +++ gw/bearerbox.c 22 Feb 2003 21:02:51 -0000 @@ -65,7 +65,7 @@ static Mutex *status_mutex; Mutex *boxid_mutex; static time_t start_time; - +int restart = 0; /* to avoid copied code */ @@ -524,6 +524,9 @@ dlr_shutdown(); gwlib_shutdown(); + if (restart == 1) + execvp(argv[0],argv); + return 0; } @@ -636,7 +639,8 @@ int bb_restart(void) { - return -1; + restart = 1; + return bb_shutdown(); }
pgp00000.pgp
Description: signature