diff --git a/lib/advio.c b/lib/advio.c index df81d3ab9..33f6441e6 100644 --- a/lib/advio.c +++ b/lib/advio.c @@ -41,19 +41,36 @@ static int advio_trace(CURL *handle, curl_infotype type, char *data, size_t size, void *userp) { - char *nl; + const char *text; switch (type) { case CURLINFO_TEXT: - nl = strchr(data, '\n'); - if (nl) - *nl = 0; - - debug(LOG_ADVIO | 10, "%s", data); + text = "info"; + break; + case CURLINFO_HEADER_OUT: + text = "send header"; + break; + case CURLINFO_DATA_OUT: + text = "send data"; + break; + case CURLINFO_HEADER_IN: + text = "recv header"; + break; + case CURLINFO_DATA_IN: + text = "recv data"; + break; + case CURLINFO_SSL_DATA_IN: + text = "recv SSL data"; + break; + case CURLINFO_SSL_DATA_OUT: + text = "send SSL data"; + break; default: /* in case a new one is introduced to shock us */ return 0; } - + + debug(LOG_ADVIO | 5, "CURL: %s: %.*s", text, (int) size-1, data); + return 0; } @@ -333,9 +350,9 @@ int aupload(AFILE *af, int resume) curl_easy_getinfo(af->curl, CURLINFO_TOTAL_TIME, &total_time); char *total_bytes_human = advio_human_size(total_bytes, buf[0], sizeof(buf[0])); - char *total_time_human = advio_human_time(total_time, buf[1], sizeof(buf[1])); + char *total_time_human = advio_human_time(total_time, buf[1], sizeof(buf[1])); - info("Finished uploaded of %s in %s", total_bytes_human, total_time_human); + info("Finished upload of %s in %s", total_bytes_human, total_time_human); af->uploaded += total_bytes; @@ -376,7 +393,7 @@ int adownload(AFILE *af, int resume) curl_easy_getinfo(af->curl, CURLINFO_TOTAL_TIME, &total_time); char *total_bytes_human = advio_human_size(total_bytes, buf[0], sizeof(buf[0])); - char *total_time_human = advio_human_time(total_time, buf[1], sizeof(buf[1])); + char *total_time_human = advio_human_time(total_time, buf[1], sizeof(buf[1])); info("Finished download of %s in %s", total_bytes_human, total_time_human); @@ -386,7 +403,7 @@ int adownload(AFILE *af, int resume) res = curl_easy_getinfo(af->curl, CURLINFO_RESPONSE_CODE, &code); if (res) return -1; - + switch (code) { case 0: case 200: goto exist; @@ -408,7 +425,7 @@ int adownload(AFILE *af, int resume) return -1; default: - error("ADVIO: Failed to fetch file: %s: %s", af->uri, curl_easy_strerror(res)); + error("ADVIO: Failed to download file: %s: %s", af->uri, curl_easy_strerror(res)); return -1; } diff --git a/lib/node.c b/lib/node.c index 884393f49..6ff8a666b 100644 --- a/lib/node.c +++ b/lib/node.c @@ -157,7 +157,7 @@ int node_destroy(struct node *n) int node_read(struct node *n, struct sample *smps[], unsigned cnt) { - int nread = 0; + int readd, nread = 0; if (!n->_vt->read) return -1; @@ -165,11 +165,14 @@ int node_read(struct node *n, struct sample *smps[], unsigned cnt) /* Send in parts if vector not supported */ if (n->_vt->vectorize > 0 && n->_vt->vectorize < cnt) { while (cnt - nread > 0) { - nread += n->_vt->read(n, &smps[nread], MIN(cnt - nread, n->_vt->vectorize)); + readd = n->_vt->read(n, &smps[nread], MIN(cnt - nread, n->_vt->vectorize)); + nread += readd; + debug(LOG_NODES | 5, "Received %u samples from node %s", readd, node_name(n)); } } else { nread = n->_vt->read(n, smps, cnt); + debug(LOG_NODES | 5, "Received %u samples from node %s", nread, node_name(n)); } for (int i = 0; i < nread; i++) @@ -180,18 +183,22 @@ int node_read(struct node *n, struct sample *smps[], unsigned cnt) int node_write(struct node *n, struct sample *smps[], unsigned cnt) { - int nsent = 0; + int sent, nsent = 0; if (!n->_vt->write) return -1; /* Send in parts if vector not supported */ if (n->_vt->vectorize > 0 && n->_vt->vectorize < cnt) { - while (cnt - nsent > 0) - nsent += n->_vt->write(n, &smps[nsent], MIN(cnt - nsent, n->_vt->vectorize)); + while (cnt - nsent > 0) { + sent = n->_vt->write(n, &smps[nsent], MIN(cnt - nsent, n->_vt->vectorize)); + nsent += sent; + debug(LOG_NODES | 5, "Sent %u samples to node %s", sent, node_name(n)); + } } else { nsent = n->_vt->write(n, smps, cnt); + debug(LOG_NODES | 5, "Sent %u samples to node %s", nsent, node_name(n)); } return nsent;