Skip to content
Merged
Show file tree
Hide file tree
Changes from 25 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
72b32bd
Client, Manager, API, docker_wrapper: support network access from apps
davidpanderson May 18, 2026
c8df367
Oops! I confused Docker build and create commands
davidpanderson May 19, 2026
96436f9
docker_wrapper: check for exit requests while waiting for network
davidpanderson May 19, 2026
5508aaa
docker_wrapper: show error code if google unreachable
davidpanderson May 20, 2026
5dfb25a
fix
davidpanderson May 20, 2026
aa9037d
On Win, gethostbyname() continues to fail even when network reconnect…
davidpanderson May 20, 2026
dac17ec
Fix Windows 'ping' idiocy
davidpanderson May 20, 2026
206ec56
docker_wrapper: report need_network
davidpanderson May 20, 2026
fbd2e38
client: don't strip tags in messages / notices
davidpanderson May 20, 2026
573d038
remove unused code
davidpanderson May 20, 2026
d694c7b
Merge branch 'dpa_app_network' of github.com:BOINC/boinc into dpa_app…
davidpanderson May 20, 2026
4b8be19
API: fix C language issue
davidpanderson May 20, 2026
9aa8f39
docker_wrapper: print network-related msgs only if verbose flag set
davidpanderson May 20, 2026
2d7c544
comment
davidpanderson May 20, 2026
ba51777
Cubic fixes
davidpanderson May 20, 2026
eabf883
client/docker_wrapper: allow network test server other than Google
davidpanderson May 20, 2026
d99c9dd
lib: CreateProcess() can modify its cmd arg. So copy it to a temp buf
davidpanderson May 20, 2026
0cc4b45
lib: always <want_networ> in progress message
davidpanderson May 20, 2026
9d53936
- use 'berkeley.edu' instead of 'google.com' as test host
davidpanderson May 20, 2026
05979c9
docker_wrapper: need to look for different error str if not retrying
davidpanderson May 21, 2026
47a3ff6
client: work fetch tweak
davidpanderson May 21, 2026
0b35a51
fix API tag mismatch
davidpanderson May 21, 2026
589262d
Unix: run_command() wasn't returning nonzero if the command failed.
davidpanderson May 21, 2026
5b115b4
docker_wrapper: fix build command logic
davidpanderson May 21, 2026
854d71e
docker_wrapper: wait for a heartbeat message before checking network …
davidpanderson May 21, 2026
6e622d5
docker_wrapper: add printfs
davidpanderson May 21, 2026
8dbe71d
remote printf
davidpanderson May 21, 2026
cbe058e
remove some unused bytes sent/received code
davidpanderson May 21, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 12 additions & 26 deletions api/boinc_api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,6 @@ static volatile int running_interrupt_count = 0;
static volatile bool finishing;
// used for worker/timer synch during boinc_finish();
static int want_network = 0;
static int have_network = 1;
static double bytes_sent = 0;
static double bytes_received = 0;
bool boinc_disable_timer_thread = false;
Expand All @@ -205,6 +204,7 @@ int app_min_checkpoint_period = 0;
static volatile SPORADIC_AC_STATE ac_state;
static volatile int ac_fd, ca_fd;
static volatile bool do_sporadic_files;
bool got_heartbeat_message = false;

