Re: [PATCH] add restart to bearerbox

2003-02-24 Thread Stipe Tolj
Alexander Malysh wrote:
 
 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 ;)

+1, commited to cvs.

Stipe

[EMAIL PROTECTED]
---
Wapme Systems AG

Vogelsanger Weg 80
40470 Düsseldorf

Tel: +49-211-74845-0
Fax: +49-211-74845-299

E-Mail: [EMAIL PROTECTED]
Internet: http://www.wapme-systems.de
---
wapme.net - wherever you are



[PATCH] add restart to bearerbox

2003-02-22 Thread Alexander Malysh
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 -	1.61
+++ gw/bb_boxc.c	22 Feb 2003 21:02:49 -
 -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 -	1.41
+++ gw/bb_http.c	22 Feb 2003 21:02:50 -
 -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 -	1.132
+++ gw/bearerbox.c	22 Feb 2003 21:02:51 -
 -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();
 }
 
 


pgp0.pgp
Description: signature