diff --git a/api/boinc_api.cpp b/api/boinc_api.cpp
index f24f8c297c..f55a0f08c1 100644
--- a/api/boinc_api.cpp
+++ b/api/boinc_api.cpp
@@ -135,7 +135,13 @@ static volatile bool standalone = false;
static volatile double initial_wu_cpu_time;
static volatile bool have_new_trickle_up = false;
static volatile bool have_trickle_down = true;
- // on first call, scan slot dir for msgs
+ // set if the client notified us of a trickle-down.
+ // init to true so the first call to boinc_receive_trickle_down()
+ // will scan the slot dir for old trickle-down files
+static volatile bool handle_trickle_downs = false;
+ // whether we should check for notifications of trickle_downs
+ // and file upload status.
+ // set by boinc_receive_trickle_down() and boinc_upload_file().
static volatile int heartbeat_giveup_count;
// interrupt count value at which to give up on client
#ifdef _WIN32
@@ -661,7 +667,6 @@ int boinc_get_status(BOINC_STATUS *s) {
//
static void send_trickle_up_msg() {
char buf[MSG_CHANNEL_SIZE];
- BOINCINFO("Sending Trickle Up Message");
if (standalone) return;
strcpy(buf, "");
if (have_new_trickle_up) {
@@ -671,6 +676,7 @@ static void send_trickle_up_msg() {
strcat(buf, "\n");
}
if (strlen(buf)) {
+ BOINCINFO("Sending Trickle Up Message");
if (app_client_shm->shm->trickle_up.send_msg(buf)) {
have_new_trickle_up = false;
have_new_upload_file = false;
@@ -1011,7 +1017,7 @@ static void handle_upload_file_status() {
}
}
-// handle trickle and file upload messages
+// handle trickle and file upload status messages
//
static void handle_trickle_down_msg() {
char buf[MSG_CHANNEL_SIZE];
@@ -1137,7 +1143,7 @@ static void timer_handler() {
if (options.check_heartbeat) {
handle_heartbeat_msg();
}
- if (options.handle_trickle_downs) {
+ if (handle_trickle_downs) {
handle_trickle_down_msg();
}
if (options.handle_process_control) {
@@ -1183,7 +1189,7 @@ static void timer_handler() {
update_app_progress(last_wu_cpu_time, last_checkpoint_cpu_time);
}
- if (options.handle_trickle_ups) {
+ if (have_new_trickle_up || have_new_upload_file) {
send_trickle_up_msg();
}
if (timer_callback) {
@@ -1349,7 +1355,6 @@ static int start_worker_signals() {
#endif
int boinc_send_trickle_up(char* variety, char* p) {
- if (!options.handle_trickle_ups) return ERR_NO_OPTION;
FILE* f = boinc_fopen(TRICKLE_UP_FILENAME, "wb");
if (!f) return ERR_FOPEN;
fprintf(f, "%s\n", variety);
@@ -1438,7 +1443,7 @@ int boinc_receive_trickle_down(char* buf, int len) {
std::string filename;
char path[MAXPATHLEN];
- if (!options.handle_trickle_downs) return false;
+ handle_trickle_downs = true;
if (have_trickle_down) {
relative_to_absolute("", path);
@@ -1466,10 +1471,15 @@ int boinc_upload_file(std::string& name) {
if (!f) return ERR_FOPEN;
have_new_upload_file = true;
fclose(f);
+
+ // file upload status messages are on same channel as
+ // trickle down messages, so listen to that channel
+ //
+ handle_trickle_downs = true;
+
return 0;
}
-
int boinc_upload_status(std::string& name) {
for (unsigned int i=0; i