Commit 67ea8b77 authored by Thai Nguyen's avatar Thai Nguyen
Browse files

Reduce LOGs in case of Peer is slow by LOG when time out happens

parent 111c6e40
Loading
Loading
Loading
Loading
+8 −3
Original line number Diff line number Diff line
@@ -39,7 +39,6 @@ bool ReaderWriter::Read(void *buf, size_t n, int* err) {
        if (status == -1 && errno == EINTR) {
            continue;
        } else if (status == -1 && (errno == EAGAIN || errno == EWOULDBLOCK )) {
	    LOG(INFO) << "Peer is slow to transmit";
	    //Wait for 500us;
	    usleep(500);
            socket_timeout++;
@@ -55,7 +54,10 @@ bool ReaderWriter::Read(void *buf, size_t n, int* err) {
        }
        bytes_read += status;
    }

    if (socket_timeout >= SOCKET_TIMEOUT) {
        LOG(INFO) << "Peer is slow to transmit";
        return false;
    }
    return true;
}

@@ -68,7 +70,6 @@ bool ReaderWriter::Write(const void *buf, size_t n) {
        if (status == -1 && errno == EINTR) {
            continue;
        } else if (status == -1 && (errno == EAGAIN || errno == EWOULDBLOCK)) {
	    LOG(INFO) << " Peer is slow to receive";
	    usleep(500);
	    socket_timeout++;
            continue;
@@ -82,6 +83,10 @@ bool ReaderWriter::Write(const void *buf, size_t n) {
        }
        bytes_written += status;
    }
    if (socket_timeout >= SOCKET_TIMEOUT) {
        LOG(INFO) << " Peer is slow to receive";
        return false;
    }

    return true;
}