void main_loop() { int retval; int node=0,n; while (node<n1) { check_stop_daemons(); retval = count_unsent_results(n, 0); if (retval) { log_messages.printf(MSG_CRITICAL, "count_unsent_jobs() failed: %s\n", boincerror(retval) ); exit(retval); } if (n > CUSHION) { daemon_sleep(5); } else { // int njobs = (CUSHION-n)/REPLICATION_FACTOR; log_messages.printf(MSG_DEBUG, "Making job for %d\n", node ); // for (int i=0; i<njobs; i++) { for (int i=0; i<n1; i+=CLIENT_LIMIT) { retval = make_job(node,i); if (retval) { log_messages.printf(MSG_CRITICAL, "can't make job: %s\n", boincerror(retval) ); exit(retval); } } // } // Now sleep for a few seconds to let the transitioner // create instances for the jobs we just created. // Otherwise we could end up creating an excess of jobs. double now = dtime(); while (1) { daemon_sleep(5); double x; retval = min_transition_time(x); if (retval) { log_messages.printf(MSG_CRITICAL, "min_transition_time failed: %s\n", boincerror(retval) ); exit(retval); } if (x > now) break; } } node++; } }
void main_loop() { int retval; while (1) { check_stop_daemons(); long n; retval = count_unsent_results(n, app.id); if (retval) { log_messages.printf(MSG_CRITICAL, "count_unsent_jobs() failed: %s\n", boincerror(retval) ); exit(retval); } if (n > CUSHION) { daemon_sleep(10); } else { int njobs = (CUSHION-n)/REPLICATION_FACTOR; log_messages.printf(MSG_DEBUG, "Making %d jobs\n", njobs ); for (int i=0; i<njobs; i++) { retval = make_job(); if (retval) { log_messages.printf(MSG_CRITICAL, "can't make job: %s\n", boincerror(retval) ); exit(retval); } } // Wait for the transitioner to create instances // of the jobs we just created. // Otherwise we'll create too many jobs. // double now = dtime(); while (1) { daemon_sleep(5); double x; retval = min_transition_time(x); if (retval) { log_messages.printf(MSG_CRITICAL, "min_transition_time failed: %s\n", boincerror(retval) ); exit(retval); } if (x > now) break; } } } }