httpd: fw update - gracefully close connections before restart

This commit is contained in:
andy.padavan
2012-05-11 01:36:14 +08:00
parent e28efecc18
commit 741609d40b
2 changed files with 22 additions and 26 deletions

View File

@@ -58,7 +58,7 @@ typedef unsigned char bool;
#include <stdarg.h>
#include <sys/wait.h>
#include <dirent.h>
//#include <wlutils.h> Viz banned 2010.08
#include <sys/reboot.h>
#include <proto/ethernet.h> //add by Viz 2010.08
#ifdef WRITE2FLASH
@@ -5232,18 +5232,32 @@ do_upgrade_post(char *url, FILE *stream, int len, char *boundary)
static void
do_upgrade_cgi(char *url, FILE *stream)
{
printf("## [httpd] do upgrade cgi\n"); // tmp test
/* Reboot if successful */
int i, success = 0;
if (chk_image_err == 0)
{
system("killall -q watchdog");
websApply(stream, "Updating.asp");
system("/sbin/mtd_storage.sh save");
eval("/bin/mtd_write", "-r", "write", "/tmp/linux.trx", "Firmware_Stub");
websApply(stream, "Updating.asp");
if (eval("/bin/mtd_write", "write", "/tmp/linux.trx", "Firmware_Stub") == 0) {
success = 1;
system("killall -q l2tpd");
system("killall -q pppd");
for (i=0; i<5; i++) {
if (!pids("pppd"))
break;
sleep(1);
}
system("killall -q wpa_cli");
system("killall -q wpa_supplicant");
system("ifconfig ra0 down");
system("ifconfig rai0 down");
system("ifconfig eth3 down");
reboot(RB_AUTOBOOT);
}
}
else
{
if (!success) {
websApply(stream, "UpdateError.asp");
unlink("/tmp/linux.trx");
}

View File

@@ -242,24 +242,6 @@ fatal_signal(int sig)
{
dbG("sig: %d 0x%x\n", sig, sig);
char *message = NULL;
switch (sig) {
case SIGQUIT: message = "Quit"; break;
case SIGILL: message = "Illegal instruction"; break;
case SIGABRT: message = "Abort"; break;
case SIGFPE: message = "Floating exception"; break;
case SIGPIPE: message = "Broken pipe"; break;
case SIGBUS: message = "Bus error"; break;
case SIGSEGV: message = "Segmentation fault"; break;
case SIGSYS: message = "Bad system call"; break;
case SIGTRAP: message = "Trace trap"; break;
case SIGPWR: message = "Power failure"; break;
case SIGTERM: message = "Terminated"; break;
}
if (message)
dbG("%s\n", message);
system("touch /tmp/.reboot");
shutdown_system();
sleep(1);