don't give up on an HTTP rhizome transfer on an empty read if

the error is EAGAIN.
This commit is contained in:
gardners 2013-08-25 17:35:34 +09:30
parent 0d85d60566
commit 53c9a406e1

View File

@ -1423,6 +1423,7 @@ void rhizome_fetch_poll(struct sched_ent *alarm)
/* Keep reading until we have the promised amount of data */ /* Keep reading until we have the promised amount of data */
unsigned char buffer[8192]; unsigned char buffer[8192];
sigPipeFlag = 0; sigPipeFlag = 0;
errno=0;
int bytes = read_nonblock(slot->alarm.poll.fd, buffer, sizeof buffer); int bytes = read_nonblock(slot->alarm.poll.fd, buffer, sizeof buffer);
/* If we got some data, see if we have found the end of the HTTP request */ /* If we got some data, see if we have found the end of the HTTP request */
if (bytes > 0) { if (bytes > 0) {
@ -1434,10 +1435,12 @@ void rhizome_fetch_poll(struct sched_ent *alarm)
schedule(&slot->alarm); schedule(&slot->alarm);
return; return;
} else { } else {
if (config.debug.rhizome_rx) if (errno!=EAGAIN) {
DEBUGF("Empty read, closing connection: received %"PRId64" of %"PRId64" bytes", if (config.debug.rhizome_rx)
slot->write_state.file_offset,slot->write_state.file_length); DEBUGF("Empty read, closing connection: received %"PRId64" of %"PRId64" bytes",
rhizome_fetch_switch_to_mdp(slot); slot->write_state.file_offset,slot->write_state.file_length);
rhizome_fetch_switch_to_mdp(slot);
}
return; return;
} }
if (sigPipeFlag) { if (sigPipeFlag) {