#define TIMER_PERIOD 0.1
// Sleep interval for timer thread;
Expand Down Expand Up @@ -425,12 +425,11 @@ static bool update_app_progress(double cpu_t, double cp_cpu_t) {

snprintf(msg_buf, sizeof(msg_buf),
"<current_cpu_time>%e</current_cpu_time>\n"
"<checkpoint_cpu_time>%e</checkpoint_cpu_time>\n",
cpu_t, cp_cpu_t
"<checkpoint_cpu_time>%e</checkpoint_cpu_time>\n"
"<want_network>%d</want_network>\n",
cpu_t, cp_cpu_t,
want_network?1:0
);
if (want_network) {
strlcat(msg_buf, "<want_network>1</want_network>\n", sizeof(msg_buf));
}
if (fraction_done >= 0) {
double range = aid.fraction_done_end - aid.fraction_done_start;
double fdone = aid.fraction_done_start + fraction_done*range;
Expand Down Expand Up @@ -480,12 +479,13 @@ static void handle_heartbeat_msg() {
if (parse_double(buf, "<max_wss>", dtemp)) {
boinc_status.max_working_set_size = dtemp;
}
if (parse_bool(buf, "suspend_network", btemp)) {
if (parse_bool(buf, "network_suspended", btemp)) {
boinc_status.network_suspended = btemp;
}
if (parse_int(buf, "<sporadic_ca>", i)) {
boinc_status.ca_state = (SPORADIC_CA_STATE)i;
}
got_heartbeat_message = true;
}

// called in timer thread
Expand Down Expand Up @@ -970,11 +970,6 @@ void boinc_exit(int status) {
#endif
}

void boinc_network_usage(double sent, double received) {
bytes_sent = sent;
bytes_received = received;
}

int boinc_is_standalone() {
if (standalone) return 1;
return 0;
Expand Down Expand Up @@ -1122,6 +1117,9 @@ int boinc_report_app_status_aux(
sprintf(buf, "<wss>%f</wss>\n", wss);
strlcat(msg_buf, buf, sizeof(msg_buf));
}
if (want_network) {
strlcat(msg_buf, "<want_network>1</want_network>\n", sizeof(msg_buf));
}
Comment on lines +1102 to +1104
#ifdef MSGS_FROM_FILE
if (fout) {
fputs(msg_buf, fout);
Expand Down Expand Up @@ -1371,9 +1369,6 @@ static void handle_process_control_msg() {
if (match_tag(buf, "<reread_app_info/>")) {
boinc_status.reread_init_data_file = true;
}
if (match_tag(buf, "<network_available/>")) {
have_network = 1;
}
#ifdef ANDROID
// Trigger call to worker_signal_handler() in the worker thread
//
Expand Down Expand Up @@ -1794,17 +1789,8 @@ int boinc_upload_status(std::string& name) {
return ERR_NOT_FOUND;
}

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;
void boinc_waiting_for_network(bool x) {
want_network = x;
}

#ifndef _WIN32
Expand Down
9 changes: 3 additions & 6 deletions api/boinc_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ typedef struct BOINC_OPTIONS {
// set this if application creates subprocesses.
} BOINC_OPTIONS;

// info passed from client to app in heartbeat message
// info passed from client to app in heartbeat and process control messages
//
typedef struct BOINC_STATUS {
int no_heartbeat;
Expand Down Expand Up @@ -100,10 +100,6 @@ extern int boinc_report_app_status(
extern int boinc_time_to_checkpoint(void);
extern void boinc_begin_critical_section(void);
extern void boinc_end_critical_section(void);
extern void boinc_need_network(void);
extern int boinc_network_poll(void);
extern void boinc_network_done(void);
extern void boinc_network_usage(double sent, double received);
extern int boinc_is_standalone(void);
extern void boinc_ops_per_cpu_sec(double fp, double integer);
extern void boinc_ops_cumulative(double fp, double integer);
Expand Down Expand Up @@ -132,6 +128,7 @@ extern int setMacIcon(char *filename, char *iconData, long iconSize);
#include <string>
#include "app_ipc.h"

extern void boinc_waiting_for_network(bool);
extern int boinc_resolve_filename_s(const char*, std::string&);
Comment on lines 126 to 132
extern int boinc_get_init_data(APP_INIT_DATA&);
extern int boinc_wu_cpu_time(double&);
Expand Down Expand Up @@ -166,6 +163,7 @@ extern HANDLE worker_thread_handle;
extern int boinc_init_options_general(BOINC_OPTIONS& opt);
extern int start_timer_thread(void);
extern bool boinc_disable_timer_thread;
extern bool got_heartbeat_message;

inline void boinc_options_defaults(BOINC_OPTIONS& b) {
b.main_program = 1;
Expand All @@ -178,7 +176,6 @@ inline void boinc_options_defaults(BOINC_OPTIONS& b) {
b.multi_process = 0;
}


/////////// IMPLEMENTATION STUFF ENDS HERE

#endif // C++ part
Expand Down
36 changes: 6 additions & 30 deletions client/app.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,10 +121,6 @@ ACTIVE_TASK::ACTIVE_TASK() {
run_interval_start_wall_time = gstate.now;
checkpoint_wall_time = 0;
elapsed_time = 0;
bytes_sent_episode = 0;
bytes_received_episode = 0;
bytes_sent = 0;
bytes_received = 0;
safe_strcpy(slot_dir, "");
safe_strcpy(slot_path, "");
max_elapsed_time = 0;
Expand Down Expand Up @@ -795,9 +791,7 @@ int ACTIVE_TASK::write(MIOFILE& fout) {
" <swap_size>%f</swap_size>\n"
" <working_set_size>%f</working_set_size>\n"
" <working_set_size_smoothed>%f</working_set_size_smoothed>\n"
" <page_fault_rate>%f</page_fault_rate>\n"
" <bytes_sent>%f</bytes_sent>\n"
" <bytes_received>%f</bytes_received>\n",
" <page_fault_rate>%f</page_fault_rate>\n",
result->project->master_url,
result->name,
task_state(),
Expand All @@ -812,9 +806,7 @@ int ACTIVE_TASK::write(MIOFILE& fout) {
procinfo.swap_size,
procinfo.working_set_size,
procinfo.working_set_size_smoothed,
procinfo.page_fault_rate,
bytes_sent,
bytes_received
procinfo.page_fault_rate
);
fout.printf("</active_task>\n");
return 0;
Expand Down Expand Up @@ -848,10 +840,7 @@ int ACTIVE_TASK::write_gui(MIOFILE& fout) {
" <working_set_size>%f</working_set_size>\n"
" <working_set_size_smoothed>%f</working_set_size_smoothed>\n"
" <page_fault_rate>%f</page_fault_rate>\n"
" <bytes_sent>%f</bytes_sent>\n"
" <bytes_received>%f</bytes_received>\n"
"%s"
"%s",
"%s%s%s",
task_state(),
app_version->version_num,
slot,
Expand All @@ -865,10 +854,9 @@ int ACTIVE_TASK::write_gui(MIOFILE& fout) {
procinfo.working_set_size,
procinfo.working_set_size_smoothed,
procinfo.page_fault_rate,
bytes_sent,
bytes_received,
too_large?" <too_large/>\n":"",
needs_shmem?" <needs_shmem/>\n":""
needs_shmem?" <needs_shmem/>\n":"",
want_network?" <want_network/>\n":""
);
if (elapsed_time > first_fraction_done_elapsed_time) {
fout.printf(
Expand Down Expand Up @@ -1008,8 +996,6 @@ int ACTIVE_TASK::parse(XML_PARSER& xp) {
else if (xp.parse_double("working_set_size_smoothed", procinfo.working_set_size_smoothed)) continue;
else if (xp.parse_double("page_fault_rate", procinfo.page_fault_rate)) continue;
else if (xp.parse_double("current_cpu_time", x)) continue;
else if (xp.parse_double("bytes_sent", bytes_sent)) continue;
else if (xp.parse_double("bytes_received", bytes_received)) continue;
else {
if (log_flags.unparsed_xml) {
msg_printf(project, MSG_INFO,
Expand Down Expand Up @@ -1220,23 +1206,13 @@ void ACTIVE_TASK_SET::handle_upload_files() {
}
}

bool ACTIVE_TASK_SET::want_network() {
bool ACTIVE_TASK_SET::some_task_wants_network() {
for (ACTIVE_TASK* atp: active_tasks) {
if (atp->want_network) return true;
}
return false;
}

void ACTIVE_TASK_SET::network_available() {
#ifndef SIM
for (ACTIVE_TASK* atp: active_tasks) {
if (atp->want_network) {
atp->send_network_available();
}
}
#endif
}

void ACTIVE_TASK::upload_notify_app(const FILE_INFO* fip, const FILE_REF* frp) {
char path[MAXPATHLEN];
snprintf(path, sizeof(path),
Expand Down
16 changes: 4 additions & 12 deletions client/app.h
Original file line number Diff line number Diff line change
Expand Up @@ -127,13 +127,6 @@ struct ACTIVE_TASK {
// wall time at the last checkpoint
double elapsed_time;
// current total running time, adjusted for CPU throttling
double bytes_sent_episode;
// bytes sent in current episode of job,
// as (optionally) reported by boinc_network_usage()
double bytes_received_episode;
double bytes_sent;
// bytes in all episodes
double bytes_received;
char slot_dir[256];
// directory where process runs (relative)
char slot_path[MAXPATHLEN];
Expand All @@ -159,8 +152,9 @@ struct ACTIVE_TASK {
bool needs_shmem;
// waiting for a free shared memory segment
int want_network;
// This task wants to do network comm (for F@h)
// this is passed via share-memory message (app_status channel)
// This task is waiting for the network
// (physical connection or no suspension)
// This is passed via share-memory message (app_status channel)
double abort_time;
// when we sent an abort message to this app
// kill it 5 seconds later if it doesn't exit
Expand Down Expand Up @@ -300,7 +294,6 @@ struct ACTIVE_TASK {
int preempt(PREEMPT_TYPE preempt_type, int reason=0);
// preempt (via suspend or quit) a running task
int resume_or_start(bool);
void send_network_available();
#ifdef _WIN32
void handle_exited_app(unsigned long);
#else
Expand Down Expand Up @@ -363,8 +356,7 @@ class ACTIVE_TASK_SET {
void report_overdue();
void handle_upload_files();
void upload_notify_app(FILE_INFO*);
bool want_network(); // does any task want network?
void network_available(); // notify tasks that network is available
bool some_task_wants_network();
void free_mem();
bool slot_taken(int);
void get_memory_usage();
Expand Down
64 changes: 34 additions & 30 deletions client/app_control.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -415,8 +415,6 @@ void ACTIVE_TASK::copy_final_info() {
result->final_peak_working_set_size = peak_working_set_size;
result->final_peak_swap_size = peak_swap_size;
result->final_peak_disk_usage = peak_disk_usage;
result->final_bytes_sent = bytes_sent;
result->final_bytes_received = bytes_received;
}

// deal with a process that has exited, for whatever reason:
Expand Down Expand Up @@ -1341,15 +1339,6 @@ int ACTIVE_TASK::unsuspend(int reason) {
return 0;
}

void ACTIVE_TASK::send_network_available() {
if (!app_client_shm.shm) return;
process_control_queue.msg_queue_send(
"<network_available/>",
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.
Expand All @@ -1358,7 +1347,6 @@ bool ACTIVE_TASK::get_app_status_msg() {
char msg_buf[MSG_CHANNEL_SIZE];
double fd;
int other_pid, i;
double dtemp;
static double last_msg_time=0;

if (!app_client_shm.shm) {
Expand All @@ -1375,7 +1363,7 @@ bool ACTIVE_TASK::get_app_status_msg() {
"[app_msg_receive] got msg from slot %d: %s", slot, msg_buf
);
}
want_network = 0;
int new_want_network = 0;
current_cpu_time = checkpoint_cpu_time = 0.0;
if (parse_double(msg_buf, "<fraction_done>", fd)) {
// fraction_done will be reported as zero
Expand Down Expand Up @@ -1420,23 +1408,7 @@ bool ACTIVE_TASK::get_app_status_msg() {
parse_double(msg_buf, "<fpops_cumulative>", result->fpops_cumulative);
parse_double(msg_buf, "<intops_per_cpu_sec>", result->intops_per_cpu_sec);
parse_double(msg_buf, "<intops_cumulative>", result->intops_cumulative);
if (parse_double(msg_buf, "<bytes_sent>", dtemp)) {
if (dtemp > bytes_sent_episode) {
double nbytes = dtemp - bytes_sent_episode;
daily_xfer_history.add(nbytes, true);
bytes_sent += nbytes;
}
bytes_sent_episode = dtemp;
}
if (parse_double(msg_buf, "<bytes_received>", dtemp)) {
if (dtemp > bytes_received_episode) {
double nbytes = dtemp - bytes_received_episode;
daily_xfer_history.add(nbytes, false);
bytes_received += nbytes;
}
bytes_received_episode = dtemp;
}
parse_int(msg_buf, "<want_network>", want_network);
parse_int(msg_buf, "<want_network>", new_want_network);
if (parse_int(msg_buf, "<other_pid>", other_pid)) {
// for now, we handle only one of these
other_pids.clear();
Expand All @@ -1445,6 +1417,38 @@ bool ACTIVE_TASK::get_app_status_msg() {
if (parse_int(msg_buf, "<sporadic_ac>", i)) {
sporadic_ac_state = (SPORADIC_AC_STATE)i;
}

switch (new_want_network) {
case 0:
// if want_network goes true to false,
// and no tasks now want network, remove notice
//
if (want_network) {
want_network = 0;
if (net_status.network_notice_active) {
if (!gstate.active_tasks.some_task_wants_network()) {
notices.remove_notices(NULL, REMOVE_NETWORK_MSG);
net_status.network_notice_active = false;
}
}
Comment on lines +1424 to +1436
}
break;
case 1:
// if want_network goes from false to true, show notice
//
if (!want_network) {
if (!net_status.network_notice_active) {
if (gstate.network_suspended) {
msg_printf(0, MSG_USER_ALERT, APP_NETWORK_SUSPENDED_MSG);
} else {
msg_printf(0, MSG_USER_ALERT, APP_NEED_NETWORK_MSG);
}
net_status.network_notice_active = true;
}
want_network = 1;
}
break;
}
Comment on lines +1421 to +1457
return true;
}

Expand Down
3 changes: 0 additions & 3 deletions client/app_start.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -674,9 +674,6 @@ int ACTIVE_TASK::start() {
graphics_request_queue.init(result->name); // reset message queues
process_control_queue.init(result->name);

bytes_sent_episode = 0;
bytes_received_episode = 0;

if (!app_client_shm.shm) {
retval = get_shmem_seg_name();
if (retval) {
Expand Down
Loading
Loading