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

TSocket read/peek fails on OS X

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 0.1
    • 0.2
    • C++ - Library
    • None
    • Mac OS X 10.5.6

    • Patch Available

    Description

      Both TSocket::read() and TSocket::peek() have code that detects ECONNRESET in a FreeBSD environment and interprets it to mean that the socket was closed by the other side. This code was added by THRIFT-96.

      When Thrift is used under OS X, the server often sees the ECONNRESET error when the client has simply shutdown the socket. This makes sense since OS X is derived from FreeBSD.

      The attached patch modifies the read() and peek() routines to treat ECONNRESET as close() for OS X, just like it does for other FreeBSD versions. It also moves the read() error message display so that no error message is displayed when ECONNRESET is interpreted as close.

      Just past the error message, I left the test for ECONNRESET without making it depend on the _FREEBSD_ and _MACH_ macro definitions. This means that if a real error occurs on a FreeBSD-based system, there will be an extra check for ECONNRESET. I don't think this is a problem because you're on the way to throwing an exception anyway in that case, so the performance penalty of checking for ECONNRESET seems minimal. It also keeps the logic simpler.

      Patrick Schlangen gets credit for realizing that the _FREEBSD_ fix applied to OS X as well.

      Attachments

        1. 497-TSocket.cpp.patch
          1 kB
          Rush Manbert

        Issue Links

          Activity

            People

              Unassigned Unassigned
              rush Rush Manbert
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: