You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@thrift.apache.org by "Zhenghui Zhou (Jira)" <ji...@apache.org> on 2019/11/24 05:13:00 UTC

[jira] [Created] (THRIFT-5028) TEvHttpServer don't work under cygwin ( or windows)

Zhenghui Zhou created THRIFT-5028:
-------------------------------------

             Summary: TEvHttpServer don't work under cygwin ( or windows)
                 Key: THRIFT-5028
                 URL: https://issues.apache.org/jira/browse/THRIFT-5028
             Project: Thrift
          Issue Type: Bug
          Components: C++ - Library
    Affects Versions: 0.13.0, 0.12.0, 0.11.0, 0.10.0
         Environment: Tested: cygwin64 under windows 10, may affect all cygwin or windows systems
            Reporter: Zhenghui Zhou
         Attachments: TEvHttpServer.patch

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
{code:java}
namespace cpp test
service Test {
  i32 foo();
}
{code}
{code:java}
thrift --gen cpp:cob_style test.thrift
{code}
evhttp_thrift_server.cpp:
{code:java}
#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;
}
{code}
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.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)