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

TServerSocket fix for MSVC

    XMLWordPrintableJSON

Details

    • Patch Available

    Description

      The changes to compile the Thrift library for Visual Studio #ifdef'd out the bind section in TServerSocket.cpp. This prevented TSimpleServer, TThreadedServer and anything that uses TServerSocket transport from functioning. The server side reports the following error due to 'bind' being skipped:
      TSimpleServer::run() listen(): Could not listen: errno = 10022

      The bind overload unfortunately results in a conflict with Microsoft's libraries. TServerSocket uses namespace std which pulls in the tr1 overloads of bind. The template definitions seem to always 'win' over any other overloads. I was unsuccessful creating an overload of bind in the windows config.h file so had to #ifdef the bind call. Microsoft is aware of the issue:
      http://connect.microsoft.com/VisualStudio/feedback/details/500364/how-to-avoid-conflicts-between-tr1-bind-and-winsock-bind-function

      It does the job though I'm not too proud of using #ifdefs. One possible way around this is to declare a wrapper function as such in config.h:

      inline int thriftbind(SOCKET socket, sockaddr* name, int namelen)
      {
      return ::bind(socket, name, namelen);
      }

      The Unix-style version would need to be declared in the appropriate file as well.

      Attachments

        1. TServerSocket_bind.patch
          2 kB
          Peace C
        2. TServerSocket_bind_12-8-2011.patch
          2 kB
          Peace C

        Activity

          People

            Unassigned Unassigned
            peace Peace C
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: