mirror of https://github.com/BOINC/boinc.git
parent
0423d6c4d3
commit
29d50db100
|
@ -813,7 +813,7 @@ void process_request(
|
|||
int last_rpc_dayofyear;
|
||||
int current_rpc_dayofyear;
|
||||
bool ok_to_send_work = true;
|
||||
|
||||
bool have_no_work;
|
||||
|
||||
// if different major version of BOINC, just send a message
|
||||
//
|
||||
|
@ -831,8 +831,12 @@ void process_request(
|
|||
// this isn't an initial RPC,
|
||||
// and client is requesting work, return without accessing DB
|
||||
//
|
||||
lock_sema();
|
||||
have_no_work = ss.no_work(g_pid);
|
||||
unlock_sema();
|
||||
|
||||
if ((sreq.work_req_seconds > 0)
|
||||
&& ss.no_work()
|
||||
&& have_no_work
|
||||
&& (sreq.results.size() == 0)
|
||||
&& (sreq.hostid != 0)
|
||||
) {
|
||||
|
@ -845,16 +849,18 @@ void process_request(
|
|||
return;
|
||||
}
|
||||
|
||||
// FROM HERE ON DON'T RETURN; goto leave instead
|
||||
|
||||
// now open the database
|
||||
//
|
||||
retval = open_database();
|
||||
if (retval) {
|
||||
send_message("Server can't open database", 3600);
|
||||
return;
|
||||
goto leave;
|
||||
}
|
||||
|
||||
retval = authenticate_user(sreq, reply);
|
||||
if (retval) return;
|
||||
if (retval) goto leave;
|
||||
if (reply.user.id == 0) {
|
||||
log_messages.printf(SCHED_MSG_LOG::CRITICAL, "No user ID!\n");
|
||||
}
|
||||
|
@ -891,7 +897,7 @@ void process_request(
|
|||
SCHED_MSG_LOG::CRITICAL, "[HOST#%d] platform '%s' not found\n",
|
||||
reply.host.id, sreq.platform_name
|
||||
);
|
||||
return;
|
||||
goto leave;
|
||||
}
|
||||
|
||||
handle_global_prefs(sreq, reply);
|
||||
|
@ -906,7 +912,7 @@ void process_request(
|
|||
|
||||
// if last RPC was within config.min_sendwork_interval, don't send work
|
||||
//
|
||||
if (ok_to_send_work && sreq.work_req_seconds > 0) {
|
||||
if (!have_no_work && ok_to_send_work && sreq.work_req_seconds > 0) {
|
||||
if (config.min_sendwork_interval) {
|
||||
double diff = dtime() - last_rpc_time;
|
||||
if (diff < config.min_sendwork_interval) {
|
||||
|
@ -935,6 +941,11 @@ void process_request(
|
|||
}
|
||||
|
||||
update_host_record(reply.host);
|
||||
|
||||
leave:
|
||||
if (!have_no_work) {
|
||||
ss.restore_work(g_pid);
|
||||
}
|
||||
}
|
||||
|
||||
void handle_request(
|
||||
|
|
|
@ -66,6 +66,7 @@ bool use_files = false; // use disk files for req/reply msgs (for debugging)
|
|||
|
||||
SCHED_CONFIG config;
|
||||
key_t sema_key;
|
||||
int g_pid;
|
||||
|
||||
void send_message(char* msg, int delay) {
|
||||
printf(
|
||||
|
@ -96,7 +97,7 @@ int open_database() {
|
|||
|
||||
int main() {
|
||||
FILE* fin, *fout;
|
||||
int i, retval, pid;
|
||||
int i, retval;
|
||||
char req_path[256], reply_path[256], path[256];
|
||||
SCHED_SHMEM* ssp=0;
|
||||
void* p;
|
||||
|
@ -169,7 +170,7 @@ int main() {
|
|||
}
|
||||
}
|
||||
|
||||
pid = getpid();
|
||||
g_pid = getpid();
|
||||
#ifdef _USING_FCGI_
|
||||
while(FCGI_Accept() >= 0) {
|
||||
counter++;
|
||||
|
@ -186,8 +187,8 @@ int main() {
|
|||
// (this makes it easy to save the input,
|
||||
// and to know the length of the output).
|
||||
//
|
||||
sprintf(req_path, "%s%d_%u", REQ_FILE_PREFIX, pid, counter);
|
||||
sprintf(reply_path, "%s%d_%u", REPLY_FILE_PREFIX, pid, counter);
|
||||
sprintf(req_path, "%s%d_%u", REQ_FILE_PREFIX, g_pid, counter);
|
||||
sprintf(reply_path, "%s%d_%u", REPLY_FILE_PREFIX, g_pid, counter);
|
||||
fout = fopen(req_path, "w");
|
||||
if (!fout) {
|
||||
log_messages.printf(SCHED_MSG_LOG::CRITICAL, "can't write request file\n");
|
||||
|
|
|
@ -23,6 +23,9 @@
|
|||
|
||||
extern SCHED_CONFIG config;
|
||||
extern key_t sema_key;
|
||||
extern int g_pid;
|
||||
extern void lock_sema();
|
||||
extern void unlock_sema();
|
||||
|
||||
extern void send_message(char*, int);
|
||||
extern int open_database();
|
||||
|
|
|
@ -496,10 +496,8 @@ static void scan_work_array(
|
|||
// i.e. ones that don't require DB access
|
||||
// if any check fails, continue
|
||||
|
||||
switch (wu_result.state) {
|
||||
case WR_STATE_EMPTY:
|
||||
case WR_STATE_CHECKED_OUT:
|
||||
continue;
|
||||
if (wu_result.state != WR_STATE_PRESENT || wu_result.state != g_pid) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (wreq.infeasible_only && (wu_result.infeasible_count==0)) {
|
||||
|
|
|
@ -157,12 +157,26 @@ APP_VERSION* SCHED_SHMEM::lookup_app_version(
|
|||
return best_avp;
|
||||
}
|
||||
|
||||
bool SCHED_SHMEM::no_work() {
|
||||
bool SCHED_SHMEM::no_work(int pid) {
|
||||
int i;
|
||||
|
||||
if (!ready) return false;
|
||||
if (!ready) return true;
|
||||
for (i=0; i<max_wu_results; i++) {
|
||||
if (wu_results[i].state == WR_STATE_PRESENT) return false;
|
||||
if (wu_results[i].state == WR_STATE_PRESENT) {
|
||||
wu_results[i].state = pid;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void SCHED_SHMEM::restore_work(int pid) {
|
||||
int i;
|
||||
|
||||
for (i=0; i<max_wu_results; i++) {
|
||||
if (wu_results[i].state == pid) {
|
||||
wu_results[i].state = WR_STATE_PRESENT;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -80,7 +80,8 @@ struct SCHED_SHMEM {
|
|||
int verify();
|
||||
int scan_tables();
|
||||
bool have_app(int);
|
||||
bool no_work();
|
||||
bool no_work(int pid);
|
||||
void restore_work(int pid);
|
||||
|
||||
APP* lookup_app(int);
|
||||
APP_VERSION* lookup_app_version(int appid, int platform, int version);
|
||||
|
|
|
@ -62,6 +62,8 @@ int main() {
|
|||
case WR_STATE_CHECKED_OUT:
|
||||
printf("%d: checked out: result %d\n", i, wu_result.resultid);
|
||||
break;
|
||||
default:
|
||||
printf("%d: PID %d: result %d\n", i, wu_result.state, wu_result.resultid);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue