~ubuntu-branches/ubuntu/precise/torque/precise-updates

« back to all changes in this revision

Viewing changes to src/resmom/freebsd5/mom_start.c

  • Committer: Bazaar Package Importer
  • Author(s): Dominique Belhachemi
  • Date: 2010-05-17 20:56:46 UTC
  • mto: This revision was merged to the branch mainline in revision 8.
  • Revision ID: james.westby@ubuntu.com-20100517205646-yjsoqs5r1s9xpnu9
Tags: upstream-2.4.8+dfsg
ImportĀ upstreamĀ versionĀ 2.4.8+dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
95
95
#include "server_limits.h"
96
96
#include "attribute.h"
97
97
#include "resource.h"
98
 
#include "job.h"
 
98
#include "pbs_job.h"
99
99
#include "mom_mach.h"
100
100
#include "mom_func.h"
101
101
 
113
113
extern int       LOGLEVEL;
114
114
 
115
115
/* Private variables */
 
116
#define TMAX_TJCACHESIZE 128
 
117
job *TJCache[TMAX_TJCACHESIZE];
116
118
 
117
119
/*
118
120
 * set_job - set up a new job session
124
126
 *  -2 - if other, message in log_buffer
125
127
 */
126
128
 
127
 
int set_job(pjob, sjr)
128
 
job *pjob;
129
 
 
130
 
struct startjob_rtn *sjr;
 
129
int
 
130
set_job(job *pjob, struct startjob_rtn *sjr)
131
131
  {
132
132
  return (sjr->sj_session = setsid());
133
133
  }
136
136
** set_globid - set the global id for a machine type.
137
137
*/
138
138
void
139
 
set_globid(pjob, sjr)
140
 
job *pjob;
141
 
 
142
 
struct startjob_rtn *sjr;
 
139
set_globid(job *pjob, struct startjob_rtn *sjr)
143
140
  {
144
141
  extern char noglobid[];
145
142
 
151
148
 * set_mach_vars - setup machine dependent environment variables
152
149
 */
153
150
int
154
 
set_mach_vars(pjob, vtab)
155
 
job      *pjob;    /* pointer to the job */
156
 
 
157
 
struct var_table *vtab;    /* pointer to variable table */
 
151
set_mach_vars(
 
152
  job *pjob,    /* pointer to the job */
 
153
  struct var_table *vtab    /* pointer to variable table */
 
154
)
158
155
  {
159
156
  return 0;
160
157
  }
161
158
 
162
 
char *set_shell(pjob, pwdp)
163
 
job       *pjob;
164
 
 
165
 
struct passwd *pwdp;
 
159
char *
 
160
set_shell(job *pjob, struct passwd *pwdp)
166
161
  {
167
162
  char *cp;
168
163
  int   i;
207
202
 * task as Exiting.
208
203
 */
209
204
 
210
 
#define TMAX_TJCACHESIZE 128
211
 
 
212
205
void
213
206
scan_for_terminated(void)
214
207
  {
219
212
  task  *ptask = 0;
220
213
  int  statloc;
221
214
 
222
 
 
223
 
#ifdef CACHEOBITFAILURES
224
 
  static job *TJCache[TMAX_TJCACHESIZE];
225
 
 
226
 
  int tjcindex;
227
 
 
228
 
  int TJCIndex = 0;
229
 
#endif
230
 
 
231
215
  if (LOGLEVEL >= 7)
232
216
    {
233
217
    log_record(
253
237
      }
254
238
    }
255
239
 
256
 
#ifdef CACHEOBITFAILURES
257
 
  /* process cached obit failures */
258
 
 
259
 
  for (TJCIndex = 0;TJCIndex < TMAX_TJCACHESIZE;TJCIndex++)
260
 
    {
261
 
    if (TJCache[TJCIndex] == NULL)
262
 
      break;
263
 
 
264
 
    if (TJCache[TJCIndex] == (job *)1)
265
 
      continue;
266
 
 
267
 
    /* attempt to send obit again */
268
 
 
269
 
    pjob = TJCache[TJCIndex];
270
 
 
271
 
    if (LOGLEVEL >= 7)
272
 
      {
273
 
      LOG_EVENT(
274
 
        PBSEVENT_DEBUG,
275
 
        PBS_EVENTCLASS_JOB,
276
 
        pjob->ji_qs.ji_jobid,
277
 
        "Retrying send of OBIT");
278
 
      }
279
 
 
280
 
    if (pjob->ji_mompost(pjob, exiteval) != 0)
281
 
      {
282
 
      /* attempt failed again */
283
 
 
284
 
      termin_child = 1;
285
 
 
286
 
      continue;
287
 
      }
288
 
 
289
 
    /* success */
290
 
    if (LOGLEVEL >= 7)
291
 
      {
292
 
      LOG_EVENT(
293
 
        PBSEVENT_DEBUG,
294
 
        PBS_EVENTCLASS_JOB,
295
 
        pjob->ji_qs.ji_jobid,
296
 
        "OBIT resent successfully");
297
 
      }
298
 
 
299
 
    pjob->ji_mompost = NULL;
300
 
 
301
 
    /* clear mom sub-task */
302
 
 
303
 
    pjob->ji_momsubt = 0;
304
 
 
305
 
    job_save(pjob, SAVEJOB_QUICK);
306
 
    TJCache[TJCIndex] = ((job *)1);
307
 
 
308
 
    }  /* END for (TJIndex) */
309
 
 
310
 
#endif /* CACHEOBITFAILURES */
311
 
 
312
240
  /* Now figure out which task(s) have terminated (are zombies) */
313
241
 
314
242
  while ((pid = waitpid(-1, &statloc, WNOHANG)) > 0)
402
330
          pjob->ji_mompost = 0;
403
331
          }
404
332
 
405
 
#ifdef CACHEOBITFAILURES
406
 
        else
407
 
          {
408
 
          for (tjcindex = 0;tjcindex < TMAX_TJCACHESIZE;tjcindex++)
409
 
            {
410
 
            if ((TJCache[tjcindex] == NULL) || (TJCache[tjcindex] == (job *)1))
411
 
              {
412
 
              if (LOGLEVEL >= 7)
413
 
                {
414
 
                LOG_EVENT(
415
 
                  PBSEVENT_DEBUG,
416
 
                  PBS_EVENTCLASS_JOB,
417
 
                  pjob->ji_qs.ji_jobid,
418
 
                  "Caching OBIT for resend");
419
 
                }
420
 
 
421
 
              TJCache[tjcindex] = pjob;
422
 
 
423
 
              termin_child = 1;
424
 
 
425
 
              break;
426
 
              }
427
 
            }    /* END for (tjcindex) */
428
 
 
429
 
          continue;
430
 
          }
431
 
 
432
 
#endif /* CACHEOBITFAILURES */
433
333
        }
434
334
      else
435
335
        {
489
389
  return;
490
390
  }  /* END scan_for_terminated() */
491
391
 
 
392
 
 
393
 
 
394
 
492
395
/*
493
396
 * creat the master pty, this particular
494
397
 * piece of code does it the hard way, it searches