handling replies continuously from server
[oweals/gnunet.git] / src / util / os_priority.c
index 0b56ce5c520e2929be58e0f014c7ff592a1f6add..9def6ca54d899cd0b59920a2afc54090f6ec9b10 100644 (file)
@@ -330,11 +330,11 @@ parent_control_handler (void *cls,
   
   LOG (GNUNET_ERROR_TYPE_DEBUG, "`%s' invoked because of %d\n", __FUNCTION__,
        tc->reason);
-  if (tc->reason &
-      (GNUNET_SCHEDULER_REASON_SHUTDOWN | GNUNET_SCHEDULER_REASON_TIMEOUT |
-       GNUNET_SCHEDULER_REASON_PREREQ_DONE))
+  if (0 != (tc->reason &
+           (GNUNET_SCHEDULER_REASON_SHUTDOWN | GNUNET_SCHEDULER_REASON_TIMEOUT)))
   {
     GNUNET_DISK_file_close (control_pipe);
+    control_pipe = NULL;
     return;
   }
   ret = GNUNET_DISK_file_read (control_pipe, &sig, sizeof (sig));
@@ -343,6 +343,7 @@ parent_control_handler (void *cls,
     if (-1 == ret)
       LOG_STRERROR (GNUNET_ERROR_TYPE_ERROR, "GNUNET_DISK_file_read");
     GNUNET_DISK_file_close (control_pipe);
+    control_pipe = NULL;
     return;
   }
   LOG (GNUNET_ERROR_TYPE_DEBUG, "Got control code %d from parent\n", sig);
@@ -485,8 +486,13 @@ GNUNET_OS_process_get_pid (struct GNUNET_OS_Process * proc)
 }
 
 
+/**
+ * Cleans up process structure contents (OS-dependent) and deallocates it
+ *
+ * @param proc pointer to process structure
+ */
 void
-GNUNET_OS_process_close (struct GNUNET_OS_Process *proc)
+GNUNET_OS_process_destroy (struct GNUNET_OS_Process *proc)
 {
   if (NULL != proc->control_pipe)
     GNUNET_DISK_file_close (proc->control_pipe);
@@ -643,10 +649,15 @@ GNUNET_OS_set_process_priority (struct GNUNET_OS_Process *proc,
 static char *
 CreateCustomEnvTable (char **vars)
 {
-  char *win32_env_table, *ptr, **var_ptr, *result, *result_ptr;
+  char *win32_env_table;
+  char *ptr;
+  char **var_ptr;
+  char *result;
+  char *result_ptr;
   size_t tablesize = 0;
   size_t items_count = 0;
-  size_t n_found = 0, n_var;
+  size_t n_found = 0;
+  size_t n_var;
   char *index = NULL;
   size_t c;
   size_t var_len;
@@ -1498,7 +1509,9 @@ GNUNET_OS_start_process_v (int pipe_control,
 
 
 /**
- * Retrieve the status of a process
+ * Retrieve the status of a process, waiting on him if dead.
+ * Nonblocking version.
+ * 
  * @param proc process ID
  * @param type status type
  * @param code return code/signal number
@@ -1715,7 +1728,7 @@ GNUNET_OS_command_stop (struct GNUNET_OS_CommandHandle *cmd)
   }
   (void) GNUNET_OS_process_kill (cmd->eip, SIGKILL);
   GNUNET_break (GNUNET_OK == GNUNET_OS_process_wait (cmd->eip));
-  GNUNET_OS_process_close (cmd->eip);
+  GNUNET_OS_process_destroy (cmd->eip);
   GNUNET_DISK_pipe_close (cmd->opipe);
   GNUNET_free (cmd);
 }