if (!fd_closed(server.fd()))
commSetTimeout(server.fd(), Config.Timeout.read, tunnelTimeout, this);
- if (len < 0 || errcode)
+ if (errcode)
from.error (xerrno);
else if (len == 0 || fd_closed(to.fd())) {
comm_close(from.fd());
{
debugs(26, 3, "tunnelWriteServer: FD " << server.fd() << ", " << len << " bytes written");
- if (flag == COMM_ERR_CLOSING)
- return;
-
/* Error? */
- if (len < 0 || flag != COMM_OK) {
- server.error(xerrno); // may call comm_close
+ if (flag != COMM_OK) {
+ if (flag != COMM_ERR_CLOSING)
+ server.error(xerrno); // may call comm_close
return;
}
{
debugs(26, 3, "tunnelWriteClient: FD " << client.fd() << ", " << len << " bytes written");
- if (flag == COMM_ERR_CLOSING)
- return;
-
/* Error? */
- if (len < 0 || flag != COMM_OK) {
- client.error(xerrno); // may call comm_close
+ if (flag != COMM_OK) {
+ if (flag != COMM_ERR_CLOSING)
+ client.error(xerrno); // may call comm_close
return;
}
char *buf = urnState->reqbuf;
StoreIOBuffer tempBuffer;
- debugs(52, 3, "urnHandleReply: Called with size=" << (unsigned int)result.length << ".");
+ debugs(52, 3, "urnHandleReply: Called with size=" << result.length << ".");
- if (EBIT_TEST(urlres_e->flags, ENTRY_ABORTED) || result.length == 0 || result.flags.error < 0) {
+ if (EBIT_TEST(urlres_e->flags, ENTRY_ABORTED) || result.length == 0 || result.flags.error) {
urnHandleReplyError(urnState, urlres_e);
return;
}
void
WhoisState::readReply (int fd, char *aBuffer, size_t aBufferLength, comm_err_t flag, int xerrno)
{
- int do_next_read = 0;
-
/* Bail out early on COMM_ERR_CLOSING - close handlers will tidy up for us */
-
- if (flag == COMM_ERR_CLOSING) {
+ if (flag == COMM_ERR_CLOSING)
return;
- }
aBuffer[aBufferLength] = '\0';
debugs(75, 3, "whoisReadReply: FD " << fd << " read " << aBufferLength << " bytes");
debugs(75, 5, "{" << aBuffer << "}");
- if (flag == COMM_OK && aBufferLength > 0) {
- if (!dataWritten)
- setReplyToOK(entry);
-
- kb_incr(&statCounter.server.all.kbytes_in, aBufferLength);
-
- kb_incr(&statCounter.server.http.kbytes_in, aBufferLength);
-
- /* No range support, we always grab it all */
- dataWritten = true;
-
- entry->append(aBuffer, aBufferLength);
-
- entry->flush();
-
- do_next_read = 1;
- } else if (flag != COMM_OK || aBufferLength < 0) {
+ if (flag != COMM_OK) {
debugs(50, 2, "whoisReadReply: FD " << fd << ": read failure: " << xstrerror() << ".");
if (ignoreErrno(errno)) {
- do_next_read = 1;
+ comm_read(fd, aBuffer, BUFSIZ, whoisReadReply, this);
} else {
ErrorState *err;
err = errorCon(ERR_READ_ERROR, HTTP_INTERNAL_SERVER_ERROR, fwd->request);
err->xerrno = errno;
fwd->fail(err);
comm_close(fd);
- do_next_read = 0;
}
- } else {
- entry->timestampsSet();
- entry->flush();
-
- if (!EBIT_TEST(entry->flags, RELEASE_REQUEST))
- entry->setPublicKey();
+ return;
+ }
- fwd->complete();
+ if (aBufferLength > 0) {
+ if (!dataWritten)
+ setReplyToOK(entry);
- debugs(75, 3, "whoisReadReply: Done: " << entry->url() );
+ kb_incr(&statCounter.server.all.kbytes_in, aBufferLength);
+ kb_incr(&statCounter.server.http.kbytes_in, aBufferLength);
- comm_close(fd);
+ /* No range support, we always grab it all */
+ dataWritten = true;
+ entry->append(aBuffer, aBufferLength);
+ entry->flush();
- do_next_read = 0;
+ comm_read(fd, aBuffer, BUFSIZ, whoisReadReply, this);
+ return;
}
- if (do_next_read)
- comm_read(fd, aBuffer, BUFSIZ, whoisReadReply, this);
+ /* no bytes read. stop reading */
+ entry->timestampsSet();
+ entry->flush();
+
+ if (!EBIT_TEST(entry->flags, RELEASE_REQUEST))
+ entry->setPublicKey();
+
+ fwd->complete();
+ debugs(75, 3, "whoisReadReply: Done: " << entry->url());
+ comm_close(fd);
}
static void