*
*/
/*
- Copyright (C) 2000, 2001, 2002 Kern Sibbald and John Walker
+ Copyright (C) 2000-2004 Kern Sibbald and John Walker
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
char TERM_msg[] = "2999 Terminate\n";
-#ifdef HAVE_CYGWIN
-int win32_client = 1;
+#if defined(HAVE_CYGWIN) || defined(HAVE_WIN32)
+const int win32_client = 1;
#else
-int win32_client = 0;
+const int win32_client = 0;
#endif
* Main Bacula Unix Client Program
*
*/
-#ifdef HAVE_CYGWIN
+#if defined(HAVE_CYGWIN) || defined(HAVE_WIN32)
#define main BaculaMain
#endif
+
int main (int argc, char *argv[])
{
int ch;
init_msg(NULL, NULL);
daemon_start_time = time(NULL);
- memset(&last_job, 0, sizeof(last_job));
-
while ((ch = getopt(argc, argv, "c:d:fg:istu:v?")) != -1) {
switch (ch) {
case 'c': /* configuration file */
init_stack_dump(); /* set new pid */
}
- drop(uid, gid);
-
/* Maximum 1 daemon at a time */
create_pid_file(me->pid_directory, "bacula-fd", me->FDport);
+ read_state_file(me->working_directory, "bacula-fd", me->FDport);
+
+ drop(uid, gid);
#ifdef BOMB
me += 1000000;
start_watchdog(); /* start watchdog thread */
+ init_jcr_subsystem(); /* start JCR watchdogs etc. */
+
if (inetd_request) {
/* Socket is on fd 0 */
- BSOCK *bs = init_bsock(NULL, 0, "client", "unknown client", me->FDport);
+ struct sockaddr_in client_addr;
+ memset(&client_addr, 0, sizeof(client_addr));
+ BSOCK *bs = init_bsock(NULL, 0, "client", "unknown client", me->FDport,
+ &client_addr);
handle_client_request((void *)bs);
} else {
/* Become server, and handle requests */
&dir_workq, handle_client_request);
}
- term_msg();
+ terminate_filed(0);
exit(0); /* should never get here */
}
void terminate_filed(int sig)
{
- stop_watchdog();
-
if (configfile != NULL) {
free(configfile);
}
if (debug_level > 5) {
print_memory_pool_stats();
}
+ write_state_file(me->working_directory, "bacula-fd", me->FDport);
delete_pid_file(me->pid_directory, "bacula-fd", me->FDport);
free_config_resources();
term_msg();
+ stop_watchdog();
close_memory_pool(); /* release free memory in pool */
sm_dump(False); /* dump orphaned buffers */
exit(1);