r253: Revert r231; it's causing more problems than it attempts to solve
[nbd.git] / nbd-server.c
index 3e6801a..fd04489 100644 (file)
@@ -638,7 +638,7 @@ void sigchld_handler(int s) {
        pid_t pid;
 
        while((pid=waitpid(-1, &status, WNOHANG)) > 0) {
-               if(WIFEXITED(&status)) {
+               if(WIFEXITED(status)) {
                        msg3(LOG_INFO, "Child exited with %d", WEXITSTATUS(status));
                }
                i=g_hash_table_lookup(children, &pid);
@@ -693,16 +693,16 @@ void sigterm_handler(int s) {
  **/
 off_t size_autodetect(int fhandle) {
        off_t es;
-       u32 es32;
+       unsigned long sectors;
        struct stat stat_buf;
        int error;
 
 #ifdef HAVE_SYS_MOUNT_H
 #ifdef HAVE_SYS_IOCTL_H
 #ifdef BLKGETSIZE
-       DEBUG("looking for fhandle size with ioctl BLKGETSIZE\n");
-       if (!ioctl(fhandle, BLKGETSIZE, &es32) && es32) {
-               es = (off_t)es32 * (off_t)512;
+       DEBUG("looking for export size with ioctl BLKGETSIZE\n");
+       if (!ioctl(fhandle, BLKGETSIZE, &sectors) && sectors) {
+               es = (off_t)sectors * (off_t)512;
                return es;
        }
 #endif /* BLKGETSIZE */
@@ -1359,7 +1359,6 @@ void setup_serve(SERVER *serve) {
        sa.sa_flags = SA_RESTART;
        if(sigaction(SIGTERM, &sa, NULL) == -1)
                err("sigaction: %m");
-       children=g_hash_table_new_full(g_int_hash, g_int_equal, NULL, destroy_pid_t);
 }
 
 /**
@@ -1371,6 +1370,7 @@ void setup_servers(GArray* servers) {
        for(i=0;i<servers->len;i++) {
                setup_serve(&(g_array_index(servers, SERVER, i)));
        }
+       children=g_hash_table_new_full(g_int_hash, g_int_equal, NULL, destroy_pid_t);
 }
 
 /**