- Timestamp:
- May 3, 2010, 8:50:52 AM (16 years ago)
- Location:
- branches/simtest_nebulous_branches
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/simtest_nebulous_branches
- Property svn:mergeinfo changed
-
branches/simtest_nebulous_branches/Ohana
-
Property svn:mergeinfo
set to (toggle deleted branches)
/trunk/Ohana merged eligible /branches/eam_branches/Ohana.20100407 27635-27772 /branches/pap_delete/Ohana 27530-27595
-
Property svn:mergeinfo
set to (toggle deleted branches)
-
branches/simtest_nebulous_branches/Ohana/src/opihi/pcontrol/CheckIdleHost.c
r23330 r27840 1 1 # include "pcontrol.h" 2 2 3 // The connection to the remote host is only allowed to live for MAX_CONNECT_TIME seconds. 4 // We disconnect and reconnect if a remote host has been connected for too long. This is 5 // a (temporary?) work-around for the problem that the remote pclient job tends to grow 6 // too large over time. 7 8 static float MAX_WANTHOST_WAIT = 10.0; 9 static float MAX_CONNECT_TIME = 36000.0; 3 10 static FILE *logfile = NULL; 11 12 /* if this host has been connected for too long, disconnect (will automatically reconnect) */ 13 int CheckResetHost (Host *host) { 14 15 struct timeval now; 16 float dtime; 17 18 /* if this host has been connected for too long, disconnect (will automatically reconnect) */ 19 gettimeofday (&now, (void *) NULL); 20 dtime = DTIME (now, host[0].connect_time); 21 if (dtime > MAX_CONNECT_TIME) { 22 if (VerboseMode()) gprint (GP_ERR, "disconnect from %s\n", host[0].hostname); 23 StopHost (host, PCONTROL_HOST_DOWN); 24 return (TRUE); 25 } 26 return FALSE; 27 } 4 28 5 29 /* the supplied host is not on a stack: it cannot be taken by the other thread */ … … 21 45 if (host[0].markoff) { 22 46 host[0].markoff = FALSE; 23 StopHost (host );47 StopHost (host, PCONTROL_HOST_OFF); 24 48 return (TRUE); 25 49 } 26 50 51 /* check if host has been connected for too long */ 52 if (CheckResetHost (host)) { 53 return (TRUE); 54 } 55 27 56 /* search the JOB_PENDING stack for an appropriate job */ 28 57 stack = GetJobStack (PCONTROL_JOB_PENDING); … … 41 70 42 71 // if (logfile) fprintf (logfile, "start needhost %s (job host %s) : %s\n", host[0].hostname, job[0].hostname, job[0].argv[0]); 72 AddMachineJob (host, job); 43 73 44 74 /* take the job off the stack and unlock the stack */ … … 61 91 62 92 // if (logfile) fprintf (logfile, "start wanthost %s (job host %s) : %s\n", host[0].hostname, job[0].hostname, job[0].argv[0]); 93 AddMachineJob (host, job); 63 94 64 95 /* take the job off the stack and unlock the stack */ … … 74 105 if (job[0].mode != PCONTROL_JOB_ANYHOST) continue; 75 106 107 if (!CheckMachineJobs (host, job)) continue; 108 76 109 /* we have found an appropriate job; link it to the host and send to StartJob */ 77 110 job[0].host = (struct Host *) host; … … 79 112 80 113 // if (logfile) fprintf (logfile, "start anyhost %s (job host %s) : %s\n", host[0].hostname, job[0].hostname, job[0].argv[0]); 114 AddMachineJob (host, job); 81 115 82 116 /* take the job off the stack and unlock the stack */ … … 95 129 gettimeofday (&now, (void *) NULL); 96 130 dtime = DTIME (now, job[0].start); 97 if (dtime < 10.0) continue; 131 if (dtime < MAX_WANTHOST_WAIT) continue; 132 133 if (!CheckMachineJobs (host, job)) continue; 98 134 99 135 if (logfile) fprintf (logfile, "start wanthost(2) %s (job host %s) : %s\n", host[0].hostname, job[0].hostname, job[0].argv[0]); 136 AddMachineJob (host, job); 100 137 101 138 /* we have found an appropriate job; link it to the host and send to StartJob */ … … 116 153 } 117 154 155 void SetMaxWantHostWait (float value) { 156 157 MAX_WANTHOST_WAIT = value; 158 return; 159 } 160 161 float GetMaxWantHostWait (void) { 162 163 return MAX_WANTHOST_WAIT; 164 } 165 166 void SetMaxConnectTime (float value) { 167 168 MAX_CONNECT_TIME = value; 169 return; 170 } 171 172 float GetMaxConnectTime (void) { 173 174 return MAX_CONNECT_TIME; 175 } 176 118 177 /** note : host and job popped off IDLE and PENDING stacks, 119 178 unless no job is available **/
Note:
See TracChangeset
for help on using the changeset viewer.
