httpserver on serverbootstrap (2)
authorDave Watson <davejwatson@fb.com>
Tue, 24 Mar 2015 16:40:29 +0000 (09:40 -0700)
committerNoam Lerner <noamler@fb.com>
Wed, 25 Mar 2015 22:36:07 +0000 (15:36 -0700)
Summary:
Original diff D1800100, reverted in D1895181.  Issue seems to have been caused by a copy constructor issue.

Fixes: Remove copy constructor, move contructor only. Separate stop() and join(), since join() can happen only after all stop()s have completed when reusing the same IOThreadPoolExecutors.
Test Plan: build and unit tests of relevant product

Reviewed By: praveenr@fb.com

Subscribers: trunkagent, doug, fugalh, alandau, bmatheny, mshneer, folly-diffs@, jsedgwick, yfeldblum

FB internal diff: D1901718

Tasks: 6431975

Signature: t1:1901718:1426885577:46b63bfe117df207be3d273b953c100249c1a7da

Blame Revision: D1895181

folly/io/async/AsyncUDPServerSocket.h
folly/wangle/bootstrap/ServerBootstrap.h

index e424e83d9bd4ab35ce0b9752b57cd45e37962129..485f18b03b6127212e108c50630d866f87995443 100644 (file)
@@ -82,11 +82,11 @@ class AsyncUDPServerSocket : private AsyncUDPSocket::ReadCallback
     }
   }
 
-  void bind(const folly::SocketAddress& address) {
+  void bind(const folly::SocketAddress& addy) {
     CHECK(!socket_);
 
     socket_ = folly::make_unique<AsyncUDPSocket>(evb_);
-    socket_->bind(address);
+    socket_->bind(addy);
   }
 
   folly::SocketAddress address() const {
index 82465988e7660b763706f1ce7eb02046d79cd266..3c3dd4fd874fc166276862bb91ef8b17f7301b92 100644 (file)
@@ -42,8 +42,14 @@ template <typename Pipeline>
 class ServerBootstrap {
  public:
 
+  ServerBootstrap(const ServerBootstrap& that) = delete;
+  ServerBootstrap(ServerBootstrap&& that) = default;
+
+  ServerBootstrap() {}
+
   ~ServerBootstrap() {
     stop();
+    join();
   }
 
   typedef wangle::ChannelPipeline<
@@ -222,7 +228,7 @@ class ServerBootstrap {
         new_sockets.push_back(socket);
         sock_lock.unlock();
 
-        if (port == 0) {
+        if (port <= 0) {
           socket->getAddress(&address);
           port = address.getPort();
         }
@@ -278,7 +284,9 @@ class ServerBootstrap {
       barrier.wait();
     }
     sockets_.clear();
+  }
 
+  void join() {
     if (acceptor_group_) {
       acceptor_group_->join();
     }