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-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
|
|
|
|
|
2004-07-13 13:54:09 +00:00
|
|
|
#include <cstdio>
|
|
|
|
#include <cstdlib>
|
|
|
|
#include <cstring>
|
|
|
|
#include <ctime>
|
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
|
|
|
|
2004-08-21 19:03:12 +00:00
|
|
|
// The following parameters determine the feeder's policy
|
|
|
|
// for purging "infeasible" results,
|
|
|
|
// i.e. those that are hard to send to any client.
|
|
|
|
// TODO: remove these from the source code,
|
|
|
|
// make them config.xml parameters
|
|
|
|
|
|
|
|
#define MAX_INFEASIBLE_THRESHOLD 2000
|
|
|
|
// if a result's infeasible_count exceeds this,
|
|
|
|
// count it as "possibly infeasible" (see the following)
|
|
|
|
// TODO: lower this to 20 or so
|
|
|
|
#define MAX_INFEASIBLE 500
|
|
|
|
// if # of possibly infeasibly results exceeds this,
|
|
|
|
// classify some of them as COULDNT_SEND and remove from array
|
|
|
|
#define MAX_INFEASIBLE_COUNT 5000
|
|
|
|
// a result's infeasible_count exceeds this,
|
|
|
|
// classify as COULDNT_SEND and remove it from array
|
|
|
|
// TODO: lower this to 50 or so
|
|
|
|
|
|
|
|
// Uncomment the following to enable this purging.
|
|
|
|
//
|
|
|
|
//#define REMOVE_INFEASIBLE_ENTRIES
|
|
|
|
|
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
|
|
|
|
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(
|
2004-07-03 17:57:32 +00:00
|
|
|
DB_WORK_ITEM& wi, int limit,
|
2003-09-21 21:00:25 +00:00
|
|
|
int& nadditions, int& ncollisions, int& ninfeasible,
|
|
|
|
bool& no_wus
|
|
|
|
) {
|
|
|
|
int i, j, retval;
|
|
|
|
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-08-21 19:03:12 +00:00
|
|
|
switch (wu_result.state) {
|
|
|
|
case WR_STATE_CHECKED_OUT:
|
|
|
|
break;
|
2004-03-24 00:16:18 +00:00
|
|
|
#ifdef REMOVE_INFEASIBLE_ENTRIES
|
2004-08-21 19:03:12 +00:00
|
|
|
case WR_STATE_PRESENT:
|
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-08-21 19:03:12 +00:00
|
|
|
break;
|
2004-03-24 00:16:18 +00:00
|
|
|
#endif
|
2004-08-21 19:03:12 +00:00
|
|
|
case WR_STATE_EMPTY:
|
2004-07-03 17:57:32 +00:00
|
|
|
retval = wi.enumerate(limit);
|
2003-09-21 21:00:25 +00:00
|
|
|
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;
|
2004-07-03 17:57:32 +00:00
|
|
|
retval = wi.enumerate(limit);
|
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
|
|
|
}
|
|
|
|
|
|
|
|
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
|
2004-07-03 17:57:32 +00:00
|
|
|
&& ssp->wu_results[j].resultid == wi.res_id
|
2003-09-21 21:00:25 +00:00
|
|
|
) {
|
|
|
|
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,
|
2004-07-03 17:57:32 +00:00
|
|
|
"adding result [RESULT#%d] in slot %d\n",
|
|
|
|
wi.res_id, i
|
2003-09-21 21:00:25 +00:00
|
|
|
);
|
2004-07-03 17:57:32 +00:00
|
|
|
if (!ssp->have_app(wi.wu.appid)) {
|
2004-06-17 23:23:13 +00:00
|
|
|
continue;
|
|
|
|
}
|
2004-07-03 17:57:32 +00:00
|
|
|
wu_result.resultid = wi.res_id;
|
|
|
|
wu_result.workunit = wi.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;
|
2004-07-03 17:57:32 +00:00
|
|
|
DB_WORK_ITEM wi;
|
2003-09-21 21:00:25 +00:00
|
|
|
bool no_wus;
|
|
|
|
|
|
|
|
while (1) {
|
|
|
|
nadditions = 0;
|
|
|
|
ncollisions = 0;
|
|
|
|
ninfeasible = 0;
|
|
|
|
no_wus = false;
|
|
|
|
|
|
|
|
scan_work_array(
|
2004-07-03 17:57:32 +00:00
|
|
|
wi, 1000, nadditions, ncollisions, ninfeasible, no_wus
|
2003-09-21 21:00:25 +00:00
|
|
|
);
|
|
|
|
|
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);
|
2004-05-03 19:30:01 +00:00
|
|
|
check_stop_daemons();
|
2003-06-20 01:31:03 +00:00
|
|
|
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
|
|
|
}
|