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

TEvHttpServer don't work under cygwin ( or windows)

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Major
    • Resolution: Unresolved
    • 0.10.0, 0.11.0, 0.12.0, 0.13.0
    • None
    • C++ - Library
    • None
    • Tested: cygwin64 under windows 10, may affect all cygwin or windows systems

    • Patch Available
    • Patch

    Description

      In my environment, TEvHttpServer don't work under Cygwin64 under window 10.

      Call to evhttp_bind_socket() fails to bind any network interface under windows, since a NULL pointer of the ip address string parameter is used. By contrast, in the examples of libevent, the string "0.0.0.0" is used and can bind successfully under all known platforms.

      Example:

      test.thrift

      namespace cpp test
      service Test {
        i32 foo();
      }
      
      thrift --gen cpp:cob_style test.thrift
      

      evhttp_thrift_server.cpp:

      #include <thrift/protocol/TBinaryProtocol.h>
      #include <thrift/async/TAsyncProtocolProcessor.h>
      #include <thrift/async/TEvhttpServer.h>
      #include "gen-cpp/Test.h"
      
      using apache::thrift::protocol::TBinaryProtocolFactory;
      using apache::thrift::protocol::TProtocolFactory;
      using apache::thrift::async::TEvhttpServer;
      using apache::thrift::async::TAsyncProcessor;
      using apache::thrift::async::TAsyncBufferProcessor;
      using apache::thrift::async::TAsyncProtocolProcessor;
      using namespace ::apache::thrift;
      using namespace ::test;
      
      class TestHandle : public TestCobSvIf {
      public:
        void foo(thrift::stdcxx::function <void(int32_t const& _ret)> cob) { return cob(0); }
      }
      
      int main() {
        stdcxx::shared_ptr<TestHandle> service(new TestHandle());
        stdcxx::shared_ptr<TAsyncProcessor> proc(new TestAsyncProcessor(service));
        stdcxx::shared_ptr<TProtocolFactory> pfact(new TBinaryProtocolFactory());
        stdcxx::shared_ptr<TAsyncBufferProcessor> bufproc(new TAsyncProtocolProcessor(proc, pfact));
        stdcxx::shared_ptr<TEvhttpServer> server(new TEvhttpServer(bufproc, 8000));
        server->serve();
        return 0;
      }
      

      Compile and run it, everything seems ok, but a "netstat -a" on a new terminal window can tell that there is no service binding to port 8000 of any network interfaces.

      Attachments

        1. TEvHttpServer.patch
          0.5 kB
          Zhenghui Zhou

        Activity

          People

            Unassigned Unassigned
            zhouzhenghui Zhenghui Zhou
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated: