Changeset 8546 for trunk/Ohana/src/opihi/pcontrol/StopHosts.c
- Timestamp:
- Aug 23, 2006, 5:31:09 PM (20 years ago)
- File:
-
- 1 edited
-
trunk/Ohana/src/opihi/pcontrol/StopHosts.c (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Ohana/src/opihi/pcontrol/StopHosts.c
r8424 r8546 17 17 } 18 18 19 /* for use by shutdown: force machines which are up to go down 20 wait for a little while for the client thread to take care 21 of them 22 */ 23 19 24 int DownHosts () { 20 25 26 int i, Nobject, Nwait; 21 27 Stack *stack; 22 28 Host *host; 23 29 30 SetCheckPoint (); // ensure we can find the specified host 24 31 stack = GetHostStack (PCONTROL_HOST_IDLE); 25 while ((host = PullStackByLocation (stack, STACK_BOTTOM)) != NULL) { 26 StopHost (host); 27 DownHost (host); 32 Nobject = stack[0].Nobject; 33 for (i = 0; i < Nobject; i++) { 34 host = PullStackByLocation (stack, STACK_TOP); 35 if (host == NULL) continue; 36 host[0].markoff = TRUE; 37 PutHost (host, PCONTROL_HOST_IDLE, STACK_BOTTOM); 28 38 } 29 39 30 40 stack = GetHostStack (PCONTROL_HOST_BUSY); 31 while ((host = PullStackByLocation (stack, STACK_BOTTOM)) != NULL) { 32 StopHost (host); 33 DownHost (host); 41 Nobject = stack[0].Nobject; 42 for (i = 0; i < Nobject; i++) { 43 host = PullStackByLocation (stack, STACK_TOP); 44 if (host == NULL) continue; 45 host[0].markoff = TRUE; 46 PutHost (host, PCONTROL_HOST_IDLE, STACK_BOTTOM); 47 } 48 ClearCheckPoint (); 49 50 Nwait = 0; 51 stack = GetHostStack (PCONTROL_HOST_IDLE); 52 gprint (GP_ERR, "waiting for clients to exit"); 53 while ((Nwait < 15) && stack[0].Nobject) { 54 gprint (GP_ERR, "."); 55 usleep (100000); // wait for clients to exit 56 Nwait++; 57 } 58 gprint (GP_ERR, "\n"); 59 if (stack[0].Nobject) { 60 gprint (GP_ERR, "trouble shutting down all pclient instances: %d still alive\n", stack[0].Nobject); 61 } else { 62 gprint (GP_ERR, "done\n"); 34 63 } 35 64 return (TRUE); … … 69 98 int i, result, waitstatus; 70 99 71 gprint (GP_ERR, "harvesting within thread %d\n", pthread_self());72 gprint (GP_ERR, "child process %d is down, wait for exit status\n", pid);100 // gprint (GP_ERR, "harvesting within thread %d\n", pthread_self()); 101 // gprint (GP_ERR, "child process %d is down, wait for exit status\n", pid); 73 102 74 103 // Loop a few times waiting for child to exit … … 76 105 result = waitpid (pid, &waitstatus, WNOHANG); 77 106 if ((result == -1) && (errno == ECHILD)) { 78 usleep (10000); 107 usleep (10000); // wait for child to exit 79 108 continue; 80 109 } else { … … 109 138 110 139 if (WIFEXITED(waitstatus)) { 111 gprint (GP_ERR, "child exited with status %d\n", WEXITSTATUS(waitstatus));140 if (VerboseMode()) gprint (GP_ERR, "child exited with status %d\n", WEXITSTATUS(waitstatus)); 112 141 } 113 142 if (WIFSIGNALED(waitstatus)) { 114 gprint (GP_ERR, "child crashed with status %d\n", WTERMSIG(waitstatus));143 if (VerboseMode()) gprint (GP_ERR, "child crashed with status %d\n", WTERMSIG(waitstatus)); 115 144 } 116 145 if (WIFSTOPPED(waitstatus)) { 117 gprint (GP_ERR, "waitpid returns 'stopped': programming error\n");146 if (VerboseMode()) gprint (GP_ERR, "waitpid returns 'stopped': programming error\n"); 118 147 exit (1); 119 148 }
Note:
See TracChangeset
for help on using the changeset viewer.
