@@ -340,19 +340,23 @@ int run_job(SessionJob_t * job)
340340 }
341341
342342#if defined (__RUN_CHAIN_JOBS__ )
343- if (chainJobId ) {
344- log_info ("%s::%s(%d) : Completed job indicates that job %s should be run immediately" , LOG_INF , chainJobId );
345- chainJob = get_job_by_id (& JobList , chainJobId );
346- if (chainJob ) {
347- (void )run_job (chainJob );
348- } else {
349- log_info ("%s::%s(%d) : Job %s could not be found in the scheduled jobs list, and will not be run" , LOG_INF , chainJobId );
343+ if (0 == status ) {
344+ if (chainJobId ) {
345+ log_info ("%s::%s(%d) : Completed job indicates that job %s should be run immediately" , LOG_INF , chainJobId );
346+ chainJob = get_job_by_id (& JobList , chainJobId );
347+ if (chainJob ) {
348+ (void )run_job (chainJob );
349+ } else {
350+ log_info ("%s::%s(%d) : Job %s could not be found in the scheduled jobs list, and will not be run" , LOG_INF , chainJobId );
351+ }
350352 }
351353 }
352354#endif
355+
353356 if (chainJobId ) {
354357 free (chainJobId );
355358 }
359+
356360 return status ;
357361} /* run_job */
358362
@@ -480,14 +484,15 @@ bool release_platform(void)
480484} /* release_platform */
481485
482486/* */
483- /* Runs a single loop agent */
484- /* @param - none */
485- /* @return - none */
487+ /* Main program loop. Establishes a session with the platform, retrieves the */
488+ /* job list, and executes all scheduled jobs in priority order. */
489+ /* */
490+ /* @return true if all jobs executed successfully, false otherwise */
486491/* */
487492static bool main_loop (void )
488493{
489494 time_t now = 0 ;
490- bool error_status = false ;
495+ bool success = true ;
491496 /* First establish a session with the platform; the session registration */
492497 /* gets all of the jobs from the platform. (Unless EnrollOnStartup is */
493498 /*true in the config file.If EnrollOnStartup is true, the agent */
@@ -504,7 +509,7 @@ static bool main_loop(void)
504509 //Run the jobs based on the time queue
505510 now = time (NULL );
506511 if (0 != run_job (currentJob -> Job )) {
507- error_status = true ;
512+ success = false ;
508513 }
509514 log_info ("%s::%s(%d) : Advancing to job number %s" , LOG_INF ,
510515 NULL == currentJob -> NextJob ? "NULL" : currentJob -> NextJob -> Job -> JobId );
@@ -513,7 +518,7 @@ static bool main_loop(void)
513518
514519 log_info ("%s::%s(%d) : No jobs to run -- Begin Agent Shutdown & Memory Release" , LOG_INF );
515520
516- return error_status ;
521+ return success ;
517522} /* main_loop */
518523
519524/* */
0 commit comments