2003-07-01 20:37:09 +00:00
|
|
|
// The contents of this file are subject to the BOINC Public License
|
2002-05-30 07:14:21 +00:00
|
|
|
// Version 1.0 (the "License"); you may not use this file except in
|
|
|
|
// compliance with the License. You may obtain a copy of the License at
|
2003-07-01 20:37:09 +00:00
|
|
|
// http://boinc.berkeley.edu/license_1.0.txt
|
2003-07-02 20:57:59 +00:00
|
|
|
//
|
2002-05-30 07:14:21 +00:00
|
|
|
// Software distributed under the License is distributed on an "AS IS"
|
|
|
|
// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
|
|
|
|
// License for the specific language governing rights and limitations
|
2003-07-02 20:57:59 +00:00
|
|
|
// under the License.
|
|
|
|
//
|
|
|
|
// The Original Code is the Berkeley Open Infrastructure for Network Computing.
|
|
|
|
//
|
2002-05-30 07:14:21 +00:00
|
|
|
// The Initial Developer of the Original Code is the SETI@home project.
|
2003-07-01 20:37:09 +00:00
|
|
|
// Portions created by the SETI@home project are Copyright (C) 2002
|
2003-07-02 20:57:59 +00:00
|
|
|
// University of California at Berkeley. All Rights Reserved.
|
|
|
|
//
|
2002-05-30 07:14:21 +00:00
|
|
|
// Contributor(s):
|
|
|
|
//
|
|
|
|
|
2003-09-21 22:33:43 +00:00
|
|
|
// -------------------------------
|
|
|
|
//
|
2003-09-01 17:11:14 +00:00
|
|
|
// feeder [-asynch] [-d debug_level]
|
2003-09-21 22:33:43 +00:00
|
|
|
// -asynch fork and run in a separate process
|
2002-05-30 07:14:21 +00:00
|
|
|
//
|
|
|
|
// Creates a shared memory segment containing DB info,
|
2003-09-21 22:33:43 +00:00
|
|
|
// including the work array (results/workunits to send).
|
2002-05-30 07:14:21 +00:00
|
|
|
// This means that the scheduler CGI program doesn't have to
|
|
|
|
// access the DB to get this info.
|
2002-06-01 20:26:21 +00:00
|
|
|
//
|
2003-09-21 22:33:43 +00:00
|
|
|
// Try to keep the work array filled.
|
|
|
|
// This is a little tricky.
|
|
|
|
// We use an enumerator.
|
|
|
|
// The inner loop scans the wu_result table,
|
|
|
|
// looking for empty slots and trying to fill them in.
|
|
|
|
// When the enumerator reaches the end, it is restarted;
|
|
|
|
// hopefully there will be some new workunits.
|
|
|
|
// There are two complications:
|
2004-01-09 00:51:47 +00:00
|
|
|
//
|
2003-09-21 22:33:43 +00:00
|
|
|
// - An enumeration may return results already in the array.
|
|
|
|
// So, for each result, we scan the entire array to make sure
|
|
|
|
// it's not there already. Can this be streamlined?
|
2004-01-09 00:51:47 +00:00
|
|
|
//
|
2003-09-21 22:33:43 +00:00
|
|
|
// - We must avoid excessive re-enumeration,
|
|
|
|
// especially when the number of results is less than the array size.
|
|
|
|
// Crude approach: if a "collision" (as above) occurred on
|
|
|
|
// a pass through the array, wait a long time (5 sec)
|
|
|
|
//
|
|
|
|
// Checking for infeasible results (i.e. can't sent to any host):
|
2004-01-09 00:51:47 +00:00
|
|
|
//
|
2003-09-21 22:33:43 +00:00
|
|
|
// - the "infeasible_count" field of WU_RESULT keeps track of
|
|
|
|
// how many times the WU_RESULT was infeasible for a host
|
2004-01-09 00:51:47 +00:00
|
|
|
//
|
2003-09-21 22:33:43 +00:00
|
|
|
// - the scheduler gives priority to results that have infeasible_count > 0
|
2004-01-09 00:51:47 +00:00
|
|
|
//
|
2003-09-21 22:33:43 +00:00
|
|
|
// - If the infeasible_count of any result exceeds MAX_INFEASIBLE_COUNT,
|
|
|
|
// the feeder flags the result as OVER with outcome COULDNT_SEND,
|
|
|
|
// and flags the WU for the transitioner.
|
2004-01-09 00:51:47 +00:00
|
|
|
//
|
2003-09-21 22:33:43 +00:00
|
|
|
// - the feeder tries to ensure that the number of WU_RESULTs
|
2004-01-09 00:51:47 +00:00
|
|
|
// with infeasible_count > MAX_INFEASIBLE_THRESHOLD
|
|
|
|
// doesn't exceed MAX_INFEASIBLE (defined in sched_shmem.h)
|
2003-09-21 22:33:43 +00:00
|
|
|
// If it does, then the feeder picks the WU_RESULT with
|
|
|
|
// the largest infeasible_count, marks if COULDNT_SEND as above,
|
|
|
|
// and repeats this until the infeasible count is low enough again
|
2002-05-30 07:14:21 +00:00
|
|
|
|
2002-12-03 18:57:40 +00:00
|
|
|
// Trigger files:
|
|
|
|
// The feeder program periodically checks for two trigger files:
|
2002-05-30 07:14:21 +00:00
|
|
|
//
|
2002-12-03 18:57:40 +00:00
|
|
|
// stop_server: destroy shmem and exit
|
|
|
|
// leave trigger file there (for other daemons)
|
|
|
|
// reread_db: update DB contents in existing shmem
|
|
|
|
// delete trigger file
|
2002-05-30 07:14:21 +00:00
|
|
|
|
2002-11-06 19:42:23 +00:00
|
|
|
// If you get an "Invalid argument" error when trying to run the feeder,
|
|
|
|
// it is likely that you aren't able to allocate enough shared memory.
|
|
|
|
// Either increase the maximum shared memory segment size in the kernel
|
|
|
|
// configuration, or decrease the MAX_PLATFORMS, MAX_APPS
|
|
|
|
// MAX_APP_VERSIONS, and MAX_WU_RESULTS in sched_shmem.h
|
|
|
|
|
2002-05-30 07:14:21 +00:00
|
|
|
#include <stdio.h>
|
2002-07-11 20:41:24 +00:00
|
|
|
#include <stdlib.h>
|
2002-09-26 23:12:13 +00:00
|
|
|
#include <string.h>
|
2003-01-07 08:11:16 +00:00
|
|
|
#include <time.h>
|
2002-05-30 08:33:30 +00:00
|
|
|
#if HAVE_UNISTD_H
|
|
|
|
#include <unistd.h>
|
|
|
|
#endif
|
2002-05-30 07:14:21 +00:00
|
|
|
|
2003-04-07 19:06:00 +00:00
|
|
|
#include "boinc_db.h"
|
2002-05-30 07:14:21 +00:00
|
|
|
#include "shmem.h"
|
2004-04-04 01:59:47 +00:00
|
|
|
#include "synch.h"
|
2003-02-10 19:51:32 +00:00
|
|
|
#include "util.h"
|
2003-08-15 00:45:25 +00:00
|
|
|
#include "sched_config.h"
|
2002-05-30 07:14:21 +00:00
|
|
|
#include "sched_shmem.h"
|
2003-03-08 00:09:40 +00:00
|
|
|
#include "sched_util.h"
|
2004-04-08 08:15:23 +00:00
|
|
|
#include "sched_msgs.h"
|
2002-05-30 07:14:21 +00:00
|
|
|
|
2002-12-03 18:57:40 +00:00
|
|
|
#define REREAD_DB_FILENAME "reread_db"
|
2003-02-10 19:51:32 +00:00
|
|
|
#define LOCKFILE "feeder.out"
|
2003-06-20 01:31:03 +00:00
|
|
|
#define PIDFILE "feeder.pid"
|
2002-05-30 07:14:21 +00:00
|
|
|
|
2004-03-24 00:16:18 +00:00
|
|
|
//#define REMOVE_INFEASIBLE_ENTRIES
|
|
|
|
|
2003-09-02 21:16:55 +00:00
|
|
|
SCHED_CONFIG config;
|
2003-06-20 01:31:03 +00:00
|
|
|
SCHED_SHMEM* ssp;
|
2004-04-04 01:59:47 +00:00
|
|
|
key_t sema_key;
|
2002-12-03 18:57:40 +00:00
|
|
|
|
2003-09-02 21:16:55 +00:00
|
|
|
void cleanup_shmem() {
|
2003-06-20 01:31:03 +00:00
|
|
|
detach_shmem((void*)ssp);
|
|
|
|
destroy_shmem(config.shmem_key);
|
|
|
|
}
|
|
|
|
|
|
|
|
int check_reread_trigger() {
|
|
|
|
FILE* f;
|
2002-12-03 18:57:40 +00:00
|
|
|
f = fopen(REREAD_DB_FILENAME, "r");
|
|
|
|
if (f) {
|
|
|
|
fclose(f);
|
2002-05-30 07:14:21 +00:00
|
|
|
ssp->init();
|
|
|
|
ssp->scan_tables();
|
2002-12-03 18:57:40 +00:00
|
|
|
unlink(REREAD_DB_FILENAME);
|
2002-05-30 07:14:21 +00:00
|
|
|
}
|
2002-11-22 20:20:58 +00:00
|
|
|
|
2002-05-30 07:14:21 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2004-03-24 00:16:18 +00:00
|
|
|
#ifdef REMOVE_INFEASIBLE_ENTRIES
|
2003-09-21 22:33:43 +00:00
|
|
|
static int remove_infeasible(int i) {
|
|
|
|
int retval;
|
|
|
|
DB_RESULT result;
|
|
|
|
DB_WORKUNIT wu;
|
|
|
|
|
|
|
|
WU_RESULT& wu_result = ssp->wu_results[i];
|
2004-04-04 01:59:47 +00:00
|
|
|
wu_result.state = WR_STATE_EMPTY;
|
2003-09-21 22:33:43 +00:00
|
|
|
result = wu_result.result;
|
|
|
|
wu = wu_result.workunit;
|
|
|
|
|
|
|
|
log_messages.printf(
|
2004-04-08 08:15:23 +00:00
|
|
|
SCHED_MSG_LOG::NORMAL,
|
2003-09-30 18:09:58 +00:00
|
|
|
"[%s] declaring result as unsendable; infeasible count %d\n",
|
|
|
|
result.name, wu_result.infeasible_count
|
2003-09-21 22:33:43 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
result.server_state = RESULT_SERVER_STATE_OVER;
|
|
|
|
result.outcome = RESULT_OUTCOME_COULDNT_SEND;
|
|
|
|
retval = result.update();
|
|
|
|
if (retval) {
|
|
|
|
log_messages.printf(
|
2004-04-08 08:15:23 +00:00
|
|
|
SCHED_MSG_LOG::CRITICAL,
|
2003-09-21 22:33:43 +00:00
|
|
|
"[%s]: can't update: %d\n",
|
|
|
|
result.name, retval
|
|
|
|
);
|
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
wu.transition_time = time(0);
|
|
|
|
retval = wu.update();
|
|
|
|
if (retval) {
|
|
|
|
log_messages.printf(
|
2004-04-08 08:15:23 +00:00
|
|
|
SCHED_MSG_LOG::CRITICAL,
|
2003-09-21 22:33:43 +00:00
|
|
|
"[%s]: can't update: %d\n",
|
|
|
|
wu.name, retval
|
|
|
|
);
|
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
2004-03-24 00:16:18 +00:00
|
|
|
#endif
|
2003-06-04 17:21:26 +00:00
|
|
|
|
2003-09-21 21:00:25 +00:00
|
|
|
static void scan_work_array(
|
|
|
|
DB_RESULT& result, char* clause,
|
|
|
|
int& nadditions, int& ncollisions, int& ninfeasible,
|
|
|
|
bool& no_wus
|
|
|
|
) {
|
|
|
|
int i, j, retval;
|
|
|
|
DB_WORKUNIT wu;
|
|
|
|
bool collision, restarted_enum = false;
|
2002-12-03 18:57:40 +00:00
|
|
|
|
2003-09-21 21:00:25 +00:00
|
|
|
for (i=0; i<ssp->nwu_results; i++) {
|
|
|
|
WU_RESULT& wu_result = ssp->wu_results[i];
|
2004-04-04 01:59:47 +00:00
|
|
|
if (wu_result.state == WR_STATE_PRESENT) {
|
2004-03-24 00:16:18 +00:00
|
|
|
#ifdef REMOVE_INFEASIBLE_ENTRIES
|
2003-09-21 22:33:43 +00:00
|
|
|
if (wu_result.infeasible_count > MAX_INFEASIBLE_COUNT) {
|
|
|
|
remove_infeasible(i);
|
2004-01-09 00:51:47 +00:00
|
|
|
} else if (wu_result.infeasible_count > MAX_INFEASIBLE_THRESHOLD) {
|
2003-09-21 21:00:25 +00:00
|
|
|
ninfeasible++;
|
|
|
|
}
|
2004-03-24 00:16:18 +00:00
|
|
|
#endif
|
2003-09-21 21:00:25 +00:00
|
|
|
} else {
|
2003-01-07 22:49:42 +00:00
|
|
|
try_again:
|
2003-09-21 21:00:25 +00:00
|
|
|
retval = result.enumerate(clause);
|
|
|
|
if (retval) {
|
2002-05-30 07:14:21 +00:00
|
|
|
|
2003-09-21 21:00:25 +00:00
|
|
|
// if we already restarted the enum on this array scan,
|
|
|
|
// there's no point in doing it again.
|
|
|
|
//
|
|
|
|
if (restarted_enum) {
|
2004-04-08 08:15:23 +00:00
|
|
|
log_messages.printf(SCHED_MSG_LOG::DEBUG,
|
2003-09-21 22:33:43 +00:00
|
|
|
"already restarted enum on this array scan\n"
|
|
|
|
);
|
2003-09-21 21:00:25 +00:00
|
|
|
break;
|
2002-05-30 07:14:21 +00:00
|
|
|
}
|
2003-05-21 00:13:55 +00:00
|
|
|
|
2003-09-21 21:00:25 +00:00
|
|
|
// restart the enumeration
|
2003-05-21 00:13:55 +00:00
|
|
|
//
|
2003-09-21 21:00:25 +00:00
|
|
|
restarted_enum = true;
|
|
|
|
retval = result.enumerate(clause);
|
2004-04-08 08:15:23 +00:00
|
|
|
log_messages.printf(SCHED_MSG_LOG::DEBUG,
|
2003-09-21 22:33:43 +00:00
|
|
|
"restarting enumeration\n"
|
|
|
|
);
|
2003-05-21 00:13:55 +00:00
|
|
|
if (retval) {
|
2004-04-08 08:15:23 +00:00
|
|
|
log_messages.printf(SCHED_MSG_LOG::DEBUG,
|
2003-09-21 22:33:43 +00:00
|
|
|
"enumeration restart returned nothing\n"
|
|
|
|
);
|
2003-09-21 21:00:25 +00:00
|
|
|
no_wus = true;
|
|
|
|
break;
|
2003-01-07 22:49:42 +00:00
|
|
|
}
|
2003-09-21 21:00:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// there's a chance this result was sent out
|
|
|
|
// after the enumeration started.
|
|
|
|
// So read it from the DB again
|
|
|
|
//
|
|
|
|
retval = result.lookup_id(result.id);
|
|
|
|
if (retval) {
|
2004-04-08 08:15:23 +00:00
|
|
|
log_messages.printf(SCHED_MSG_LOG::NORMAL,
|
2003-09-21 21:00:25 +00:00
|
|
|
"[%s] can't reread result: %d\n", result.name, retval
|
|
|
|
);
|
|
|
|
goto try_again;
|
|
|
|
}
|
|
|
|
if (result.server_state != RESULT_SERVER_STATE_UNSENT) {
|
|
|
|
log_messages.printf(
|
2004-04-08 08:15:23 +00:00
|
|
|
SCHED_MSG_LOG::NORMAL,
|
2003-09-21 21:00:25 +00:00
|
|
|
"[%s] RESULT STATE CHANGED\n",
|
|
|
|
result.name
|
|
|
|
);
|
|
|
|
goto try_again;
|
|
|
|
}
|
|
|
|
collision = false;
|
|
|
|
for (j=0; j<ssp->nwu_results; j++) {
|
2004-04-04 01:59:47 +00:00
|
|
|
if (ssp->wu_results[j].state != WR_STATE_EMPTY
|
2003-09-21 21:00:25 +00:00
|
|
|
&& ssp->wu_results[j].result.id == result.id
|
|
|
|
) {
|
|
|
|
ncollisions++;
|
|
|
|
collision = true;
|
|
|
|
break;
|
2002-05-30 07:14:21 +00:00
|
|
|
}
|
2003-09-21 21:00:25 +00:00
|
|
|
}
|
|
|
|
if (!collision) {
|
|
|
|
log_messages.printf(
|
2004-04-08 08:15:23 +00:00
|
|
|
SCHED_MSG_LOG::NORMAL,
|
2003-09-21 21:00:25 +00:00
|
|
|
"[%s] adding result in slot %d\n",
|
|
|
|
result.name, i
|
|
|
|
);
|
|
|
|
retval = wu.lookup_id(result.workunitid);
|
|
|
|
if (retval) {
|
2003-07-13 01:10:24 +00:00
|
|
|
log_messages.printf(
|
2004-04-08 08:15:23 +00:00
|
|
|
SCHED_MSG_LOG::CRITICAL,
|
2003-09-21 21:00:25 +00:00
|
|
|
"[%s] can't read workunit #%d: %d\n",
|
|
|
|
result.name, result.workunitid, retval
|
2003-07-13 01:10:24 +00:00
|
|
|
);
|
2003-09-21 21:00:25 +00:00
|
|
|
continue;
|
2002-05-30 07:14:21 +00:00
|
|
|
}
|
2003-09-21 21:00:25 +00:00
|
|
|
wu_result.result = result;
|
|
|
|
wu_result.workunit = wu;
|
2004-04-04 01:59:47 +00:00
|
|
|
wu_result.state = WR_STATE_PRESENT;
|
2003-09-21 21:00:25 +00:00
|
|
|
wu_result.infeasible_count = 0;
|
|
|
|
nadditions++;
|
2002-05-30 07:14:21 +00:00
|
|
|
}
|
|
|
|
}
|
2003-09-21 21:00:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-03-24 00:16:18 +00:00
|
|
|
#ifdef REMOVE_INFEASIBLE_ENTRIES
|
2003-09-21 22:33:43 +00:00
|
|
|
static int remove_most_infeasible() {
|
|
|
|
int i, max, imax=-1;
|
2003-09-21 21:00:25 +00:00
|
|
|
|
|
|
|
max = 0;
|
|
|
|
for (i=0; i<ssp->nwu_results; i++) {
|
|
|
|
WU_RESULT& wu_result = ssp->wu_results[i];
|
2004-04-04 01:59:47 +00:00
|
|
|
if (wu_result.state == WR_STATE_PRESENT && wu_result.infeasible_count > max) {
|
2003-09-21 21:00:25 +00:00
|
|
|
imax = i;
|
|
|
|
max = wu_result.infeasible_count;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (max == 0) return -1; // nothing is infeasible
|
|
|
|
|
2003-09-21 22:33:43 +00:00
|
|
|
return remove_infeasible(imax);
|
2003-09-21 21:00:25 +00:00
|
|
|
}
|
2004-03-24 00:16:18 +00:00
|
|
|
#endif
|
2003-09-21 21:00:25 +00:00
|
|
|
|
|
|
|
void feeder_loop() {
|
2004-03-24 00:16:18 +00:00
|
|
|
int nadditions, ncollisions, ninfeasible;
|
2003-09-21 21:00:25 +00:00
|
|
|
DB_RESULT result;
|
|
|
|
bool no_wus;
|
|
|
|
char clause[256];
|
|
|
|
|
2003-09-21 22:33:43 +00:00
|
|
|
sprintf(clause, "where server_state=%d order by random",
|
|
|
|
RESULT_SERVER_STATE_UNSENT
|
2003-09-21 21:00:25 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
while (1) {
|
|
|
|
nadditions = 0;
|
|
|
|
ncollisions = 0;
|
|
|
|
ninfeasible = 0;
|
|
|
|
no_wus = false;
|
|
|
|
|
|
|
|
scan_work_array(
|
|
|
|
result, clause, nadditions, ncollisions, ninfeasible, no_wus
|
|
|
|
);
|
|
|
|
|
2003-03-16 21:59:11 +00:00
|
|
|
ssp->ready = true;
|
2003-09-21 21:00:25 +00:00
|
|
|
|
2004-03-24 00:16:18 +00:00
|
|
|
#ifdef REMOVE_INFEASIBLE_ENTRIES
|
|
|
|
int i, n, retval;
|
2003-09-21 21:00:25 +00:00
|
|
|
if (ninfeasible > MAX_INFEASIBLE) {
|
|
|
|
n = ninfeasible - MAX_INFEASIBLE;
|
|
|
|
for (i=0; i<n; i++ ) {
|
|
|
|
retval = remove_most_infeasible();
|
|
|
|
if (retval) break;
|
|
|
|
}
|
|
|
|
}
|
2004-03-24 00:16:18 +00:00
|
|
|
#endif
|
2002-05-30 07:14:21 +00:00
|
|
|
if (nadditions == 0) {
|
2004-04-08 08:15:23 +00:00
|
|
|
log_messages.printf(SCHED_MSG_LOG::DEBUG, "No results added; sleeping 1 sec\n");
|
2002-05-30 07:14:21 +00:00
|
|
|
sleep(1);
|
|
|
|
} else {
|
2004-04-08 08:15:23 +00:00
|
|
|
log_messages.printf(SCHED_MSG_LOG::DEBUG, "Added %d results to array\n", nadditions);
|
2002-05-30 07:14:21 +00:00
|
|
|
}
|
|
|
|
if (no_wus) {
|
2004-04-08 08:15:23 +00:00
|
|
|
log_messages.printf(SCHED_MSG_LOG::DEBUG, "No results available; sleeping 5 sec\n");
|
2002-06-01 20:26:21 +00:00
|
|
|
sleep(5);
|
2002-05-30 07:14:21 +00:00
|
|
|
}
|
|
|
|
if (ncollisions) {
|
2004-04-08 08:15:23 +00:00
|
|
|
log_messages.printf(SCHED_MSG_LOG::DEBUG, "Some results already in array - sleeping 5 sec\n");
|
2002-06-01 20:26:21 +00:00
|
|
|
sleep(5);
|
2002-05-30 07:14:21 +00:00
|
|
|
}
|
2002-10-09 04:56:41 +00:00
|
|
|
fflush(stdout);
|
2003-06-20 01:31:03 +00:00
|
|
|
check_stop_trigger();
|
|
|
|
check_reread_trigger();
|
2002-06-01 20:26:21 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int main(int argc, char** argv) {
|
|
|
|
int i, retval;
|
|
|
|
bool asynch = false;
|
|
|
|
void* p;
|
2004-04-04 01:59:47 +00:00
|
|
|
char path[256];
|
2002-06-01 20:26:21 +00:00
|
|
|
|
2002-12-03 18:57:40 +00:00
|
|
|
unlink(REREAD_DB_FILENAME);
|
2002-10-09 04:56:41 +00:00
|
|
|
|
2003-09-02 21:16:55 +00:00
|
|
|
retval = config.parse_file("..");
|
2002-10-03 18:33:46 +00:00
|
|
|
if (retval) {
|
2004-04-08 08:15:23 +00:00
|
|
|
log_messages.printf(SCHED_MSG_LOG::CRITICAL, "can't parse config file\n");
|
2002-10-03 18:33:46 +00:00
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
2002-06-01 20:26:21 +00:00
|
|
|
for (i=1; i<argc; i++) {
|
|
|
|
if (!strcmp(argv[i], "-asynch")) {
|
|
|
|
asynch = true;
|
2003-06-11 23:36:40 +00:00
|
|
|
} else if (!strcmp(argv[i], "-d")) {
|
2003-07-02 02:02:18 +00:00
|
|
|
log_messages.set_debug_level(atoi(argv[++i]));
|
2002-06-01 20:26:21 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-11-08 08:54:16 +00:00
|
|
|
if (asynch) {
|
|
|
|
if (fork()!=0) {
|
|
|
|
exit(0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-04-08 08:15:23 +00:00
|
|
|
log_messages.printf(SCHED_MSG_LOG::NORMAL, "Starting\n");
|
2003-02-27 19:29:48 +00:00
|
|
|
|
2004-04-04 02:59:42 +00:00
|
|
|
get_project_dir(path, sizeof(path));
|
2004-04-04 01:59:47 +00:00
|
|
|
get_key(path, 'a', sema_key);
|
|
|
|
destroy_semaphore(sema_key);
|
|
|
|
create_semaphore(sema_key);
|
|
|
|
|
2002-10-03 18:33:46 +00:00
|
|
|
retval = destroy_shmem(config.shmem_key);
|
2002-06-01 20:26:21 +00:00
|
|
|
if (retval) {
|
2004-04-08 08:15:23 +00:00
|
|
|
log_messages.printf(SCHED_MSG_LOG::CRITICAL, "can't destroy shmem\n");
|
2002-06-01 20:26:21 +00:00
|
|
|
exit(1);
|
|
|
|
}
|
2002-10-03 18:33:46 +00:00
|
|
|
retval = create_shmem(config.shmem_key, sizeof(SCHED_SHMEM), &p);
|
2002-06-01 20:26:21 +00:00
|
|
|
if (retval) {
|
2004-04-08 08:15:23 +00:00
|
|
|
log_messages.printf(SCHED_MSG_LOG::CRITICAL, "can't create shmem\n");
|
2002-06-01 20:26:21 +00:00
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
ssp = (SCHED_SHMEM*)p;
|
|
|
|
ssp->init();
|
2003-06-20 01:31:03 +00:00
|
|
|
|
|
|
|
atexit(cleanup_shmem);
|
2003-12-31 23:09:21 +00:00
|
|
|
install_stop_signal_handler();
|
2003-06-20 01:31:03 +00:00
|
|
|
|
2004-01-15 23:53:13 +00:00
|
|
|
retval = boinc_db.open(config.db_name, config.db_host, config.db_user, config.db_passwd);
|
2002-06-01 20:26:21 +00:00
|
|
|
if (retval) {
|
2004-04-08 08:15:23 +00:00
|
|
|
log_messages.printf(SCHED_MSG_LOG::CRITICAL, "boinc_db.open: %d; %s\n", retval, boinc_db.error_string());
|
2002-06-01 20:26:21 +00:00
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
ssp->scan_tables();
|
|
|
|
|
2003-07-13 01:10:24 +00:00
|
|
|
log_messages.printf(
|
2004-04-08 08:15:23 +00:00
|
|
|
SCHED_MSG_LOG::NORMAL,
|
2003-07-13 01:10:24 +00:00
|
|
|
"feeder: read "
|
|
|
|
"%d platforms, "
|
|
|
|
"%d apps, "
|
|
|
|
"%d app_versions\n",
|
|
|
|
ssp->nplatforms,
|
|
|
|
ssp->napps,
|
|
|
|
ssp->napp_versions
|
|
|
|
);
|
2002-06-01 20:26:21 +00:00
|
|
|
|
2003-06-20 01:31:03 +00:00
|
|
|
feeder_loop();
|
2002-05-30 07:14:21 +00:00
|
|
|
}
|