diff --git a/checkin_notes b/checkin_notes index ce58118025..28e5db60d4 100644 --- a/checkin_notes +++ b/checkin_notes @@ -6386,3 +6386,14 @@ David 22 Sept 2011 client/ client_state.cpp cs_trickle.cpp,h + +David 22 Sept 2011 + - client: replicated trickles. Seems to be working now. + - client: added config option + + client/ + cs_trickle.cpp + gui_http.cpp,h + httl_curl.cpp + lib/ + cc_config.cpp,h diff --git a/client/cs_trickle.cpp b/client/cs_trickle.cpp index 577f087b28..f4950d5522 100644 --- a/client/cs_trickle.cpp +++ b/client/cs_trickle.cpp @@ -201,10 +201,18 @@ void send_replicated_trickles(PROJECT* p, const char* msg, char* result_name, in for (unsigned int i=0; itrickle_up_ops.size(); i++) { TRICKLE_UP_OP *t = p->trickle_up_ops[i]; if (t->gui_http->is_busy()) { - msg_printf(p, MSG_INFO, "TRICKLE CHANNEL IS BUSY"); + if (log_flags.trickle_debug) { + msg_printf(p, MSG_INFO, + "[trickle] Trickle channel to %s is busy", t->url.c_str() + ); + } return; } - msg_printf(p, MSG_INFO, "SENDING REPLICATED TRICKLE TO %s", t->url.c_str()); + if (log_flags.trickle_debug) { + msg_printf(p, MSG_INFO, + "[trickle] Sending replicated trickle to %s", t->url.c_str() + ); + } t->do_rpc(buf); } } @@ -257,11 +265,15 @@ void update_trickle_up_urls(PROJECT* p, vector &urls) { } int TRICKLE_UP_OP::do_rpc(const char* msg) { - req_buf = strdup(msg); + int n = strlen(msg)+1; + if (n<65536) n = 65536; + req_buf = (char*)malloc(n); + strcpy(req_buf, msg); int retval = gui_http->do_rpc_post_str( - this, const_cast(url.c_str()), req_buf + this, const_cast(url.c_str()), req_buf, n ); if (retval) { + msg_printf(0, MSG_INTERNAL_ERROR, "Trickle-up post failed: %d", retval); free(req_buf); req_buf = 0; } @@ -282,7 +294,11 @@ int parse_trickle_up_urls(XML_PARSER& xp, std::vector& urls) { } void TRICKLE_UP_OP::handle_reply(int http_op_retval) { - msg_printf(0, MSG_INFO, "TRICKLE RETVAL: %d", http_op_retval); + if (log_flags.trickle_debug) { + msg_printf(0, MSG_INFO, + "[trickle] Replicated trickle done; retval %d", http_op_retval + ); + } if (req_buf) { free(req_buf); req_buf = 0; diff --git a/client/gui_http.cpp b/client/gui_http.cpp index 42fd19f3b9..677dc5d83f 100644 --- a/client/gui_http.cpp +++ b/client/gui_http.cpp @@ -73,11 +73,11 @@ int GUI_HTTP::do_rpc_post( return 0; } -int GUI_HTTP::do_rpc_post_str(GUI_HTTP_OP* op, char* url, char* req_buf) { +int GUI_HTTP::do_rpc_post_str(GUI_HTTP_OP* op, char* url, char* req_buf, int len) { if (gui_http_state != GUI_HTTP_STATE_IDLE) { return ERR_RETRY; } - int retval = http_op.init_post2(url, req_buf, 0, NULL, 0); + int retval = http_op.init_post2(url, req_buf, len, NULL, 0); if (retval) return retval; gstate.http_ops->insert(&http_op); gui_http_op = op; diff --git a/client/gui_http.h b/client/gui_http.h index a28a456e0d..a6cacc42d5 100644 --- a/client/gui_http.h +++ b/client/gui_http.h @@ -70,7 +70,7 @@ struct GUI_HTTP { const char* input_file, const char* output_file, bool is_background ); - int do_rpc_post_str(GUI_HTTP_OP*, char* url, char* req); + int do_rpc_post_str(GUI_HTTP_OP*, char* url, char* req, int len); bool poll(); inline bool is_busy() { return (gui_http_state == GUI_HTTP_STATE_BUSY); diff --git a/client/http_curl.cpp b/client/http_curl.cpp index 80e8aad675..4607a070aa 100644 --- a/client/http_curl.cpp +++ b/client/http_curl.cpp @@ -335,6 +335,7 @@ int HTTP_OP::init_post2( init(); req1 = r1; req1_len = r1_len; + content_length = 0; if (in) { safe_strcpy(infile, in); file_offset = offset; diff --git a/lib/cc_config.cpp b/lib/cc_config.cpp index 935ae86fe7..0ac38c4036 100644 --- a/lib/cc_config.cpp +++ b/lib/cc_config.cpp @@ -90,6 +90,7 @@ int LOG_FLAGS::parse(XML_PARSER& xp) { if (xp.parse_bool("statefile_debug", statefile_debug)) continue; if (xp.parse_bool("task_debug", task_debug)) continue; if (xp.parse_bool("time_debug", time_debug)) continue; + if (xp.parse_bool("trickle_debug", trickle_debug)) continue; if (xp.parse_bool("unparsed_xml", unparsed_xml)) continue; if (xp.parse_bool("work_fetch_debug", work_fetch_debug)) continue; if (xp.parse_bool("notice_debug", notice_debug)) continue; @@ -133,6 +134,7 @@ int LOG_FLAGS::write(MIOFILE& out) { " %d\n" " %d\n" " %d\n" + " %d\n" " %d\n" " %d\n" " %d\n" @@ -169,6 +171,7 @@ int LOG_FLAGS::write(MIOFILE& out) { std_debug ? 1 : 0, task_debug ? 1 : 0, time_debug ? 1 : 0, + trickle_debug ? 1 : 0, unparsed_xml ? 1 : 0, work_fetch_debug ? 1 : 0, notice_debug ? 1 : 0 diff --git a/lib/cc_config.h b/lib/cc_config.h index b97c006072..35e86f97ad 100644 --- a/lib/cc_config.h +++ b/lib/cc_config.h @@ -101,6 +101,8 @@ struct LOG_FLAGS { // task start and control details, and when apps checkpoint bool time_debug; // changes in on_frac, active_frac, connected_frac + bool trickle_debug; + // show trickle messages bool unparsed_xml; // show unparsed XML lines bool work_fetch_debug;