facebook / wangle

Wangle is a framework providing a set of common client/server abstractions for building services in a consistent, modular, and composable way.
Apache License 2.0
3.05k stars 539 forks source link

test server restart #46

Open ghost opened 8 years ago

ghost commented 8 years ago

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?

djwatson commented 8 years ago

Unfortunately the client side of the API was never fleshed out fully. The way finagle does this is to have a connection factory underneath the client, and yea make a new connection based on the eventbase