Giter Site home page Giter Site logo

facebook / wangle Goto Github PK

View Code? Open in Web Editor NEW
3.0K 172.0 531.0 8.08 MB

Wangle is a framework providing a set of common client/server abstractions for building services in a consistent, modular, and composable way.

License: Apache License 2.0

C++ 71.16% CMake 7.27% Python 21.27% C 0.30%

wangle's Introduction

Support Ukraine Travis Build Status CI Status

Wangle

C++ networking library

Wangle is a library that makes it easy to build protocols, application clients, and application servers.

It's like Netty + Finagle smooshed together, but in C++

Building and Installing

The main dependencies are:

Once folly is installed, run the following inside the wangle directory to build, test, and install wangle:

cmake .
make
ctest
sudo make install

Tutorial

There is a tutorial here that explains the basics of Wangle and shows how to build an echo server/client.

Examples

See the examples/ directory for some example Wangle servers and clients

License

Wangle is Apache 2.0-licensed.

Contributing

See the CONTRIBUTING file for how to help out.

Documentation

Wangle interfaces are asynchronous. Interfaces are currently based on Futures, but we're also exploring how to support fibers

Client / Server abstraction #

You're probably familiar with Java's Netty, or Python's twisted, or similar libraries.

It is built on top of folly/async/io, so it's one level up the stack from that (or similar abstractions like boost::asio)

ServerBootstrap - easily manage creation of threadpools and pipelines

ClientBootstrap - the same for clients

Pipeline - set up a series of handlers that modify your socket data

Request / Response abstraction #

This is roughly equivalent to the Finagle library.

Aims to provide easy testing, load balancing, client pooling, retry logic, etc. for any request/response type service - i.e. thrift, http, etc.

Service - a matched interface between client/server. A server will implement this interface, and a client will call in to it. These are protocol-specific

ServiceFilter - a generic filter on a service. Examples: stats, request timeouts, rate limiting

ServiceFactory - A factory that creates client connections. Any protocol specific setup code goes here

ServiceFactoryFilter - Generic filters that control how connections are created. Client examples: load balancing, pooling, idle timeouts, markdowns, etc.

ServerBootstrap

Easily create a new server

ServerBootstrap does the work to set up one or multiple acceptor threads, and one or multiple sets of IO threads. The thread pools can be the same. SO_REUSEPORT is automatically supported for multiple accept threads. tcp is most common, although udp is also supported.

Methods #

childPipeline(PipelineFactory<Pipeline>)

Sets the pipeline factory for each new connection. One pipeline per connection will be created.

group(IOThreadPoolExecutor accept, IOThreadPoolExecutor io)

Sets the thread pools for accept and io thread pools. If more than one thread is in the accept group, SO_REUSEPORT is used. Defaults to a single accept thread, and one io thread per core.

bind(SocketAddress),bind(port)

Binds to a port. Automatically starts to accept after bind.

stop()

Stops listening on all sockets.

join()

Joins all threadpools - all current reads and writes will be completed before this method returns.

NOTE: however that both accept and io thread pools will be stopped using this method, so the thread pools can't be shared, or care must be taken using shared pools during shutdown.

waitForStop()

Waits for stop() to be called from another thread.

Other methods #

channelFactory(ServerSocketFactory)

Sets up the type of server. Defaults to TCP AsyncServerSocket, but AsyncUDPServerSocket is also supported to receive udp messages. In practice, ServerBootstrap is only useful for udp if you need to multiplex the messages across many threads, or have TCP connections going on at the same time, etc. Simple usages of AsyncUDPSocket probably don't need the complexity of ServerBootstrap.

pipeline(PipelineFactory<AcceptPipeline>)

This pipeline method is used to get the accepted socket (or udp message) before it has been handed off to an IO thread. This can be used to steer the accept thread to a particular thread, or for logging.

See also AcceptRoutingHandler and RoutingDataHandler for additional help in reading data off of the accepted socket before it gets attached to an IO thread. These can be used to hash incoming sockets to specific threads.

childHandler(AcceptorFactory)

Previously facebook had lots of code that used AcceptorFactories instead of Pipelines, this is a method to support this code and be backwards compatible. The AcceptorFactory is responsible for creating acceptors, setting up pipelines, setting up AsyncSocket read callbacks, etc.

Examples #

A simple example:

ServerBootstrap<TelnetPipeline> server;                                                                                                      
server.childPipeline(std::make_shared<TelnetPipelineFactory>());                                                                             
server.bind(FLAGS_port);                                                                                                                     
server.waitForStop();

ClientBootstrap

Create clients easily

ClientBootstrap is a thin wrapper around AsyncSocket that provides a future interface to the connect callback, and a Pipeline interface to the read callback.

Methods #

group(IOThreadPoolExecutor)

Sets the thread or group of threads where the IO will take place. Callbacks are also made on this thread.

bind(port)

Optionally bind to a specific port

Future<Pipeline*> connect(SocketAddress)

Connect to the selected address. When the future is complete, the initialized pipeline will be returned.

NOTE: future.cancel() can be called to cancel an outstanding connection attempt.

pipelineFactory(PipelineFactory<Pipeline>)

Set the pipeline factory to use after a connection is successful.

Example #

ClientBootstrap<TelnetPipeline> client;
client.group(std::make_shared<folly::wangle::IOThreadPoolExecutor>(1));
client.pipelineFactory(std::make_shared<TelnetPipelineFactory>());
// synchronously wait for the connect to finish
auto pipeline = client.connect(SocketAddress(FLAGS_host,FLAGS_port)).get();

// close the pipeline when finished pipeline->close();

Pipeline

Send your socket data through a series of tubes

A Pipeline is a series of Handlers that intercept inbound or outbound events, giving full control over how events are handled. Handlers can be added dynamically to the pipeline.

When events are called, a Context* object is passed to the Handler - this means state can be stored in the context object, and a single instantiation of any individual Handler can be used for the entire program.

Netty's documentation: ChannelHandler

Usually, the bottom of the Pipeline is a wangle::AsyncSocketHandler to read/write to a socket, but this isn't a requirement.

A pipeline is templated on the input and output types:

EventBase base_;
Pipeline<IOBufQueue&, std::unique_ptr<IOBuf>> pipeline;
pipeline.addBack(AsyncSocketHandler(AsyncSocket::newSocket(eventBase)));

The above creates a pipeline and adds a single AsyncSocket handler, that will push read events through the pipeline when the socket gets bytes. Let's try handling some socket events:

class MyHandler : public InboundHandler<folly::IOBufQueue&> {
 public:

void read(Context* ctx, folly::IOBufQueue& q) override { IOBufQueue data;
if (q.chainLength() >= 4) { data.append(q.split(4)); ctx->fireRead(data); } } };

