fixed file upload bug

svn path=/trunk/boinc/; revision=4808
This commit is contained in:
David Anderson 2004-12-10 04:18:40 +00:00
parent 3c3a9eebdf
commit b4aeaca73d
4 changed files with 44 additions and 24 deletions

View File

@ -302,7 +302,7 @@ int boinc_report_app_status(
double checkpoint_cpu_time,
double fraction_done
) {
char msg_buf[MSG_CHANNEL_SIZE], buf[256];
char msg_buf[MSG_CHANNEL_SIZE];
sprintf(msg_buf,
"<current_cpu_time>%10.4f</current_cpu_time>\n"
"<checkpoint_cpu_time>%.15e</checkpoint_cpu_time>\n"

View File

@ -20976,3 +20976,14 @@ David 9 Dec 2004
client/
http.C,h
net_xfer.C,h
David 9 Dec 2004
- Really fixed the above problem.
The HTTP code was looking at the wrong flag
(io_done, should have been io_ready)
in the POST2 case waiting for reply body
api/
boinc_api.C
client/
http.C,h

View File

@ -280,6 +280,8 @@ int HTTP_REPLY_HEADER::read_reply(int socket) {
}
// Read the contents of the socket into buf
// Read until EOF from socket, so only call this if you're
// sure the message is small
//
static int read_reply(int socket, char* buf, int len) {
int i, n;
@ -688,18 +690,18 @@ bool HTTP_OP_SET::poll(double) {
break;
}
switch (htp->http_op_type) {
case HTTP_OP_HEAD:
htp->init_head(new_url);
break;
case HTTP_OP_GET:
htp->init_get(new_url, htp->outfile, false);
break;
case HTTP_OP_POST:
htp->init_post(new_url, htp->infile, htp->outfile);
break;
case HTTP_OP_POST2:
htp->init_post2(new_url, htp->req1, htp->infile, htp->file_offset);
break;
case HTTP_OP_HEAD:
htp->init_head(new_url);
break;
case HTTP_OP_GET:
htp->init_get(new_url, htp->outfile, false);
break;
case HTTP_OP_POST:
htp->init_post(new_url, htp->infile, htp->outfile);
break;
case HTTP_OP_POST2:
htp->init_post2(new_url, htp->req1, htp->infile, htp->file_offset);
break;
}
// Open connection to the redirected server
@ -753,27 +755,32 @@ bool HTTP_OP_SET::poll(double) {
break;
case HTTP_OP_POST2:
htp->http_op_state = HTTP_STATE_REPLY_BODY;
htp->io_ready = false;
htp->io_done = false;
break;
}
}
break;
case HTTP_STATE_REPLY_BODY:
if (htp->io_done) {
action = true;
switch (htp->http_op_type) {
case HTTP_OP_POST2:
switch (htp->http_op_type) {
case HTTP_OP_POST2:
if (htp->io_ready) {
action = true;
read_reply(htp->socket, htp->req1, 256);
break;
default:
scope_messages.printf("HTTP_OP_SET::poll(): got reply body\n");
htp->http_op_state = HTTP_STATE_DONE;
htp->http_op_retval = 0;
}
break;
default:
if (htp->io_done) {
action = true;
fclose(htp->file);
htp->file = 0;
scope_messages.printf("HTTP_OP_SET::poll(): got reply body\n");
htp->http_op_state = HTTP_STATE_DONE;
htp->http_op_retval = 0;
break;
}
scope_messages.printf("HTTP_OP_SET::poll(): got reply body\n");
htp->http_op_state = HTTP_STATE_DONE;
htp->http_op_retval = 0;
}
break;
}

View File

@ -85,7 +85,9 @@ public:
int init_get(const char* url, char* outfile, bool del_old_file, double offset=0);
int init_post(const char* url, char* infile, char* outfile);
int init_post2(
const char* url, char* req1, char* infile, double offset
const char* url,
char* req1, // first part of request. ALSO USED FOR REPLY
char* infile, double offset // infile is NULL if no file sent
);
bool http_op_done();
};