Uploaded image for project: 'Thrift'
  1. Thrift
  2. THRIFT-1642

Miscalculation lead to throw unexpected "TTransportException::TIMED_OUT"(or called "EAGAIN (timed out)") exception

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Critical
    • Resolution: Fixed
    • Affects Version/s: 0.8
    • Fix Version/s: 0.9.3
    • Component/s: C++ - Library
    • Labels:
      None
    • Environment:

      GNU/Linux x86_64

      Description

      In function 'uint32_t TSocket::read(uint8_t* buf, uint32_t len)', there's an miscalculation which can lead to wrong judgment:

      struct timeval begin;
      gettimeofday(&begin, NULL);
      //
      // do some thing
      //
      struct timeval end;
      gettimeofday(&end, NULL);
      uint32_t readElapsedMicros = (((end.tv_sec - begin.tv_sec) * 1000 * 1000)
      + (((uint64_t)(end.tv_usec - begin.tv_usec))));

      'readElapsedMicros' will be very large when 'end.tv_usec < begin.tv_usec'.
      This will lead to throw unexpected "TTransportException::TIMED_OUT"(or called "EAGAIN (timed out)") exception sometimes.

      Besides,
      (1)I don't think the "usleep(50);" call in the same function above is necessary, I think delete this call could improve performance.
      (2)I don't know why 'readElapsedMicros' compare with 'eagainThresholdMicros', which is not the value (recvTimeout_*1000), but:
      eagainThresholdMicros = (recvTimeout_*1000)/ ((maxRecvRetries_>0) ? maxRecvRetries_ : 2);
      can anyone tell me someting about this? Thank you!

        Attachments

        1. TSocket.cpp.patch
          1 kB
          catxl

          Activity

            People

            • Assignee:
              jking3 James E. King III
              Reporter:
              catxl catxl
            • Votes:
              0 Vote for this issue
              Watchers:
              7 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Time Tracking

                Estimated:
                Original Estimate - 1h
                1h
                Remaining:
                Remaining Estimate - 1h
                1h
                Logged:
                Time Spent - Not Specified
                Not Specified