]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/src/filed/filed.c
Fix reporting jobs from state file + misc
[bacula/bacula] / bacula / src / filed / filed.c
index 10c98fed25d56ceb6b13ba7379a1470c141bc704..bd8fd3570449776cec7b62a8a5531f82d1b37be2 100644 (file)
@@ -41,10 +41,10 @@ char OK_msg[]   = "2000 OK\n";
 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
 
 
@@ -81,9 +81,10 @@ static void usage()
  *  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;
@@ -213,6 +214,7 @@ Without that I don't know who I am :-(\n"), configfile);
 
    /* 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);
 
@@ -228,7 +230,10 @@ Without that I don't know who I am :-(\n"), configfile);
 
    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 */
@@ -237,7 +242,7 @@ Without that I don't know who I am :-(\n"), configfile);
                      &dir_workq, handle_client_request);
    }
 
-   term_msg();
+   terminate_filed(0);
    exit(0);                          /* should never get here */
 }
 
@@ -249,6 +254,7 @@ void terminate_filed(int sig)
    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();