Commit 8f618288 authored by Shah Rinku's avatar Shah Rinku

kvcache read offload: mtcp client code

parent 09065428
......@@ -297,8 +297,9 @@ DownloadComplete(thread_context_t ctx, int sockid, struct wget_vars *wv)
fprintf(stderr, "Response size set to %lu\n", response_size);
} else {
if (wv->recv != response_size) {
fprintf(stderr, "Response size mismatch! mine: %lu, theirs: %lu\n",
wv->recv, response_size);
//@rinku: DEBUG THIS
//fprintf(stderr, "Response size mismatch! mine: %lu, theirs: %lu\n",
// wv->recv, response_size);
}
}
tdiff = (wv->t_end.tv_sec - wv->t_start.tv_sec) * 1000000 +
......@@ -341,17 +342,20 @@ HandleReadEvent(thread_context_t ctx, int sockid, struct wget_vars *wv)
wv->headerset, wv->header_len, wv->file_len);
pbuf = buf;
//printf("BUF: %s\n", buf);
if (!wv->headerset) {
copy_len = MIN(rd, HTTP_HEADER_LEN - wv->resp_len);
memcpy(wv->response + wv->resp_len, buf, copy_len);
wv->resp_len += copy_len;
wv->header_len = find_http_header(wv->response, wv->resp_len);
//printf("wv->header_len: %d wv->resp_len: %d wv->response: %s \n", wv->header_len, wv->resp_len, wv->response);
if (wv->header_len > 0) {
wv->response[wv->header_len] = '\0';
wv->file_len = http_header_long_val(wv->response,
CONTENT_LENGTH_HDR, sizeof(CONTENT_LENGTH_HDR) - 1);
if (wv->file_len < 0) {
/* failed to find the Content-Length field */
//printf("Failed to find Content-Length field\n");
wv->recv += rd;
rd = 0;
CloseConnection(ctx, sockid);
......@@ -377,6 +381,7 @@ HandleReadEvent(thread_context_t ctx, int sockid, struct wget_vars *wv)
" Data: \n%s\n", ctx->core, sockid, wv->response);
fflush(stdout);
#endif
printf("Failed to parse response header.\n");
wv->recv += rd;
rd = 0;
ctx->stat.errors++;
......@@ -410,7 +415,7 @@ HandleReadEvent(thread_context_t ctx, int sockid, struct wget_vars *wv)
break;
}
}
//printf("rd: %d\n",rd);
if (rd > 0) {
if (wv->header_len && (wv->recv >= wv->header_len + wv->file_len)) {
TRACE_APP("Socket %d Done Write: "
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment