From: Dave Watson Date: Tue, 24 Mar 2015 16:40:29 +0000 (-0700) Subject: httpserver on serverbootstrap (2) X-Git-Tag: v0.32.0~3 X-Git-Url: http://plrg.eecs.uci.edu/git/?a=commitdiff_plain;h=71b9182494ea9813ad4945915b673c5b04c3d8ee;p=folly.git httpserver on serverbootstrap (2) 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 --- diff --git a/folly/io/async/AsyncUDPServerSocket.h b/folly/io/async/AsyncUDPServerSocket.h index e424e83d..485f18b0 100644 --- a/folly/io/async/AsyncUDPServerSocket.h +++ b/folly/io/async/AsyncUDPServerSocket.h @@ -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(evb_); - socket_->bind(address); + socket_->bind(addy); } folly::SocketAddress address() const { diff --git a/folly/wangle/bootstrap/ServerBootstrap.h b/folly/wangle/bootstrap/ServerBootstrap.h index 82465988..3c3dd4fd 100644 --- a/folly/wangle/bootstrap/ServerBootstrap.h +++ b/folly/wangle/bootstrap/ServerBootstrap.h @@ -42,8 +42,14 @@ template 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(); }