This handler only handles read (inbound) data, so we can inherit from InboundHandler, and ignore the outbound type (so the ordering of inbound/outbound handlers in your pipeline doesn't matter). It checks if there are at least 4 bytes of data available, and if so, passes them on to the next handler. If there aren't yet four bytes of data available, it does nothing, and waits for more data.

We can add this handler to our pipeline like so:

pipeline.addBack(MyHandler());

and remove it just as easily:

pipeline.remove<MyHandler>();

StaticPipeline #

Instantiating all these handlers and pipelines can hit the allocator pretty hard. There are two ways to try to do fewer allocations. StaticPipeline allows all the handlers, and the pipeline, to be instantiated all in the same memory block, so we only hit the allocator once.

The other option is to allocate the handlers once at startup, and reuse them in many pipelines. This means all state has to be saved in the HandlerContext object instead of the Handler itself, since each handler can be in multiple pipelines. There is one context per pipeline to get around this limitation.

Built-in handlers

The stuff that comes with the box

Byte to byte handlers #

AsyncSocketHandler #

This is almost always the first handler in the pipeline for clients and servers - it connects an AsyncSocket to the pipeline. Having it as a handler is nice, because mocking it out for tests becomes trivial.

OutputBufferingHandler #

Output is buffered and only sent once per event loop. This logic is exactly what is in ThriftServer, and very similar to what exists in proxygen - it can improve throughput for small writes by up to 300%.

EventBaseHandler #

Putting this right after an AsyncSocketHandler means that writes can happen from any thread, and eventBase->runInEventBaseThread() will automatically be called to put them in the correct thread. It doesn't intrinsically make the pipeline thread-safe though, writes from different threads may be interleaved, other handler stages must be only used from one thread or be thread safe, etc.

In addition, reads are still always called on the eventBase thread.

Codecs #

FixedLengthFrameDecoder #

A decoder that splits received IOBufs by a fixed number of bytes. Used for fixed-length protocols

LengthFieldPrepender #

Prepends a fixed-length field length. Field length is configurable.

LengthFieldBasedFrameDecoder #

The receiving portion of LengthFieldPrepender - decodes based on a fixed frame length, with optional header/tailer data sections.

LineBasedFrameDecoder #

Decodes by line (with optional ending detection types), to be used for text-based protocols

StringCodec #

Converts from IOBufs to std::strings and back for text-based protocols. Must be used after one of the above frame decoders

Services

How to add a new protocol

Finagle's documentation on Services is highly recommended

Services #

A Pipeline was read() and write() methods - it streams bytes in one or both directions. write() returns a future, but the future is set when the bytes are successfully written. Using pipeline there is no easy way to match up requests and responses for RPC.

A Service is an RPC abstraction - Both clients and servers implement the interface. Servers implement it by handling the request. Clients implement it by sending the request to the server to complete.

A Dispatcher is the adapter between the Pipeline and Service that matches up the requests and responses. There are several built in Dispatchers, however if you are doing anything advanced, you may need to write your own.

Because both clients and servers implement the same interface, mocking either clients or servers is trivially easy.

ServiceFilters #

ServiceFilters provide a way to wrap filters around every request and response. Things like logging, timeouts, retrying requests, etc. can be implemented as ServiceFilters.

Existing ServiceFilters include:

  • CloseOnReleaseFilter - rejects requests after connection is closed. Often used in conjunction with
  • ExpiringFilter - idle timeout and max connection time (usually used for clients)
  • TimeoutFilter - request timeout time. Usually used on servers. Clients can use future.within to specify timeouts individually.
  • ExecutorFilter - move requests to a different executor.

ServiceFactories #

For some services, a Factory can help instantiate clients. In Finagle, these are frequently provided for easy use with specific protocols, i.e. http, memcache, etc.

ServiceFactoryFilters #

ServiceFactoryFilters provide filters for getting clients. These include most connection-oriented things, like connection pooling, selection, dispatch, load balancing, etc.

Existing ServiceFactoryFilters:

wangle's People

Contributors

afrind avatar ahornby avatar ajanthanasogamoorthy avatar andriigrynenko avatar anhuang avatar anirudhvr avatar chadaustin avatar dgrnbrg-meta avatar fanzeyi avatar knekritz avatar kylemirz avatar leehowes avatar lnicco avatar lukaspiatkowski avatar maxgeorg avatar mingtaoy avatar ngoyal avatar orvid avatar shri-khare avatar simpkins avatar siyengar avatar snarkmaster avatar udippant avatar viswanathgs avatar vitaut avatar w-o-o avatar wez avatar xavierd avatar yangchi avatar yfeldblum avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

wangle's Issues

Build fail on Mac OS X

On Mac OS X 10.10.5, when calling make to build wangle, errors generated like:

/Users/yimmeng/repos/devlibs/wangle/wangle/../wangle/channel/HandlerContext-inl.h:413:14: error: no viable conversion from 'Future<void>' to 'Future<folly::Unit>'
      return folly::makeFuture();

I am building wangle with homebrew installed folly (folly: stable 0.48.0 (bottled))

Problem when I make wangle in OSX

After cmake . I face the following problem when I try to make. PFB the logs of the same.

[ 49%] Building CXX object CMakeFiles/BroadcastHandlerTest.dir/channel/broadcast/test/BroadcastHandlerTest.cpp.o
In file included from /Users/nivas.thangavelu/code/wangle/wangle/channel/broadcast/test/BroadcastHandlerTest.cpp:10:
In file included from /Users/nivas.thangavelu/code/wangle/wangle/../wangle/channel/broadcast/test/Mocks.h:15:
In file included from /Users/nivas.thangavelu/code/wangle/wangle/../wangle/channel/broadcast/BroadcastHandler.h:12:
In file included from /Users/nivas.thangavelu/code/wangle/wangle/../wangle/channel/AsyncSocketHandler.h:13:
In file included from /Users/nivas.thangavelu/code/wangle/wangle/../wangle/channel/Handler.h:14:
In file included from /Users/nivas.thangavelu/code/wangle/wangle/../wangle/channel/Pipeline.h:22:
In file included from /Users/nivas.thangavelu/code/wangle/wangle/../wangle/acceptor/TransportInfo.h:12:
/Users/nivas.thangavelu/code/wangle/wangle/../wangle/ssl/SSLUtil.h:74:17: warning: 'SSL_CTX_get_ex_new_index' is deprecated: first deprecated in OS X 10.7 [-Wdeprecated-declarations]
pindex = SSL_CTX_get_ex_new_index(0, nullptr, nullptr, nullptr, nullptr);
^
/usr/include/openssl/ssl.h:1614:5: note: 'SSL_CTX_get_ex_new_index' has been explicitly marked deprecated here
int SSL_CTX_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func,
^
In file included from /Users/nivas.thangavelu/code/wangle/wangle/channel/broadcast/test/BroadcastHandlerTest.cpp:10:
In file included from /Users/nivas.thangavelu/code/wangle/wangle/../wangle/channel/broadcast/test/Mocks.h:15:
In file included from /Users/nivas.thangavelu/code/wangle/wangle/../wangle/channel/broadcast/BroadcastHandler.h:12:
In file included from /Users/nivas.thangavelu/code/wangle/wangle/../wangle/channel/AsyncSocketHandler.h:13:
In file included from /Users/nivas.thangavelu/code/wangle/wangle/../wangle/channel/Handler.h:14:
In file included from /Users/nivas.thangavelu/code/wangle/wangle/../wangle/channel/Pipeline.h:22:
In file included from /Users/nivas.thangavelu/code/wangle/wangle/../wangle/acceptor/TransportInfo.h:12:
/Users/nivas.thangavelu/code/wangle/wangle/../wangle/ssl/SSLUtil.h:81:17: warning: 'RSA_get_ex_new_index' is deprecated: first deprecated in OS X 10.7 [-Wdeprecated-declarations]
*pindex = RSA_get_ex_new_index(0, nullptr, nullptr, nullptr, nullptr);
^
/usr/include/openssl/rsa.h:389:5: note: 'RSA_get_ex_new_index' has been explicitly marked deprecated here
int RSA_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func,
^
In file included from /Users/nivas.thangavelu/code/wangle/wangle/channel/broadcast/test/BroadcastHandlerTest.cpp:10:
In file included from /Users/nivas.thangavelu/code/wangle/wangle/../wangle/channel/broadcast/test/Mocks.h:15:
In file included from /Users/nivas.thangavelu/code/wangle/wangle/../wangle/channel/broadcast/BroadcastHandler.h:12:
In file included from /Users/nivas.thangavelu/code/wangle/wangle/../wangle/channel/AsyncSocketHandler.h:13:
In file included from /Users/nivas.thangavelu/code/wangle/wangle/../wangle/channel/Handler.h:14:
In file included from /Users/nivas.thangavelu/code/wangle/wangle/../wangle/channel/Pipeline.h:22:
In file included from /Users/nivas.thangavelu/code/wangle/wangle/../wangle/acceptor/TransportInfo.h:12:
/Users/nivas.thangavelu/code/wangle/wangle/../wangle/ssl/SSLUtil.h:121:17: warning: 'SSL_SESSION_get_ex_new_index' is deprecated: first deprecated in OS X 10.7 [-Wdeprecated-declarations]
*pindex = SSL_SESSION_get_ex_new_index(
^
/usr/include/openssl/ssl.h:1609:5: note: 'SSL_SESSION_get_ex_new_index' has been explicitly marked deprecated here
int SSL_SESSION_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func,
^
3 warnings generated.
[ 49%] Linking CXX executable bin/BroadcastHandlerTest
ld: library not found for -latomic
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *
* [bin/BroadcastHandlerTest] Error 1
make[1]: *** [CMakeFiles/BroadcastHandlerTest.dir/all] Error 2
make: *** [all] Error 2

Fail to compile on Fedora 20

Hello,

I have tried different versions of gflags (also changing default namespace from gflags to google). However, I still receive the following error.

Platform: Fedora 20

wangle-0.13.0/wangle/service/ServiceTest.cpp:327:3: error: ‘ParseCommandLineFlags’ is not a member of ‘google’

separate IOThreadPool for Echo example.

trying to test the separate IOThreadPool. Patch like below for EchoClient.cpp
std::shared_ptrwangle::IOThreadPoolExecutor ioPool =
std::make_sharedwangle::IOThreadPoolExecutor(2);
std::shared_ptr pipeFact =
std::make_shared();

ClientBootstrap client;
client.group(ioPool);
client.pipelineFactory(pipeFact);

But when EchoClient exits, assert error showed up.
I0423 21:57:13.939635 54128 AsyncSocket.cpp:519] AsyncSocket::setReadCallback() this=0x7f2b88001950, fd=11, callback=0, state=2
EchoClient: io/async/AsyncSocket.cpp:558: virtual void folly::AsyncSocket::setReadCB(folly::AsyncTransportWrapper::ReadCallback*): Assertion `eventBase_->isInEventBaseThread()' failed.

Looks Pipeline/AsyncSocket destruction was called by the main thread, that was why AsyncSocket assert.

Added the patch to ClientBootstrap to avoid this assert. Is it the correct way to handle it?

Basically the patch kept the EventBase that was selected to setup the socket with server at connect() in ClientBootstrap class. And destruct pipeline in the EventBase thread in ~ClientBootstrap.
virtual ~ClientBootstrap() {
if (base_ && group_.get() && pipeline_) {
// Pipeline was already created, destroy from the EventBase thread
// as AsyncSocket destruct could only be called from its EventBase thread
VLOG(5) << " ~ClientBootstrap " << this
<< ", destruct pipeline_ in EventBase thread";
base_->runImmediatelyOrRunInEventBaseThreadAndWait(&{
pipeline_.reset();
});
}
};

Build error on Fedora 23

[ 54%] Built target wangle
[ 55%] Linking CXX executable bin/AcceptorTest
/usr/bin/ld: ../gmock/src/gmock-build/libgmock.a(gtest-all.cc.o): undefined reference to symbol 'pthread_key_delete@@GLIBC_2.2.5'
/usr/lib64/libpthread.so.0: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
CMakeFiles/AcceptorTest.dir/build.make:102: recipe for target 'bin/AcceptorTest' failed
make[2]: *** [bin/AcceptorTest] Error 1
CMakeFiles/Makefile2:68: recipe for target 'CMakeFiles/AcceptorTest.dir/all' failed
make[1]: *** [CMakeFiles/AcceptorTest.dir/all] Error 2
Makefile:138: recipe for target 'all' failed
make: *** [all] Error 2

compiling failure when building AsyncSocketHandlerTest.cpp.o on Ubuntu 14.04

It seems that lasted folly has make Future copy ctor deleted, which is used in AsyncSocketHandlerTest.cpp.

Scanning dependencies of target AsyncSocketHandlerTest
[ 2%] Building CXX object CMakeFiles/AsyncSocketHandlerTest.dir/channel/test/AsyncSocketHandlerTest.cpp.o
In file included from /home/zed/fbthrift/thrift/build/deps/wangle/wangle/gmock/src/gmock/include/gmock/gmock-generated-function-mockers.h:43:0,
from /home/zed/fbthrift/thrift/build/deps/wangle/wangle/gmock/src/gmock/include/gmock/gmock.h:61,
from /home/zed/fbthrift/thrift/build/deps/wangle/wangle/../wangle/channel/test/MockHandler.h:13,
from /home/zed/fbthrift/thrift/build/deps/wangle/wangle/channel/test/AsyncSocketHandlerTest.cpp:14:
/home/zed/fbthrift/thrift/build/deps/wangle/wangle/gmock/src/gmock/include/gmock/gmock-spec-builders.h: In instantiation of ‘T testing::internal::ActionResultHolder::GetValueAndDelete() const [with T = folly::Futurefolly::Unit]’:
/home/zed/fbthrift/thrift/build/deps/wangle/wangle/gmock/src/gmock/include/gmock/gmock-spec-builders.h:1530:60: required from ‘testing::internal::FunctionMockerBase::Result testing::internal::FunctionMockerBase::InvokeWith(const ArgumentTuple&) [with F = folly::Futurefolly::Unit(wangle::HandlerContext<folly::IOBufQueue&, std::unique_ptrfolly::IOBuf >, std::shared_ptrfolly::IOBuf); testing::internal::FunctionMockerBase::Result = folly::Futurefolly::Unit; testing::internal::FunctionMockerBase::ArgumentTuple = std::tuple<wangle::HandlerContext<folly::IOBufQueue&, std::unique_ptr<folly::IOBuf, std::default_deletefolly::IOBuf > >, std::shared_ptrfolly::IOBuf >]’
/home/zed/fbthrift/thrift/build/deps/wangle/wangle/gmock/src/gmock/include/gmock/gmock-generated-function-mockers.h:118:50: required from ‘R testing::internal::FunctionMocker<R(A1, A2)>::Invoke(A1, A2) [with R = folly::Futurefolly::Unit; A1 = wangle::HandlerContext<folly::IOBufQueue&, std::unique_ptrfolly::IOBuf >*; A2 = std::shared_ptrfolly::IOBuf]’
/home/zed/fbthrift/thrift/build/deps/wangle/wangle/../wangle/channel/test/MockHandler.h:73:3: required from here
/home/zed/fbthrift/thrift/build/deps/wangle/wangle/gmock/src/gmock/include/gmock/gmock-spec-builders.h:1330:20: error: use of deleted function ‘folly::Future::Future(const folly::Future&) [with T = folly::Unit]’
T retval(value_);
^
In file included from /home/zed/fbthrift/thrift/build/deps/wangle/wangle/../wangle/channel/Handler.h:13:0,
from /home/zed/fbthrift/thrift/build/deps/wangle/wangle/../wangle/channel/AsyncSocketHandler.h:13,
from /home/zed/fbthrift/thrift/build/deps/wangle/wangle/channel/test/AsyncSocketHandlerTest.cpp:12:
/usr/local/include/folly/futures/Future.h:50:3: error: declared here
Future(Future const&) = delete;

Build error on OSX

[ 30%] Building CXX object CMakeFiles/wangle.dir/channel/FileRegion.cpp.o
/Users/btv/wangle/wangle/channel/FileRegion.cpp:54:15: error: use of undeclared identifier 'SPLICE_F_NONBLOCK'
int flags = SPLICE_F_NONBLOCK | SPLICE_F_MORE;

Current build fails due to Async.h

I ran into this compilation error with gcc 5.3 and Ubuntu 14.04. It looks like the issue is because -std=c++0x is set in CMakeLists.txt instead of -std=c++14. Since there are no dependencies on this header I just removed it from the build order for now.

In file included from /home/vagrant/wangle/wangle/concurrent/test/AsyncTest.cpp:12:0:
/home/vagrant/wangle/wangle/../wangle/concurrent/Async.h:18:18: error: ‘async’ function uses ‘auto’ type specifier without trailing return type
auto async(F&& fn) {
^
/home/vagrant/wangle/wangle/../wangle/concurrent/Async.h:18:18: note: deduced return type only available with -std=c++14 or -std=gnu++14
/home/vagrant/wangle/wangle/concurrent/test/AsyncTest.cpp: In member function ‘virtual void AsyncFunc_manual_executor_Test::TestBody()’:
/home/vagrant/wangle/wangle/concurrent/test/AsyncTest.cpp:22:34: error: invalid use of ‘auto’
auto f = async([]{ return 42; });
^
/home/vagrant/wangle/wangle/concurrent/test/AsyncTest.cpp: In member function ‘virtual void AsyncFunc_value_lambda_Test::TestBody()’:
/home/vagrant/wangle/wangle/concurrent/test/AsyncTest.cpp:31:29: error: invalid use of ‘auto’
auto future = async(lambda);
^
/home/vagrant/wangle/wangle/concurrent/test/AsyncTest.cpp: In member function ‘virtual void AsyncFunc_void_lambda_Test::TestBody()’:
/home/vagrant/wangle/wangle/concurrent/test/AsyncTest.cpp:37:29: error: invalid use of ‘auto’
auto future = async(lambda);
^
/home/vagrant/wangle/wangle/concurrent/test/AsyncTest.cpp: In member function ‘virtual void AsyncFunc_moveonly_lambda_Test::TestBody()’:
/home/vagrant/wangle/wangle/concurrent/test/AsyncTest.cpp:44:29: error: invalid use of ‘auto’
auto future = async(lambda);
^
make[2]: *** [CMakeFiles/AsyncTest.dir/concurrent/test/AsyncTest.cpp.o] Error 1
make[1]: *** [CMakeFiles/AsyncTest.dir/all] Error 2
make: *** [all] Error 2```

multiple connections to the same server with Echo example

try to create multiple connections to the same server with Echo example. but could not get it work. any help?

The code change is simple

diff --git a/wangle/example/echo/EchoClient.cpp b/wangle/example/echo/EchoClient.cpp
index 5ee0cad..2b424b1 100644
--- a/wangle/example/echo/EchoClient.cpp
+++ b/wangle/example/echo/EchoClient.cpp
@@ -60,26 +60,49 @@ int main(int argc, char** argv) {
google::ParseCommandLineFlags(&argc, &argv, true);

ClientBootstrap client;
-- client.group(std::make_sharedwangle::IOThreadPoolExecutor(1));
++ client.group(std::make_sharedwangle::IOThreadPoolExecutor(2));
client.pipelineFactory(std::make_shared());
auto pipeline = client.connect(SocketAddress(FLAGS_host, FLAGS_port)).get();
++ auto pipeline1 = client.connect(SocketAddress(FLAGS_host, FLAGS_port)).get();

get below error
./bin/EchoClient -v=5
WARNING: Logging before InitGoogleLogging() is written to STDERR
I0414 03:06:57.619832 12775 EventBase.cpp:164] EventBase(): Created.
I0414 03:06:57.621055 12775 EventBase.cpp:295] EventBase(): Starting loop.
I0414 03:06:57.621507 12775 EventBase.cpp:401] EventBase 0x7fd1e0000af0 loop time: 0
I0414 03:06:57.621940 12775 EventBase.cpp:401] EventBase 0x7fd1e0000af0 loop time: 0
I0414 03:06:57.622267 12775 EventBase.cpp:401] EventBase 0x7fd1e0000af0 loop time: 0
I0414 03:06:57.622627 12774 EventBase.cpp:164] EventBase(): Created.
I0414 03:06:57.623005 12774 EventBase.cpp:295] EventBase(): Starting loop.
I0414 03:06:57.623384 12773 EventBase.cpp:164] EventBase(): Created.
I0414 03:06:57.623760 12774 EventBase.cpp:401] EventBase 0x7fd1d8000a10 loop time: 0
I0414 03:06:57.624092 12774 AsyncSocket.cpp:192] new AsyncSocket(0x7fd1d80017c0, evb=0x7fd1d8000a10)
I0414 03:06:57.624151 12774 AsyncSocket.cpp:383] AsyncSocket::connect(this=0x7fd1d80017c0, evb=0x7fd1d8000a10, fd=15, host=[::1]:8080
I0414 03:06:57.624732 12774 EventBase.cpp:401] EventBase 0x7fd1d8000a10 loop time: 0
I0414 03:06:57.624949 12774 AsyncSocket.cpp:1401] AsyncSocket::handleWrite() this=0x7fd1d80017c0, fd=15, state=1
I0414 03:06:57.624963 12774 AsyncSocket.cpp:1573] AsyncSocket::handleConnect() this=0x7fd1d80017c0, fd=15, state=1
I0414 03:06:57.624979 12774 AsyncSocket.cpp:1750] AsyncSocket::updateEventRegistration(this=0x7fd1d80017c0, fd=15, evb=0x7fd1d8000a10, state=2, events=2
I0414 03:06:57.625022 12775 AsyncSocket.cpp:192] new AsyncSocket(0x7fd1e0001950, evb=0x7fd1e0000af0)
I0414 03:06:57.625051 12775 AsyncSocket.cpp:383] AsyncSocket::connect(this=0x7fd1e0001950, evb=0x7fd1e0000af0, fd=16, host=[::1]:8080
EchoClient: io/async/AsyncSocket.cpp:558: virtual void folly::AsyncSocket::setReadCB(folly::AsyncTransportWrapper::ReadCallback*): Assertion `eventBase_->isInEventBaseThread()' failed.
Aborted

Building error at Acceptor.cpp

A error occurs as follows:

$ make
[ 17%] Built target gmock
[ 17%] Building CXX object CMakeFiles/wangle.dir/acceptor/Acceptor.cpp.o

/home/zzcheng/software/wangle/wangle/acceptor/Acceptor.cpp: In member function 'void wangle::Acceptor::connectionReady(folly::AsyncTransportWrapper::UniquePtr, const folly::SocketAddress&, const string&, SecureTransportType, wangle::TransportInfo&)':
/home/zzcheng/software/wangle/wangle/acceptor/Acceptor.cpp:256:28: error: 'class folly::AsyncTransportWrapper' has no member named 'getUnderlyingTransport'
auto asyncSocket = sock->getUnderlyingTransport();
^
/home/zzcheng/software/wangle/wangle/acceptor/Acceptor.cpp:256:62: error: expected primary-expression before '>' token
auto asyncSocket = sock->getUnderlyingTransport();
^
/home/zzcheng/software/wangle/wangle/acceptor/Acceptor.cpp:256:64: error: expected primary-expression before ')' token
auto asyncSocket = sock->getUnderlyingTransport();
^
make[2]: *** [CMakeFiles/wangle.dir/acceptor/Acceptor.cpp.o] Error 1
make[1]: *** [CMakeFiles/wangle.dir/all] Error 2
make: *** [all] Error 2

thanks.

ctest errors

Test project /home/lixiang/library/facebook/wangle-master/wangle/build
Start 1: AcceptorTest
1/15 Test #1: AcceptorTest ......................... Passed 0.02 sec
Start 2: LoadShedConfigurationTest
2/15 Test #2: LoadShedConfigurationTest ............ Passed 0.01 sec
Start 3: PeekingAcceptorHandshakeHelperTest
3/15 Test #3: PeekingAcceptorHandshakeHelperTest ... Passed 0.02 sec
Start 4: BootstrapTest
4/15 Test #4: BootstrapTest ........................ Passed 0.64 sec
Start 5: AsyncSocketHandlerTest
5/15 Test #5: AsyncSocketHandlerTest ............... Passed 0.01 sec
Start 6: OutputBufferingHandlerTest
6/15 Test #6: OutputBufferingHandlerTest ........... Passed 0.01 sec
Start 7: PipelineTest
7/15 Test #7: PipelineTest ......................... Passed 0.27 sec
Start 8: CodecTest
8/15 Test #8: CodecTest ............................ Passed 0.00 sec
Start 9: CodelTest
9/15 Test #9: CodelTest ............................ Passed 0.58 sec
Start 10: GlobalExecutorTest
10/15 Test #10: GlobalExecutorTest ................... Passed 0.00 sec
Start 11: ThreadPoolExecutorTest
11/15 Test #11: ThreadPoolExecutorTest ............... Passed 0.69 sec
Start 12: RxTest
12/15 Test #12: RxTest ............................... Passed 0.01 sec
Start 13: ServiceTest
13/15 Test #13: ServiceTest .........................._Exception: SegFault 0.07 sec
Start 14: SSLCacheTest
14/15 Test #14: SSLCacheTest .........................
_Failed 0.00 sec
Start 15: SSLContextManagerTest
15/15 Test #15: SSLContextManagerTest ................ Passed 0.00 sec

87% tests passed, 2 tests failed out of 15

Total Test time (real) = 2.34 sec

The following tests FAILED:
13 - ServiceTest (SEGFAULT)
14 - SSLCacheTest (Failed)
Errors while running CTest

Do you know why?

Add Boost include dirs to CMakelist.txt

Currently the root CMakelist.txt file's include dirs are:

include_directories(
${CMAKE_SOURCE_DIR}/..
${FOLLY_INCLUDE_DIR}
${INCLUDE_DIR}
)

This is missing the boost include dirs.

I think it should be:

include_directories(
${CMAKE_SOURCE_DIR}/..
${FOLLY_INCLUDE_DIR}
${Boost_INCLUDE_DIRS}
${INCLUDE_DIR}
)

Subscriber-like operations only works when compiled with `NDEBUG`

I am trying to build a pipeline that behaves similarly as Subscriber. I could not use broadcast pipeline directly because broadcasting is not the desired default behavior. So the basic operations look like follows:
Client A connects and subscribe so I save Context A
Client B connects and issued a request that A is interested in, so I write data to Context A.

Interestingly, this code works as expected only when compiled with NDEBUG flag on. I otherwise get a DCHECK failure that can be traced back to folly:
https://github.com/facebook/folly/blob/2c8de414e51305fa00ef6efdab69de0fbda7aff1/folly/io/async/EventBase.cpp#L494

While the check appears in the folly code, I am wondering what is the right approach of mimicking the behavior of wangle's broadcast pipeline.

Test fails on Ubuntu 14.04

Lib version
wangle v0.13.0
folly v0.57.0
Test project /home/ubuntu/facebook/wangle/wangle
      Start  1: BootstrapTest
 1/11 Test  #1: BootstrapTest ....................   Passed    0.63 sec
      Start  2: OutputBufferingHandlerTest
 2/11 Test  #2: OutputBufferingHandlerTest .......   Passed    0.01 sec
      Start  3: PipelineTest
 3/11 Test  #3: PipelineTest .....................   Passed    0.01 sec
      Start  4: CodecTest
 4/11 Test  #4: CodecTest ........................***Failed    0.01 sec
      Start  5: CodelTest
 5/11 Test  #5: CodelTest ........................   Passed    0.40 sec
      Start  6: GlobalExecutorTest
 6/11 Test  #6: GlobalExecutorTest ...............   Passed    0.01 sec
      Start  7: ThreadPoolExecutorTest
 7/11 Test  #7: ThreadPoolExecutorTest ...........   Passed    0.72 sec
      Start  8: RxTest
 8/11 Test  #8: RxTest ...........................   Passed    0.01 sec
      Start  9: ServiceTest
 9/11 Test  #9: ServiceTest ......................***Exception: SegFault  0.13 sec
      Start 10: SSLCacheTest
10/11 Test #10: SSLCacheTest .....................***Failed    0.01 sec
      Start 11: SSLContextManagerTest
11/11 Test #11: SSLContextManagerTest ............   Passed    0.01 sec

73% tests passed, 3 tests failed out of 11

Total Test time (real) =   1.94 sec

The following tests FAILED:
      4 - CodecTest (Failed)
      9 - ServiceTest (SEGFAULT)
     10 - SSLCacheTest (Failed)

[Fedora] undefined reference to ssl

I recently compiled the Wangle library without libatomic (as it errors on Fedora 23). I just tried to build server that is very close to echo example in the implementation. When trying to build, this is what happens:

usr/bin/ld: /usr/local/lib/libwangle.a(SSLSessionCacheManager.cpp.o): undefined reference to symbol 'SSL_CTX_get_ex_new_index@@libssl.so.10'
/usr/lib64/libssl.so.10: error adding symbols: DSO missing from command line

libssl can be found in the given directories. Is there a way to disable SSLSessionCacheManager? Am I missing any dependencies?

What I did:

  • compiled folly, installed
  • removed libatomic from wangle, compiled, installed
  • tried to compile implementation that has nothing more than echo example

Having issue building wangle with custom gcc (other than the system's gcc)

  • I build everything required into "home/$USER/build/" folder into their respective folders.
  • So far I have successfully build the following libraries:
    boost-1.59.0 double-conversion folly gcc-4.9.4 gflags glog gmp-4.3.2 libevent mpc-1.0.3 mpfr-2.4.2 mstch openssl-1.0.1u snappy
  • When it comes to building wangle I have problems.
  • I try buidling wangle source using these commands:
    cd /home/$USER/downloads
    git clone https://github.com/facebook/wangle
    cd wangle/wangle
    env PATH=/home/$USER/build/gcc-4.9.4/bin/:$PATH cmake -DBUILD_SHARED_LIBS=ON -DFOLLY_LIBRARY=/home/$USER/build/folly/lib/libfolly.so -DFOLLY_LIBRARIES=/home/$USER/build/folly/lib -DFOLLY_INCLUDE_DIR=/home/$USER/build/folly/include -DBOOST_ROOT=/home/$USER/build/boost-1.59.0 -DBoost_LIBRARIES=/home/$USER/build/boost-1.59.0/lib -DGFLAGS_LIBRARY_PATH=/home/$USER/build/gflags/lib/libgflags.so -DGLOG_LIBRARY_PATH=/home/$USER/build/glog/lib/libglog.so -DOPENSSL_LIBRARIES=/home/$USER/build/openssl-1.0.1u/lib -DOPENSSL_INCLUDE_DIR=/home/$USER/build/openssl-1.0.1u/include -DCMAKE_INSTALL_PREFIX=/home/$USER/build/wangle -DINCLUDE_DIR="/home/$USER/build/double-conversion/include;/home/$USER/build/gflags/include;/home/$USER/build/glog/include;/home/$USER/build/libevent/include;/home/$USER/build/boost-1.59.0/include" .
    env PATH=/home/$USER/build/gcc-4.9.4/bin/:$PATH make -j 10

My LD_LIBRARY_PATH is:
/home/spershin/build/folly/lib:/home/spershin/build/boost-1.59.0/lib:/home/spershin/build/double-conversion/lib64:/home/spershin/build/gflags/lib:/home/spershin/build/glog/lib:/home/spershin/build/snappy/lib:/home/spershin/build/openssl-1.0.1u/lib:/home/spershin/build/libevent/lib:/home/spershin/build/gmp-4.3.2/lib:/home/spershin/build/mpfr-2.4.2/lib:/home/spershin/build/mpc-1.0.3/lib

I get the following problems and suspicious output:

During cmake it says it has found system ssl libraries despite the specified variable (OPENSSL_LIBRARIES) in the command line:
-- Found OpenSSL: /usr/lib64/libssl.so;/usr/lib64/libcrypto.so (found version "1.0.1u")

During make:
make[2]: Warning: File CMakeFiles/LoadShedConfigurationTest.dir/depend.make has modification time 0.0025 s in the future
make[2]: Warning: File CMakeFiles/ConnectionManagerTest.dir/depend.make has modification time 0.0033 s in the future
make[2]: Warning: File CMakeFiles/ThreadPoolExecutorTest.dir/depend.make has modification time 0.00063 s in the future
make[2]: Warning: File CMakeFiles/PeekingAcceptorHandshakeHelperTest.dir/depend.make has modification time 0.0014 s in the future
make[2]: Warning: File CMakeFiles/AcceptorTest.dir/depend.make has modification time 0.00039 s in the future
...
[ 64%] Linking CXX executable bin/LoadShedConfigurationTest
/bin/ld: warning: libssl.so.1.0.0, needed by /home/spershin/build/folly/lib/libfolly.so, may conflict with libssl.so.10
/bin/ld: warning: libcrypto.so.1.0.0, needed by /home/spershin/build/folly/lib/libfolly.so, may conflict with libcrypto.so.10
/home/spershin/build/folly/lib/libfolly.so: undefined reference to std::__throw_out_of_range_fmt(char const*, ...)@GLIBCXX_3.4.20
/home/spershin/build/folly/lib/libfolly.so: undefined reference to __cxa_throw_bad_array_new_length@CXXABI_1.3.8
collect2: error: ld returned 1 exit status
make[2]: *** [bin/LoadShedConfigurationTest] Error 1
make[1]: *** [CMakeFiles/LoadShedConfigurationTest.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....

The linking error is the same for all test binaries, I think.

So I see two problems: the build is picking up the wrong ssl libraries and possibly some incorrect system libraries.
I checked the "/home/spershin/build/folly/lib/libfolly.so" and ldd does not report any "not found" dependencies. I've also been able to compile a simple application & link it with the folly library.

I'm at lost at the moment and would appreciate any help.
Thanks!

Add a tutorial

I will write an in-depth tutorial based on my upcoming blog post - Writing high-performance servers with modern C++

I would be grateful for a peer review before I publish and merge into the README.md.

Is there anything that I have missed out?
Is anything incorrect?
Does it flow correctly?
Is it interesting enough?

Build Fail: 'openssl/ssl.h' file not found

System: OS X 10.11.4

openssl is installed by homebrew, brew install openssl.

CMake command-line options: cmake -DOPENSSL_ROOT_DIR=/usr/local/opt/openssl/ .

Following log shows that cmake found openssl successfully:

$ cd wangle
$ cmake -DOPENSSL_ROOT_DIR=/usr/local/opt/openssl/ .
-- The C compiler identification is AppleClang 7.3.0.7030029
-- The CXX compiler identification is AppleClang 7.3.0.7030029
-- Check for working C compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc
-- Check for working C compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++
-- Check for working CXX compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found Folly: /usr/local/include  
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Looking for pthread_create
-- Looking for pthread_create - found
-- Found Threads: TRUE  
-- Boost version: 1.60.0
-- Found the following Boost libraries:
--   system
--   thread
--   filesystem
--   chrono
--   date_time
--   atomic
-- Found OpenSSL: /usr/local/opt/openssl/lib/libssl.dylib;/usr/local/opt/openssl/lib/libcrypto.dylib (found version "1.0.2g")
-- Configuring done
-- Generating done
-- Build files have been written to: /Users/haoxun/Temp/wangle/wangle

But, make complains that <openssl/ssl.h> not found:

$ make
Scanning dependencies of target wangle
[  1%] Building CXX object CMakeFiles/wangle.dir/acceptor/Acceptor.cpp.o
In file included from /Users/haoxun/Temp/wangle/wangle/acceptor/Acceptor.cpp:10:
In file included from /Users/haoxun/Temp/wangle/wangle/../wangle/acceptor/Acceptor.h:12:
In file included from /Users/haoxun/Temp/wangle/wangle/../wangle/acceptor/ServerSocketConfig.h:13:
In file included from /Users/haoxun/Temp/wangle/wangle/../wangle/ssl/SSLContextConfig.h:14:
/usr/local/include/folly/io/async/SSLContext.h:26:10: fatal error: 'openssl/ssl.h' file not found
#include <openssl/ssl.h>
         ^
1 error generated.
make[2]: *** [CMakeFiles/wangle.dir/acceptor/Acceptor.cpp.o] Error 1
make[1]: *** [CMakeFiles/wangle.dir/all] Error 2
make: *** [all] Error 2

I've check the CMakeCache.txt, seems there's nothing wrong:

//Path to a library.
OPENSSL_CRYPTO_LIBRARY:FILEPATH=/usr/local/opt/openssl/lib/libcrypto.dylib

//Path to a file.
OPENSSL_INCLUDE_DIR:PATH=/usr/local/opt/openssl/include

//No help, variable specified on the command line.
OPENSSL_ROOT_DIR:UNINITIALIZED=/usr/local/opt/openssl/

//Path to a library.
OPENSSL_SSL_LIBRARY:FILEPATH=/usr/local/opt/openssl/lib/libssl.dylib

OPENSSL_INCLUDE_DIR detected by cmake is correct, of course:

$ cd /usr/local/opt/openssl/include
$ tree
.
└── openssl
    ├── aes.h
    ├── asn1.h
    ├── asn1_mac.h
    ├── asn1t.h
    ├── bio.h
    ├── blowfish.h
    ├── bn.h
    ├── buffer.h
    ├── camellia.h
    ├── cast.h
    ├── cmac.h
    ├── cms.h
    ├── comp.h
    ├── conf.h
    ├── conf_api.h
    ├── crypto.h
    ├── des.h
    ├── des_old.h
    ├── dh.h
    ├── dsa.h
    ├── dso.h
    ├── dtls1.h
    ├── e_os2.h
    ├── ebcdic.h
    ├── ec.h
    ├── ecdh.h
    ├── ecdsa.h
    ├── engine.h
    ├── err.h
    ├── evp.h
    ├── hmac.h
    ├── idea.h
    ├── krb5_asn.h
    ├── kssl.h
    ├── lhash.h
    ├── md4.h
    ├── md5.h
    ├── mdc2.h
    ├── modes.h
    ├── obj_mac.h
    ├── objects.h
    ├── ocsp.h
    ├── opensslconf.h
    ├── opensslv.h
    ├── ossl_typ.h
    ├── pem.h
    ├── pem2.h
    ├── pkcs12.h
    ├── pkcs7.h
    ├── pqueue.h
    ├── rand.h
    ├── rc2.h
    ├── rc4.h
    ├── ripemd.h
    ├── rsa.h
    ├── safestack.h
    ├── seed.h
    ├── sha.h
    ├── srp.h
    ├── srtp.h
    ├── ssl.h
    ├── ssl2.h
    ├── ssl23.h
    ├── ssl3.h
    ├── stack.h
    ├── symhacks.h
    ├── tls1.h
    ├── ts.h
    ├── txt_db.h
    ├── ui.h
    ├── ui_compat.h
    ├── whrlpool.h
    ├── x509.h
    ├── x509_vfy.h
    └── x509v3.h

1 directory, 75 files

In conclusion, I guess there's something wrong in the CMakeLists.txt.

Mq based Pipeline

Hi,
Quick questions is it possible to configure wangle to use something like zero mq instead of socket ?

Regards
Ben

Compilation error: [ 3%] Performing download step (download, verify and extract) for 'gmock'

I cloned the repo, did the following, and got this error:

cd wangle/wangle
sudo cmake .
sudo make
yba@ubuntu:~/Documents/XXX/tools/fbthrift/wangle/wangle$ sudo make
[  1%] Performing configure step for 'gmock'
CMake Error at /home/yba/Documents/XXX/tools/fbthrift/wangle/wangle/gmock/src/gmock-stamp/gmock-configure.cmake:16 (message):
  Command failed: 1

   '/usr/bin/cmake' '-GUnix Makefiles' '/home/yba/Documents/XXX/tools/fbthrift/wangle/wangle/gmock/src/gmock'

  See also

    /home/yba/Documents/XXX/tools/fbthrift/wangle/wangle/gmock/src/gmock-stamp/gmock-configure-*.log


make[2]: *** [gmock/src/gmock-stamp/gmock-configure] Error 1
make[1]: *** [CMakeFiles/gmock.dir/all] Error 2
make: *** [all] Error 2

The error log says:

-- downloading...
     src='https://googlemock.googlecode.com/files/gmock-1.7.0.zip'
     dst='/home/yba/Documents/XXX/tools/fbthrift/wangle/wangle/gmock/src/gmock-1.7.0.zip'
     timeout='none'
CMake Error at gmock-stamp/download-gmock.cmake:21 (message):
  error: downloading
  'https://googlemock.googlecode.com/files/gmock-1.7.0.zip' failed

    status_code: 22
    status_string: "HTTP response code said error"
    log: Hostname was NOT found in DNS cache
    Trying 173.194.205.82...

  Connected to googlemock.googlecode.com (173.194.205.82) port 443 (#0)

  successfully set certificate verify locations:

    CAfile: none
    CApath: /etc/ssl/certs

  SSLv3, TLS handshake, Client hello (1):

Is this normal? https://googlemock.googlecode.com/files/gmock-1.7.0.zip seems to be invalid. Please confirm this is a bug, or help me on how to compile it. I could compile successfully last month.

Thank you very much!

Clean way to deploy a proxy client

Hello,

I need to implement a proxy (client side) with Wangle. The proxy server is already there, which is a simple HTTP proxy - the client can CONNECT to it, and send the message via the tunnel.

So I already have a pipeline ready, which is able to communicate with the destination directly. Does anyone have good ideas how to extend the original pipeline to support proxy? (ie. the direct destination is fixed to be the proxy while each connection can be configured in advance for the actual destination. I have no idea how to CONNECT to the server and distinguish different connections based on the actual destination.)

Thanks in advance!

Zhenyu

Add more examples

I got feedback from some developers that wasn't much examples so I decided to add more examples. I've started off with the most basic: Echo Server/Client. #21

I will write a custom binary protocol next.

Build wangle encountered error: error: use of undeclared identifier 'malloc_usable_size'

When I tried to build wangle, it reported:
In file included from /project/opensource/source/wangle/wangle/../wangle/concurrent/ThreadPoolExecutor.h:19:
In file included from /project/opensource/source/wangle/wangle/../wangle/deprecated/rx/Observable.h:20:
/usr/local/include/folly/small_vector.h:619:14: error: use of undeclared identifier 'malloc_usable_size'
return malloc_usable_size(u.pdata_.heap_) / sizeof(value_type);

I've built "folly" successfully, did anyone encounter the same issue?
Thanks!

Compile failed on latest committed branch

I tried to compile wangle on lastest commit whose hash is 0891263.

errors occur in SSLContextManagerTest.cpp: In member function ‘virtual void wangle::SSLContextManagerTest_TestSessionContextIfSupplied_Test::TestBody()’

but compile is succeeded on right before commit whose hash is 1ae9efd.

I'm installing proxygen. it forced to change branch to master. so I cannot install it. Please fix it.

Compile fails on Ubuntu 14.04

/usr/bin/ld: warning: libboost_thread.so.1.59.0, needed by /usr/local/lib/../lib/libfolly.so, may conflict with libboost_thread.so.1.54.0
/usr/bin/ld: warning: libboost_system.so.1.59.0, needed by /usr/local/lib/../lib/libfolly.so, may conflict with libboost_system.so.1.54.0
/usr/bin/ld: ../gmock/src/gmock-build/libgmock.a(gtest-all.cc.o): undefined reference to symbol 'pthread_key_delete@@GLIBC_2.2.5'
//lib/x86_64-linux-gnu/libpthread.so.0: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
make[2]: *** [bin/AcceptorTest] error 1
make[1]: *** [CMakeFiles/AcceptorTest.dir/all] error 2
make: *** [all] error 2

I can not find the solution for the error.

uname -a:

Linux lixiang-ubuntu 3.16.0-50-generic #67~14.04.1-Ubuntu SMP Fri Oct 2 22:07:51 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux

How to send a byte array via wangle?

I have a byte array (actually the raw packet data) and I know its length. However, it may contain '\0' in the middle so that the example code doesn't work for me - such '\0' will be regarded as the end of string and I cannot send the whole array together to the destination.

I'm not quite familiar with Wangle and any idea for how to build a pipeline for my purpose?

Thanks!

P.S.
The pipeline in the sample code is showed below, it works perfect for the printable strings:

auto pipeline = EchoPipeline::create();
pipeline->addBack(AsyncSocketHandler(sock));
pipeline->addBack(
    EventBaseHandler()); // ensure we can write from any thread
pipeline->addBack(LineBasedFrameDecoder(8192, false));
pipeline->addBack(StringCodec());
pipeline->addBack(EchoHandler());

Current build fails at BootstrapTest

Boost 1.60, GCC 5.3, Ubuntu 14.04

[ 71%] Building CXX object CMakeFiles/BootstrapTest.dir/bootstrap/BootstrapTest.cpp.o
Linking CXX executable bin/BootstrapTest
/usr/bin/ld: CMakeFiles/BootstrapTest.dir/bootstrap/BootstrapTest.cpp.o: undefined reference to symbol 'ZN5boost10filesystem4pathdVERKS1'
/usr/local/lib/libboost_filesystem.so.1.60.0: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
make[2]: *** [bin/BootstrapTest] Error 1
make[1]: *** [CMakeFiles/BootstrapTest.dir/all] Error 2
make: *** [all] Error 2

Correctly handling readEOF and readException

What is the right way to deal with readEOF and readException? My understanding is that one needs to close the context on readEOF otherwise the pipeline object will never get destroyed. The echo server example doesn't do this. Isn't this a problem?

Should the context also be closed on readException or is this condition recoverable?

Build failed. `gflags` has not been declared.

[ 71%] Building CXX object CMakeFiles/ConnectionManagerTest.dir/acceptor/test/ConnectionManagerTest.cpp.o
/home/vagrant/wangle/wangle/acceptor/test/ConnectionManagerTest.cpp: In function ‘int main(int, char**)’:
/home/vagrant/wangle/wangle/acceptor/test/ConnectionManagerTest.cpp:202:3: error: ‘gflags’ has not been declared
   gflags::ParseCommandLineFlags(&argc, &argv, true);
   ^
make[2]: *** [CMakeFiles/ConnectionManagerTest.dir/acceptor/test/ConnectionManagerTest.cpp.o] Error 1
make[1]: *** [CMakeFiles/ConnectionManagerTest.dir/all] Error 2
make: *** [all] Error 2

Workaround

Add #include <gflags/gflags.h> to wangle/acceptor/test/ConnectionManagerTest.cpp.

Does wangle have official benchmark data?

I modify the telnet example to echo protocol.

/*
 *  Copyright (c) 2015, Facebook, Inc.
 *  All rights reserved.
 *
 *  This source code is licensed under the BSD-style license found in the
 *  LICENSE file in the root directory of this source tree. An additional grant
 *  of patent rights can be found in the PATENTS file in the same directory.
 *
 */

#include <gflags/gflags.h>

#include <wangle/bootstrap/ServerBootstrap.h>
#include <wangle/channel/AsyncSocketHandler.h>
#include <wangle/codec/LineBasedFrameDecoder.h>
#include <wangle/codec/FixedLengthFrameDecoder.h>
#include <wangle/codec/StringCodec.h>

using namespace folly;
using namespace wangle;

DEFINE_int32(port, 8096, "echo server port");
DEFINE_int32(frame_length, 10, "echo frame length");

typedef Pipeline<IOBufQueue&, std::string> EchoPipeline;

class EchoHandler : public HandlerAdapter<std::string> {
 public:
  virtual void read(Context* ctx, std::string msg) override {
    if (msg.empty()) 
    {
      write(ctx, "Please type something.\r\n");
    } 
    else if (msg == "bye") 
    {
      write(ctx, "Have a fabulous day!\r\n").then([ctx, this]{
        close(ctx);
      });
    } 
    else 
    {
      write(ctx,  msg);
    }
  }

  virtual void transportActive(Context* ctx) override {
    auto sock = ctx->getTransport();
    SocketAddress localAddress;
    sock->getLocalAddress(&localAddress);
    //write(ctx, "Welcome to " + localAddress.describe() + "!\r\n");
    std::cout << "Welcome to " + localAddress.describe() + "!\r\n" << std::endl;
    //write(ctx, "Type 'bye' to disconnect.\r\n");
  }
};

class EchoPipelineFactory : public PipelineFactory<EchoPipeline> {
 public:
  EchoPipeline::Ptr newPipeline(std::shared_ptr<AsyncTransportWrapper> sock) {
    auto pipeline = EchoPipeline::create();
    pipeline->addBack(AsyncSocketHandler(sock));
    pipeline->addBack(FixedLengthFrameDecoder(FLAGS_frame_length));
    pipeline->addBack(StringCodec());
    pipeline->addBack(EchoHandler());
    pipeline->finalize();

    return pipeline;
  }
};

int main(int argc, char** argv) {
  google::ParseCommandLineFlags(&argc, &argv, true);

  ServerBootstrap<EchoPipeline> server;
  server.childPipeline(std::make_shared<EchoPipelineFactory>());
  server.bind(FLAGS_port);
  server.waitForStop();

  return 0;
}

I test it use my echoclient with 10 bytes playload,then the qps is only 13w。
My hardware:
model name : Intel(R) Xeon(R) CPU E5-2450 v2 @ 2.50GHz
cpu MHz : 2500.000
cache size : 20480 KB
MemTotal: 132133772 kB
OS:
CentOS release 6.3 (Final) with gcc 4.8

LengthFieldBasedFrameDecoder decoder Example. Not able to Read Content Length

Im decoding LengthFieldBasedFrameDecoder format. when I'm Decoding Length is not coming. Please Suggest me How i need to decode. please find the below program

class EchoHandler : public HandlerAdapterstd::string {
public:
virtual void read(Context* ctx, std::string msg) override {
LOG(INFO) << "Recieving Time";
/* Here Im Decoding the Buffer but Content Length is Not able to Read *//

std::cout << "handling " << msg << std::endl;
write(ctx, msg + "\r\n");

}
};
class EchoPipelineFactory : public PipelineFactory {
public:
EchoPipeline::Ptr newPipeline(std::shared_ptr sock) {
auto pipeline = EchoPipeline::create();
pipeline->addBack(AsyncSocketHandler(sock));
pipeline->addBack(LengthFieldBasedFrameDecoder());
pipeline->addBack(LengthFieldPrepender());
pipeline->addBack(StringCodec());
pipeline->addBack(EchoHandler());
pipeline->finalize();
return pipeline;
}
};

int main(int argc, char** argv) {
google::ParseCommandLineFlags(&argc, &argv, true);

ServerBootstrap server;
server.childPipeline(std::make_shared());
server.bind(FLAGS_port);
server.waitForStop();

return 0;
}

Wangle failing to build on Ubuntu 14.04

The following error happens when building in Ubuntu 14.04

In file included from /home/vagrant/proxygen/proxygen/wangle/wangle/../wangle/channel/Handler.h:13:0,
                 from /home/vagrant/proxygen/proxygen/wangle/wangle/../wangle/channel/AsyncSocketHandler.h:13,
                 from /home/vagrant/proxygen/proxygen/wangle/wangle/../wangle/channel/broadcast/BroadcastHandler.h:12,
                 from /home/vagrant/proxygen/proxygen/wangle/wangle/../wangle/channel/broadcast/test/Mocks.h:14,
                 from /home/vagrant/proxygen/proxygen/wangle/wangle/channel/broadcast/test/ObservingHandlerTest.cpp:10:
/usr/local/include/folly/futures/Future.h:50:3: note: declared here
   Future(Future const&) = delete;
   ^
In file included from /home/vagrant/proxygen/proxygen/wangle/wangle/gmock/src/gmock/include/gmock/gmock-actions.h:46:0,
                 from /home/vagrant/proxygen/proxygen/wangle/wangle/gmock/src/gmock/include/gmock/gmock.h:58,
                 from /home/vagrant/proxygen/proxygen/wangle/wangle/../wangle/channel/broadcast/test/Mocks.h:12,
                 from /home/vagrant/proxygen/proxygen/wangle/wangle/channel/broadcast/test/ObservingHandlerTest.cpp:10:
/home/vagrant/proxygen/proxygen/wangle/wangle/gmock/src/gmock/include/gmock/internal/gmock-internal-utils.h: In instantiation of ‘T testing::internal::Invalid() [with T = folly::Future<wangle::BroadcastHandler<int>*>]’:
/home/vagrant/proxygen/proxygen/wangle/wangle/gmock/src/gmock/include/gmock/gmock-actions.h:78:33:   required from ‘static T testing::internal::BuiltInDefaultValue<T>::Get() [with T = folly::Future<wangle::BroadcastHandler<int>*>]’
/home/vagrant/proxygen/proxygen/wangle/wangle/gmock/src/gmock/include/gmock/gmock-actions.h:190:47:   required from ‘static T testing::DefaultValue<T>::Get() [with T = folly::Future<wangle::BroadcastHandler<int>*>]’
/home/vagrant/proxygen/proxygen/wangle/wangle/gmock/src/gmock/include/gmock/gmock-spec-builders.h:1460:38:   required from ‘testing::internal::FunctionMockerBase<F>::Result testing::internal::FunctionMockerBase<F>::PerformDefaultAction(const ArgumentTuple&, const string&) const [with F = folly::Future<wangle::BroadcastHandler<int>*>(const std::basic_string<char>&); testing::internal::FunctionMockerBase<F>::Result = folly::Future<wangle::BroadcastHandler<int>*>; testing::internal::FunctionMockerBase<F>::ArgumentTuple = std::tuple<const std::basic_string<char, std::char_traits<char>, std::allocator<char> >&>; testing::internal::string = std::basic_string<char>]’
/home/vagrant/proxygen/proxygen/wangle/wangle/gmock/src/gmock/include/gmock/gmock-spec-builders.h:1350:66:   required from ‘static testing::internal::ActionResultHolder<T>* testing::internal::ActionResultHolder<T>::PerformDefaultAction(const testing::internal::FunctionMockerBase<F>*, const typename testing::internal::Function<F>::ArgumentTuple&, const string&) [with F = folly::Future<wangle::BroadcastHandler<int>*>(const std::basic_string<char>&); T = folly::Future<wangle::BroadcastHandler<int>*>; typename testing::internal::Function<F>::ArgumentTuple = std::tuple<const std::basic_string<char, std::char_traits<char>, std::allocator<char> >&>; testing::internal::string = std::basic_string<char>]’
/home/vagrant/proxygen/proxygen/wangle/wangle/gmock/src/gmock/include/gmock/gmock-spec-builders.h:1473:75:   required from ‘testing::internal::UntypedActionResultHolderBase* testing::internal::FunctionMockerBase<F>::UntypedPerformDefaultAction(const void*, const string&) const [with F = folly::Future<wangle::BroadcastHandler<int>*>(const std::basic_string<char>&); testing::internal::string = std::basic_string<char>]’
/home/vagrant/proxygen/proxygen/wangle/wangle/channel/broadcast/test/ObservingHandlerTest.cpp:346:1:   required from here
/home/vagrant/proxygen/proxygen/wangle/wangle/gmock/src/gmock/include/gmock/internal/gmock-internal-utils.h:371:71: error: use of deleted function ‘folly::Future<T>::Future(const folly::Future<T>&) [with T = wangle::BroadcastHandler<int>*]’
       *static_cast<volatile typename remove_reference<T>::type*>(NULL));
                                                                       ^
In file included from /home/vagrant/proxygen/proxygen/wangle/wangle/../wangle/channel/Handler.h:13:0,
                 from /home/vagrant/proxygen/proxygen/wangle/wangle/../wangle/channel/AsyncSocketHandler.h:13,
                 from /home/vagrant/proxygen/proxygen/wangle/wangle/../wangle/channel/broadcast/BroadcastHandler.h:12,
                 from /home/vagrant/proxygen/proxygen/wangle/wangle/../wangle/channel/broadcast/test/Mocks.h:14,
                 from /home/vagrant/proxygen/proxygen/wangle/wangle/channel/broadcast/test/ObservingHandlerTest.cpp:10:
/usr/local/include/folly/futures/Future.h:50:3: note: declared here
   Future(Future const&) = delete;
   ^
make[2]: *** [CMakeFiles/ObservingHandlerTest.dir/channel/broadcast/test/ObservingHandlerTest.cpp.o] Error 1
make[1]: *** [CMakeFiles/ObservingHandlerTest.dir/all] Error 2
make[2]: *** [CMakeFiles/BroadcastPoolTest.dir/channel/broadcast/test/BroadcastPoolTest.cpp.o] Error 1
make[1]: *** [CMakeFiles/BroadcastPoolTest.dir/all] Error 2
Linking CXX executable bin/BootstrapTest
[ 95%] Built target BootstrapTest
Linking CXX executable bin/PipelineTest
[ 95%] Built target PipelineTest
make: *** [all] Error 2

Commenting out the tests added in commit 35005bc fixes the issue

test server restart

trying to test the server restart case with independent IOThreadPool Echo example. patch EchoClient to catch folly::AsyncSocketException in the while loop (receive input and write to pipeline), so the while loop keeps forever.

test steps like:

  1. start EchoServer
  2. start EchoClient, write “a”
  3. stop EchoServer
  4. write “a” again at Client, this write will fail.
  5. start EchoServer again.
  6. But EchoClient could not auto-recover the broken socket.

Firstly need the similar patch with issue 45, to keep the EventBase in ClientBootstrap and implement ~ClientBootstrap.

Tried to call client.connect() again in the exception handling. But assert, `eventBase_->isInEventBaseThread()’, may fail when destruct the previous pipeline inside ClientBootstrap, as IOThreadPool is set to 2 and ClientBootstrap.connect() may select a new thread for it.

Had to allocate a new ClientBootstrap or added the reconnect() function to ClientBootstrap, which used the saved EventBase in ClientBootstrap.connect() to setup connection again. Is it the correct way to handle the server process restart?

wangle/ssl/PasswordInFile override Error

Any Ideas how to fix this?

[ 56%] Building CXX object CMakeFiles/wangle.dir/deprecated/rx/Dummy.cpp.o
[ 58%] Building CXX object CMakeFiles/wangle.dir/ssl/PasswordInFile.cpp.o
In file included from /tmp/fblualib-build.Nkyraj/wangle/wangle/ssl/PasswordInFile.cpp:10:0:
/tmp/fblualib-build.Nkyraj/wangle/wangle/../wangle/ssl/PasswordInFile.h:21:8: error: ‘void wangle::PasswordInFile::getPassword(std::string&, int)’ marked override, but does not override
void getPassword(std::string& password, int size) override {
^
make[2]: *** [CMakeFiles/wangle.dir/ssl/PasswordInFile.cpp.o] Error 1
make[1]: *** [CMakeFiles/wangle.dir/all] Error 2
make: *** [all] Error 2

Compilation problem in Ubuntu 14.04 with g++-4.9

I use the wangle version 0.13.0 and the folly version 0.57.0!

[ 20%] Building CXX object CMakeFiles/wangle.dir/acceptor/Acceptor.cpp.o
In file included from /home/junhosuh/workspace/wangle/wangle/../wangle/acceptor/Acceptor.h:14:0,
from /home/junhosuh/workspace/wangle/wangle/acceptor/Acceptor.cpp:10:
/home/junhosuh/workspace/wangle/wangle/../wangle/acceptor/ConnectionManager.h: In instantiation of ‘static wangle::ConnectionManager::UniquePtr wangle::ConnectionManager::makeUnique(Args&& ...) [with Args = {folly::EventBase_&, const std::chrono::duration<long int, std::ratio<1l, 1000l> >&, wangle::Acceptor_}; wangle::ConnectionManager::UniquePtr = std::unique_ptr<wangle::ConnectionManager, folly::DelayedDestruction::Destructor>]’:
/home/junhosuh/workspace/wangle/wangle/acceptor/Acceptor.cpp:87:54: required from here
/home/junhosuh/workspace/wangle/wangle/../wangle/acceptor/ConnectionManager.h:64:34: error: no matching function for call to ‘make_unique(folly::EventBase_&, const std::chrono::duration<long int, std::ratio<1l, 1000l> >&, wangle::Acceptor_)’
std::forward(args)...);
^
/home/junhosuh/workspace/wangle/wangle/../wangle/acceptor/ConnectionManager.h:64:34: note: candidates are:
In file included from /usr/local/include/folly/io/Cursor.h:31:0,
from /usr/local/include/folly/io/async/AsyncSSLSocket.h:32,
from /home/junhosuh/workspace/wangle/wangle/../wangle/ssl/SSLUtil.h:14,
from /home/junhosuh/workspace/wangle/wangle/../wangle/acceptor/ServerSocketConfig.h:15,
from /home/junhosuh/workspace/wangle/wangle/../wangle/acceptor/Acceptor.h:12,
from /home/junhosuh/workspace/wangle/wangle/acceptor/Acceptor.cpp:10:
/usr/local/include/folly/Memory.h:48:1: note: template<class T, class ... Args> typename std::enable_if<(! std::is_array< >::value), std::unique_ptr >::type folly::make_unique(Args&& ...)
make_unique(Args&&... args) {
^
/usr/local/include/folly/Memory.h:48:1: note: template argument deduction/substitution failed:
In file included from /home/junhosuh/workspace/wangle/wangle/../wangle/acceptor/Acceptor.h:14:0,
from /home/junhosuh/workspace/wangle/wangle/acceptor/Acceptor.cpp:10:
/home/junhosuh/workspace/wangle/wangle/../wangle/acceptor/ConnectionManager.h:64:34: note: cannot convert ‘std::forwardfolly::EventBase*&((* & args#0))’ (type ‘folly::EventBase_’) to type ‘folly::DelayedDestruction::Destructor&&’
std::forward(args)...);
^
In file included from /usr/local/include/folly/io/Cursor.h:31:0,
from /usr/local/include/folly/io/async/AsyncSSLSocket.h:32,
from /home/junhosuh/workspace/wangle/wangle/../wangle/ssl/SSLUtil.h:14,
from /home/junhosuh/workspace/wangle/wangle/../wangle/acceptor/ServerSocketConfig.h:15,
from /home/junhosuh/workspace/wangle/wangle/../wangle/acceptor/Acceptor.h:12,
from /home/junhosuh/workspace/wangle/wangle/acceptor/Acceptor.cpp:10:
/usr/local/include/folly/Memory.h:55:1: note: template typename std::enable_if<std::is_array< >::value, std::unique_ptr >::type folly::make_unique(size_t)
make_unique(const size_t n) {
^
/usr/local/include/folly/Memory.h:55:1: note: template argument deduction/substitution failed:
In file included from /home/junhosuh/workspace/wangle/wangle/../wangle/acceptor/Acceptor.h:14:0,
from /home/junhosuh/workspace/wangle/wangle/acceptor/Acceptor.cpp:10:
/home/junhosuh/workspace/wangle/wangle/../wangle/acceptor/ConnectionManager.h:64:34: error: wrong number of template arguments (2, should be 1)
std::forward(args)...);
^
In file included from /usr/local/include/folly/io/Cursor.h:31:0,
from /usr/local/include/folly/io/async/AsyncSSLSocket.h:32,
from /home/junhosuh/workspace/wangle/wangle/../wangle/ssl/SSLUtil.h:14,
from /home/junhosuh/workspace/wangle/wangle/../wangle/acceptor/ServerSocketConfig.h:15,
from /home/junhosuh/workspace/wangle/wangle/../wangle/acceptor/Acceptor.h:12,
from /home/junhosuh/workspace/wangle/wangle/acceptor/Acceptor.cpp:10:
/usr/local/include/folly/Memory.h:63:1: note: template<class T, class ... Args> typename std::enable_if<(std::extent<Tp>::value != 0), std::unique_ptr >::type folly::make_unique(Args&& ...)
make_unique(Args&&...) = delete;
^
/usr/local/include/folly/Memory.h:63:1: note: template argument deduction/substitution failed:
/usr/local/include/folly/Memory.h: In substitution of ‘template<class T, class ... Args> typename std::enable_if<(std::extent<Tp>::value != 0), std::unique_ptr >::type folly::make_unique(Args&& ...) [with T = wangle::ConnectionManager; Args = {folly::DelayedDestruction::Destructor}]’:
/home/junhosuh/workspace/wangle/wangle/../wangle/acceptor/ConnectionManager.h:64:34: required from ‘static wangle::ConnectionManager::UniquePtr wangle::ConnectionManager::makeUnique(Args&& ...) [with Args = {folly::EventBase
&, const std::chrono::duration<long int, std::ratio<1l, 1000l> >&, wangle::Acceptor
}; wangle::ConnectionManager::UniquePtr = std::unique_ptr<wangle::ConnectionManager, folly::DelayedDestruction::Destructor>]’
/home/junhosuh/workspace/wangle/wangle/acceptor/Acceptor.cpp:87:54: required from here
/usr/local/include/folly/Memory.h:63:1: error: no type named ‘type’ in ‘struct std::enable_if<false, std::unique_ptr<wangle::ConnectionManager, std::default_deletewangle::ConnectionManager > >’
make[2]: *_* [CMakeFiles/wangle.dir/acceptor/Acceptor.cpp.o] Error 1
make[1]: *** [CMakeFiles/wangle.dir/all] Error 2
make: *** [all] Error 2

wangle tests segfaults

Hello,

I built folly and wangle on linux (RHEL, gcc-4.8). Few of the tests fail with segfaults:

$ ./build/bin/ConnectionManagerTest
[==========] Running 12 tests from 1 test case.
[----------] Global test environment set-up.
[----------] 12 tests from ConnectionManagerTest
[ RUN      ] ConnectionManagerTest.testShutdownSequence
*** Aborted at 1467472772 (unix time) try "date -d @1467472772" if you are using GNU date ***
PC: @           0x49b7d4 __gnu_cxx::__exchange_and_add()
*** SIGSEGV (@0x9) received by PID 26785 (TID 0x7f5cb0f36800) from PID 9; stack trace: ***
    @       0x3ab2a0f710 (unknown)
    @           0x49b7d4 __gnu_cxx::__exchange_and_add()
    @           0x49b834 __gnu_cxx::__exchange_and_add_dispatch()
    @           0x49f34d std::_Sp_counted_base<>::_M_release()
    @           0x49e91d std::__shared_count<>::~__shared_count()
    @           0x49df8e std::__shared_ptr<>::~__shared_ptr()
    @     0x7f5cb427c3e9 std::__shared_ptr<>::operator=()
    @     0x7f5cb4276eb2 std::shared_ptr<>::operator=()
    @     0x7f5cb433ae0d folly::AsyncTimeout::scheduleTimeout()
    @           0x49c4db wangle::ConnectionManager::DrainHelper::startDrain()
    @           0x49c487 wangle::ConnectionManager::DrainHelper::startDrainAll()
    @           0x49c218 wangle::ConnectionManager::initiateGracefulShutdown()
    @           0x482404 (anonymous namespace)::ConnectionManagerTest_testShutdownSequence_Test::TestBody()
    @           0x4c2f0e testing::internal::HandleSehExceptionsInMethodIfSupported<>()
    @           0x4be15c testing::internal::HandleExceptionsInMethodIfSupported<>()
    @           0x4a5a4b testing::Test::Run()
    @           0x4a6226 testing::TestInfo::Run()
    @           0x4a68b6 testing::TestCase::Run()
    @           0x4ad0fc testing::internal::UnitTestImpl::RunAllTests()
    @           0x4c42ec testing::internal::HandleSehExceptionsInMethodIfSupported<>()
    @           0x4befb6 testing::internal::HandleExceptionsInMethodIfSupported<>()
    @           0x4abd38 testing::UnitTest::Run()
    @           0x488490 RUN_ALL_TESTS()
    @           0x48493c main
    @       0x3ab261ed5d (unknown)
    @           0x4814e9 (unknown)
[1]    26785 segmentation fault (core dumped)  ./build/bin/ConnectionManagerTest

Thanks for your help. Let me if you need more information.

Error compiling in Ubuntu 15.04

root@douglasnote:/home/douglas/projetos/filtro/lib/proxigen/proxygen/wangle/wangle# cmake .
-- Boost version: 1.54.0
-- Found the following Boost libraries:
-- system
-- thread
-- Configuring done
-- Generating done
-- Build files have been written to: /home/douglas/projetos/filtro/lib/proxigen/proxygen/wangle/wangle

root@douglasnote:/home/douglas/projetos/filtro/lib/proxigen/proxygen/wangle/wangle# make
[ 18%] Built target gmock
[ 74%] Built target wangle
[ 76%] Built target BootstrapTest
[ 79%] Built target CodecTest
[ 81%] Built target CodelTest
[ 83%] Built target GlobalExecutorTest
[ 86%] Built target OutputBufferingHandlerTest
[ 88%] Built target PipelineTest
[ 90%] Built target RxTest
[ 93%] Built target SSLCacheTest
[ 95%] Built target SSLContextManagerTest
[ 97%] Building CXX object CMakeFiles/ServiceTest.dir/service/ServiceTest.cpp.o
/home/douglas/projetos/filtro/lib/proxigen/proxygen/wangle/wangle/service/ServiceTest.cpp: In function ‘int folly::main(int, char*)’:
/home/douglas/projetos/filtro/lib/proxigen/proxygen/wangle/wangle/service/ServiceTest.cpp:324:3: error: ‘ParseCommandLineFlags’ is not a member of ‘google’
google::ParseCommandLineFlags(&argc, &argv, true);
^
make[2]: *
[CMakeFiles/ServiceTest.dir/service/ServiceTest.cpp.o] Erro 1
make[1]: ** [CMakeFiles/ServiceTest.dir/all] Erro 2
make: ** [all] Erro 2

uname -a
Linux douglasnote 3.13.0-53-generic #89-Ubuntu SMP Wed May 20 10:34:39 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux

compile error

[ 4%] Building CXX object CMakeFiles/wangle.dir/codec/LengthFieldPrepender.cpp.o
In file included from /usr/local/include/folly/futures/Promise-inl.h:23:0,
from /usr/local/include/folly/futures/Promise.h:115,
from /usr/local/include/folly/futures/Future.h:30,
from /home/leef/download/wangle/wangle/../wangle/channel/Handler.h:13,
from /home/leef/download/wangle/wangle/../wangle/codec/ByteToMessageCodec.h:13,
from /home/leef/download/wangle/wangle/../wangle/codec/LengthFieldPrepender.h:13,
from /home/leef/download/wangle/wangle/codec/LengthFieldPrepender.cpp:11:
/usr/local/include/folly/futures/detail/Core.h: In instantiation of ‘class folly::detail::Core’:
/usr/local/include/folly/futures/Future-inl.h:64:5: required from ‘void folly::Future::detach() [with T = void]’
/usr/local/include/folly/futures/Future-inl.h:58:10: required from ‘folly::Future::~Future() [with T = void]’
/home/leef/download/wangle/wangle/codec/LengthFieldPrepender.cpp:90:39: required from here
/usr/local/include/folly/futures/detail/Core.h:77:3: error: static assertion failed: void futures are not supported. Use Unit instead.
static_assert(!std::is_void::value,
^
make[2]: *** [CMakeFiles/wangle.dir/codec/LengthFieldPrepender.cpp.o] Error 1
make[1]: *** [CMakeFiles/wangle.dir/all] Error 2
make: *** [all] Error 2

Problem when I make wangle in OSX

After cmake . I face the following problem when I try to make. PFB the logs of the same.

[ 49%] Building CXX object CMakeFiles/BroadcastHandlerTest.dir/channel/broadcast/test/BroadcastHandlerTest.cpp.o
In file included from /Users/nivas.thangavelu/code/wangle/wangle/channel/broadcast/test/BroadcastHandlerTest.cpp:10:
In file included from /Users/nivas.thangavelu/code/wangle/wangle/../wangle/channel/broadcast/test/Mocks.h:15:
In file included from /Users/nivas.thangavelu/code/wangle/wangle/../wangle/channel/broadcast/BroadcastHandler.h:12:
In file included from /Users/nivas.thangavelu/code/wangle/wangle/../wangle/channel/AsyncSocketHandler.h:13:
In file included from /Users/nivas.thangavelu/code/wangle/wangle/../wangle/channel/Handler.h:14:
In file included from /Users/nivas.thangavelu/code/wangle/wangle/../wangle/channel/Pipeline.h:22:
In file included from /Users/nivas.thangavelu/code/wangle/wangle/../wangle/acceptor/TransportInfo.h:12:
/Users/nivas.thangavelu/code/wangle/wangle/../wangle/ssl/SSLUtil.h:74:17: warning: 'SSL_CTX_get_ex_new_index' is deprecated: first deprecated in OS X 10.7 [-Wdeprecated-declarations]
pindex = SSL_CTX_get_ex_new_index(0, nullptr, nullptr, nullptr, nullptr);
^
/usr/include/openssl/ssl.h:1614:5: note: 'SSL_CTX_get_ex_new_index' has been explicitly marked deprecated here
int SSL_CTX_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func,
^
In file included from /Users/nivas.thangavelu/code/wangle/wangle/channel/broadcast/test/BroadcastHandlerTest.cpp:10:
In file included from /Users/nivas.thangavelu/code/wangle/wangle/../wangle/channel/broadcast/test/Mocks.h:15:
In file included from /Users/nivas.thangavelu/code/wangle/wangle/../wangle/channel/broadcast/BroadcastHandler.h:12:
In file included from /Users/nivas.thangavelu/code/wangle/wangle/../wangle/channel/AsyncSocketHandler.h:13:
In file included from /Users/nivas.thangavelu/code/wangle/wangle/../wangle/channel/Handler.h:14:
In file included from /Users/nivas.thangavelu/code/wangle/wangle/../wangle/channel/Pipeline.h:22:
In file included from /Users/nivas.thangavelu/code/wangle/wangle/../wangle/acceptor/TransportInfo.h:12:
/Users/nivas.thangavelu/code/wangle/wangle/../wangle/ssl/SSLUtil.h:81:17: warning: 'RSA_get_ex_new_index' is deprecated: first deprecated in OS X 10.7 [-Wdeprecated-declarations]
*pindex = RSA_get_ex_new_index(0, nullptr, nullptr, nullptr, nullptr);
^
/usr/include/openssl/rsa.h:389:5: note: 'RSA_get_ex_new_index' has been explicitly marked deprecated here
int RSA_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func,
^
In file included from /Users/nivas.thangavelu/code/wangle/wangle/channel/broadcast/test/BroadcastHandlerTest.cpp:10:
In file included from /Users/nivas.thangavelu/code/wangle/wangle/../wangle/channel/broadcast/test/Mocks.h:15:
In file included from /Users/nivas.thangavelu/code/wangle/wangle/../wangle/channel/broadcast/BroadcastHandler.h:12:
In file included from /Users/nivas.thangavelu/code/wangle/wangle/../wangle/channel/AsyncSocketHandler.h:13:
In file included from /Users/nivas.thangavelu/code/wangle/wangle/../wangle/channel/Handler.h:14:
In file included from /Users/nivas.thangavelu/code/wangle/wangle/../wangle/channel/Pipeline.h:22:
In file included from /Users/nivas.thangavelu/code/wangle/wangle/../wangle/acceptor/TransportInfo.h:12:
/Users/nivas.thangavelu/code/wangle/wangle/../wangle/ssl/SSLUtil.h:121:17: warning: 'SSL_SESSION_get_ex_new_index' is deprecated: first deprecated in OS X 10.7 [-Wdeprecated-declarations]
*pindex = SSL_SESSION_get_ex_new_index(
^
/usr/include/openssl/ssl.h:1609:5: note: 'SSL_SESSION_get_ex_new_index' has been explicitly marked deprecated here
int SSL_SESSION_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func,
^
3 warnings generated.
[ 49%] Linking CXX executable bin/BroadcastHandlerTest
ld: library not found for -latomic
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *
* [bin/BroadcastHandlerTest] Error 1
make[1]: *** [CMakeFiles/BroadcastHandlerTest.dir/all] Error 2
make: *** [all] Error 2

G++ exhausted the memory while compiling Acceptor.cpp

My g++ version is

% g++ --version
g++ (GCC) 6.1.1 20160510 (Red Hat 6.1.1-2)
Copyright (C) 2016 Free Software Foundation, Inc.

I don't know if it's a bug of g++ or it's a problem caused by the structure of Acceptor.cpp.

make failure

Building on Arch Linux with 8Gb of ram, no swap. Can Acceptor.o require 8Gb to compile?

[ 1%] Building CXX object CMakeFiles/wangle.dir/acceptor/Acceptor.cpp.o
virtual memory exhausted: Cannot allocate memory
CMakeFiles/wangle.dir/build.make:62: recipe for target 'CMakeFiles/wangle.dir/acceptor/Acceptor.cpp.o' failed
make[2]: *** [CMakeFiles/wangle.dir/acceptor/Acceptor.cpp.o] Error 1
CMakeFiles/Makefile2:484: recipe for target 'CMakeFiles/wangle.dir/all' failed
make[1]: *** [CMakeFiles/wangle.dir/all] Error 2
Makefile:138: recipe for target 'all' failed
make: *** [all] Error 2

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.