Changeset 8546
- Timestamp:
- Aug 23, 2006, 5:31:09 PM (20 years ago)
- Location:
- trunk/Ohana/src/opihi/pcontrol
- Files:
-
- 8 edited
-
CheckPoint.c (modified) (1 diff)
-
CheckSystem.c (modified) (10 diffs)
-
Makefile (modified) (1 diff)
-
PclientCommand.c (modified) (2 diffs)
-
StartHost.c (modified) (1 diff)
-
StopHosts.c (modified) (4 diffs)
-
pcontrol.c (modified) (2 diffs)
-
rconnect.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Ohana/src/opihi/pcontrol/CheckPoint.c
r8424 r8546 30 30 } 31 31 pthread_mutex_unlock (&client); 32 usleep (10000); 32 usleep (10000); // wait for client thread to set lock 33 33 } 34 34 // put in a timeout? (client thread not spinning...) -
trunk/Ohana/src/opihi/pcontrol/CheckSystem.c
r8424 r8546 55 55 void *CheckSystem_Threaded (void *data) { 56 56 57 struct timeval now; 58 float dtime; 57 int Njobchecks, Nhostchecks, Nlivechecks; 58 59 Nlivechecks = 0; 59 60 60 61 gprintInit (); … … 66 67 // don't run the system checks if RunSystem is FALSE 67 68 if (!RunSystem) { 68 usleep (50000); 69 usleep (50000); // idle if RunSystem is FALSE 69 70 continue; 70 71 } 71 72 73 Njobchecks = 0; 74 Nhostchecks = 0; 75 72 76 // we want to give each block a maximum allowed time 73 CheckIdleHosts(0.020); /* submit a new job */74 75 CheckBusyJobs(0.020); /* get job status */76 CheckDoneJobs(0.020); /* harvest job stdout/stderr */77 CheckKillJobs(0.020); /* harvest job stdout/stderr */78 79 CheckDoneHosts(0.020); /* reset the host */80 CheckDownHosts(0.100); /* launch the host */77 Nhostchecks += CheckIdleHosts(0.020); /* submit a new job */ 78 79 Njobchecks += CheckBusyJobs(0.020); /* get job status */ 80 Njobchecks += CheckDoneJobs(0.020); /* harvest job stdout/stderr */ 81 Njobchecks += CheckKillJobs(0.020); /* harvest job stdout/stderr */ 82 83 Nhostchecks += CheckDoneHosts(0.020); /* reset the host */ 84 Nhostchecks += CheckDownHosts(0.100); /* launch the host */ 81 85 82 86 /* always allow at least one test */ … … 84 88 CheckDoneJobs must depend on the size of the output buffer */ 85 89 86 gettimeofday (&now, (void *) NULL); 87 dtime = DTIME (now, lastlive); 88 if (dtime > 1.0) { 90 // there is nothing on the stacks. test the hosts and wait a bit 91 if (!Njobchecks && !Nhostchecks) { 89 92 CheckLiveHosts(0.040); 90 lastlive = now;93 usleep (100000); // idle if no jobs are waiting 91 94 } 92 95 … … 145 148 } 146 149 if (DEBUG && (Nobject > 0)) gprint (GP_ERR, "checked %d of %d jobs\n", i, Nobject); 147 return ( TRUE);150 return (i); 148 151 } 149 152 … … 182 185 } 183 186 if (DEBUG && (Nobject > 0)) gprint (GP_ERR, "checked %d of %d jobs\n", i, Nobject); 184 return ( TRUE);187 return (i); 185 188 } 186 189 … … 219 222 } 220 223 if (DEBUG && (Nobject > 0)) gprint (GP_ERR, "checked %d of %d jobs\n", i, Nobject); 221 return ( TRUE);224 return (i); 222 225 } 223 226 … … 245 248 } 246 249 if (DEBUG) gprint (GP_ERR, "checked %d hosts\n", i); 247 return ( TRUE);250 return (i); 248 251 } 249 252 … … 281 284 } 282 285 if (DEBUG) gprint (GP_ERR, "checked %d hosts\n", i); 283 return ( TRUE);286 return (i); 284 287 } 285 288 … … 294 297 /* check if there are any pending jobs, otherwise skip step */ 295 298 stack = GetJobStack (PCONTROL_JOB_PENDING); 296 if (!stack[0].Nobject) return ( TRUE);299 if (!stack[0].Nobject) return (0); 297 300 298 301 /* Loop through objects on the stack, no more than once. see note above */ … … 311 314 } 312 315 if (DEBUG) gprint (GP_ERR, "checked %d hosts\n", i); 313 return ( TRUE);316 return (i); 314 317 } 315 318 -
trunk/Ohana/src/opihi/pcontrol/Makefile
r8424 r8546 23 23 LFLAGS = $(LIBS) $(LIBS2) $(LIBS1) 24 24 25 # mana user commands and support functions ######################## 25 # to build the non-threaded version, remove -lpthread and comment out 26 # the THREADED line in include/pcontrol.h 27 28 # pcontrol user commands and support functions ######################## 26 29 27 30 funcs = \ -
trunk/Ohana/src/opihi/pcontrol/PclientCommand.c
r8424 r8546 20 20 21 21 /* is pipe still open? */ 22 if ((status == -1) && (errno == EPIPE)) return (PCLIENT_DOWN); 22 if ((status == -1) && (errno == EPIPE)) { 23 // gprint (GP_ERR, "pclient read gives pipe error for %s\n", command); 24 return (PCLIENT_DOWN); 25 } 23 26 24 27 /* watch for response - wait up to 1 second */ … … 30 33 if (status == -1) nanosleep (&request, &remain); 31 34 } 32 if (status == 0) return (PCLIENT_DOWN); 35 if (status == 0) { 36 // gprint (GP_ERR, "pclient read returns 0 for %s\n", command); 37 return (PCLIENT_DOWN); 38 } 33 39 if (status == -1) return (PCLIENT_HUNG); 34 40 /* gprint (GP_ERR, "buffer.buffer: %s\n", buffer[0].buffer); */ -
trunk/Ohana/src/opihi/pcontrol/StartHost.c
r8424 r8546 14 14 if (VarConfig ("SHELL", "%s", shell) == NULL) strcpy (shell, "pclient"); 15 15 16 gprint (GP_ERR, "starting host within thread %d\n", pthread_self());16 if (VerboseMode()) gprint (GP_ERR, "starting host within thread %d\n", pthread_self()); 17 17 18 18 pid = rconnect (command, host[0].hostname, shell, stdio); -
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 } -
trunk/Ohana/src/opihi/pcontrol/pcontrol.c
r8424 r8546 25 25 InitHostStacks (); 26 26 27 /* set global signal masks (these apply to all threads launched below) */ 28 signal (SIGPIPE, gotsignal); 29 signal (SIGTSTP, gotsignal); 30 signal (SIGTTIN, gotsignal); 31 27 32 rl_readline_name = opihi_name; 28 33 rl_attempted_completion_function = command_completer; 29 34 # ifdef THREADED 35 SetRunSystem (TRUE); 30 36 pthread_create (&clientsThread, NULL, &CheckSystem_Threaded, NULL); 31 37 rl_event_hook = NULL; … … 45 51 46 52 /* ignore the history file. to change this, see, eg, mana.c */ 47 signal (SIGPIPE, gotsignal);48 signal (SIGTSTP, gotsignal);49 signal (SIGTTIN, gotsignal);50 53 return; 51 54 } -
trunk/Ohana/src/opihi/pcontrol/rconnect.c
r7917 r8546 81 81 status = ReadtoIOBuffer (&buffer, stdout_fd[0]); 82 82 p = memstr (buffer.buffer, "CONNECTED", buffer.Nbuffer); 83 usleep (10000); 83 usleep (10000); // wait for client to be connected 84 84 } 85 85 if (status == 0) goto connect_error;
Note:
See TracChangeset
for help on using the changeset viewer.
