diff --git a/api/boinc_api.C b/api/boinc_api.C index 3e576379d9..c3f48076f3 100644 --- a/api/boinc_api.C +++ b/api/boinc_api.C @@ -106,6 +106,8 @@ static volatile int interrupt_count = 0; static double fpops_per_cpu_sec = 0; static double fpops_cumulative = 0; static int non_cpu_intensive = 0; +static int want_network = 0; +static int have_network = 1; #define TIMER_PERIOD 1 // period of worker-thread timer interrupts. @@ -196,6 +198,9 @@ static bool update_app_progress( "%d\n", cpu_t, cp_cpu_t, non_cpu_intensive ); + if (want_network) { + strcat(msg_buf, "1\n"); + } if (fraction_done >= 0) { double range = aid.fraction_done_end - aid.fraction_done_start; double fdone = aid.fraction_done_start + fraction_done*range; @@ -550,6 +555,9 @@ static void handle_process_control_msg() { if (match_tag(buf, "")) { boinc_status.reread_init_data_file = true; } + if (match_tag(buf, "")) { + have_network = 1; + } } } @@ -809,6 +817,19 @@ void boinc_using_cpu() { non_cpu_intensive = 0; } +void boinc_need_network() { + want_network = 1; + have_network = 0; +} + +int boinc_network_poll() { + return have_network?0:1; +} + +void boinc_network_done() { + want_network = 0; +} + #ifndef _WIN32 // block SIGALRM, so that the worker thread will be forced to handle it // diff --git a/checkin_notes b/checkin_notes index 94e35e407a..b481e2ffa0 100755 --- a/checkin_notes +++ b/checkin_notes @@ -10800,3 +10800,33 @@ David 17 Aug 2005 scheduler_op.C lib/ app_ipc.h + +David 17 Aug 2005 + - Add new API calls: + boinc_need_network() + boinc_network_poll() + boinc_network_done() + For apps that do network communication. + If there is no physical connection (e.g. modem not dialed) + this allows the app + 1) to request (via the core client and the BOINC manager) + that the user establish a connection; + 2) to learn when a connection has been established + 3) to indicate that it is done with network comm + (e.g. so we can hang up the modem) + + Implementation: + Add want_network, have_network flags in API lib. + Send want_network in app_status messages to core. + Core: on network_available(), send to + any app that wants network. + + (for Folding@Home) + + api/ + boinc_api.C + client/ + app.C,h + app_control.C + client_state.C + scheduler_op.C diff --git a/client/app.C b/client/app.C index 21b4935605..f4da07ca10 100644 --- a/client/app.C +++ b/client/app.C @@ -102,7 +102,8 @@ ACTIVE_TASK::ACTIVE_TASK() { have_trickle_down = false; send_upload_file_status = false; pending_suspend_via_quit = false; - non_cpu_intensive = false; + non_cpu_intensive = 0; + want_network = 0; #ifdef _WIN32 pid_handle = 0; thread_handle = 0; @@ -554,6 +555,23 @@ void ACTIVE_TASK_SET::handle_upload_files() { } } +bool ACTIVE_TASK_SET::want_network() { + for (unsigned int i=0; iwant_network) return true; + } + return false; +} + +void ACTIVE_TASK_SET::network_available() { + for (unsigned int i=0; iwant_network) { + atp->send_network_available(); + } + } +} + void ACTIVE_TASK::upload_notify_app(const FILE_INFO* fip, const FILE_REF* frp) { char path[256]; sprintf(path, "%s/%s%s", slot_dir, UPLOAD_FILE_STATUS_PREFIX, frp->open_name); diff --git a/client/app.h b/client/app.h index 1b63a7cd7c..047e4f75b8 100644 --- a/client/app.h +++ b/client/app.h @@ -125,6 +125,7 @@ public: bool send_upload_file_status; bool pending_suspend_via_quit; // waiting for task to suspend via quit int non_cpu_intensive; + int want_network; APP_CLIENT_SHM app_client_shm; // core/app shared mem MSG_QUEUE graphics_request_queue; @@ -167,6 +168,7 @@ public: bool has_task_exited(); // return true if this task has exited int preempt(bool quit_task); // preempt (via suspend or quit) a running task int resume_or_start(); + void send_network_available(); #ifdef _WIN32 bool handle_exited_app(unsigned long); #else @@ -220,6 +222,8 @@ public: void report_overdue(); void handle_upload_files(); void upload_notify_app(FILE_INFO*); + bool want_network(); + void network_available(); // screensaver-related functions ACTIVE_TASK* get_ss_app(); diff --git a/client/app_control.C b/client/app_control.C index c766703108..cf9aab2971 100644 --- a/client/app_control.C +++ b/client/app_control.C @@ -797,6 +797,15 @@ int ACTIVE_TASK::unsuspend() { return 0; } +void ACTIVE_TASK::send_network_available() { + if (!app_client_shm.shm) return; + process_control_queue.msg_queue_send( + "", + app_client_shm.shm->process_control_request + ); + return; +} + // See if the app has placed a new message in shared mem // (with CPU done, frac done etc.) // If so parse it and return true. diff --git a/client/client_state.C b/client/client_state.C index 440d136f01..1db214cf95 100644 --- a/client/client_state.C +++ b/client/client_state.C @@ -1404,6 +1404,7 @@ bool CLIENT_STATE::want_network() { if (http_ops->nops()) return true; if (network_suspended) return false; if (want_network_flag) return true; + if (active_tasks.want_network()) return true; return false; } @@ -1418,6 +1419,7 @@ void CLIENT_STATE::network_available() { PROJECT* p = projects[i]; p->min_rpc_time = 0; } + active_tasks.network_available(); } const char *BOINC_RCSID_e836980ee1 = "$Id$"; diff --git a/client/scheduler_op.C b/client/scheduler_op.C index 1dc9da5341..c8db5e3408 100644 --- a/client/scheduler_op.C +++ b/client/scheduler_op.C @@ -541,7 +541,7 @@ SCHEDULER_REPLY::~SCHEDULER_REPLY() { // int SCHEDULER_REPLY::parse(FILE* in, PROJECT* project) { char buf[256], msg_buf[1024], pri_buf[256]; - int retval, x; + int retval; MIOFILE mf; std::string delete_file_name; mf.init_file(in);