mirror of
https://gitea.psi.ch/ELOG/elog.git
synced 2026-09-10 18:23:28 +00:00
Fixed crash when running as windows service
SVN revision: 1084
This commit is contained in:
parent
0055996b1f
commit
7df850c62b
43
src/elogd.c
43
src/elogd.c
@ -6,6 +6,9 @@
|
|||||||
Contents: Web server program for Electronic Logbook ELOG
|
Contents: Web server program for Electronic Logbook ELOG
|
||||||
|
|
||||||
$Log$
|
$Log$
|
||||||
|
Revision 1.477 2004/09/18 05:45:43 midas
|
||||||
|
Fixed crash when running as windows service
|
||||||
|
|
||||||
Revision 1.476 2004/09/18 04:54:17 midas
|
Revision 1.476 2004/09/18 04:54:17 midas
|
||||||
Fixed problem withe missing attachment images
|
Fixed problem withe missing attachment images
|
||||||
|
|
||||||
@ -19474,12 +19477,7 @@ void server_loop(void)
|
|||||||
/* Redirect all messages handled with eprintf/efputs to syslog */
|
/* Redirect all messages handled with eprintf/efputs to syslog */
|
||||||
redirect_to_syslog();
|
redirect_to_syslog();
|
||||||
|
|
||||||
#ifdef OS_WINNT
|
#ifdef OS_UNIX
|
||||||
if (!run_service()) {
|
|
||||||
eprintf("Couldn't run the service; aborting\n");
|
|
||||||
exit(EXIT_FAILURE);
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
if (!ss_daemon_init()) {
|
if (!ss_daemon_init()) {
|
||||||
eprintf("Couldn't initiate the daemon; aborting\n");
|
eprintf("Couldn't initiate the daemon; aborting\n");
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
@ -20303,17 +20301,24 @@ void server_loop(void)
|
|||||||
|
|
||||||
} while (!_abort);
|
} while (!_abort);
|
||||||
|
|
||||||
|
eprintf("elogd server aborted.\n");
|
||||||
|
|
||||||
/* free all allocated memory */
|
/* free all allocated memory */
|
||||||
for (i = 0; lb_list[i].name[0]; i++) {
|
for (i = 0; lb_list[i].name[0]; i++) {
|
||||||
xfree(lb_list[i].el_index);
|
if (lb_list[i].el_index) {
|
||||||
xfree(lb_list[i].n_el_index);
|
xfree(lb_list[i].el_index);
|
||||||
|
lb_list[i].el_index = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (lb_list[i].n_el_index) {
|
||||||
|
xfree(lb_list[i].n_el_index);
|
||||||
|
lb_list[i].n_el_index = NULL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
xfree(net_buffer);
|
xfree(net_buffer);
|
||||||
xfree(return_buffer);
|
xfree(return_buffer);
|
||||||
xfree(cfgbuffer);
|
xfree(cfgbuffer);
|
||||||
|
|
||||||
eprintf("elogd server aborted.\n");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*------------------------------------------------------------------*/
|
/*------------------------------------------------------------------*/
|
||||||
@ -20547,6 +20552,7 @@ void create_password(char *logbook, char *name, char *pwd)
|
|||||||
/* write remainder of file */
|
/* write remainder of file */
|
||||||
write(fh, p, strlen(p));
|
write(fh, p, strlen(p));
|
||||||
xfree(cfgbuffer);
|
xfree(cfgbuffer);
|
||||||
|
cfgbuffer = NULL;
|
||||||
close(fh);
|
close(fh);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -20567,6 +20573,7 @@ void create_password(char *logbook, char *name, char *pwd)
|
|||||||
/* write remainder of file */
|
/* write remainder of file */
|
||||||
write(fh, p, strlen(p));
|
write(fh, p, strlen(p));
|
||||||
xfree(cfgbuffer);
|
xfree(cfgbuffer);
|
||||||
|
cfgbuffer = NULL;
|
||||||
close(fh);
|
close(fh);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -20579,6 +20586,7 @@ void create_password(char *logbook, char *name, char *pwd)
|
|||||||
}
|
}
|
||||||
|
|
||||||
xfree(cfgbuffer);
|
xfree(cfgbuffer);
|
||||||
|
cfgbuffer = NULL;
|
||||||
close(fh);
|
close(fh);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -21224,7 +21232,22 @@ int main(int argc, char *argv[])
|
|||||||
if (getcfg("global", "Max content length", str, sizeof(str)))
|
if (getcfg("global", "Max content length", str, sizeof(str)))
|
||||||
_max_content_length = atoi(str);
|
_max_content_length = atoi(str);
|
||||||
|
|
||||||
|
#ifdef OS_WINNT
|
||||||
|
/* if running as a service, server_loop gets called from the service main routine */
|
||||||
|
if (running_as_daemon) {
|
||||||
|
redirect_to_syslog();
|
||||||
|
|
||||||
|
if (!run_service()) {
|
||||||
|
eprintf("Couldn't run the service; aborting\n");
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
} else
|
||||||
|
server_loop();
|
||||||
|
#else
|
||||||
|
|
||||||
server_loop();
|
server_loop();
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
exit(EXIT_SUCCESS);
|
exit(EXIT_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user