From: Jelte Jansen Date: Thu, 22 Dec 2011 15:36:33 +0000 (+0100) Subject: [1522] some more cleanup X-Git-Tag: trac2351_base~304^2~15^2~19 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=cccc0f378a5aa81c51dc529e2b01823f00efc326;p=thirdparty%2Fkea.git [1522] some more cleanup --- diff --git a/src/lib/server_common/socket_request.h b/src/lib/server_common/socket_request.h index e208753957..fd457e364f 100644 --- a/src/lib/server_common/socket_request.h +++ b/src/lib/server_common/socket_request.h @@ -152,8 +152,6 @@ public: /// /// \param session the CC session that'll be used to talk to the /// socket creator. - /// \param socket_path the path of the domain socket that is used to - /// the pass the actual sockets around. /// \throw InvalidOperation when it is called more than once, /// when socket_path is empty static void init(config::ModuleCCSession& session); diff --git a/src/lib/server_common/tests/socket_requestor_test.cc b/src/lib/server_common/tests/socket_requestor_test.cc index c883e721dd..47160b5b6f 100644 --- a/src/lib/server_common/tests/socket_requestor_test.cc +++ b/src/lib/server_common/tests/socket_requestor_test.cc @@ -73,7 +73,6 @@ TEST(SocketRequestorAccess, initialized) { } // This class contains a fake (module)ccsession to emulate answers from Boss -// and creates a local domain socket to emulate fd_sharing class SocketRequestorTest : public ::testing::Test { public: SocketRequestorTest() : session(ElementPtr(new ListElement), @@ -260,7 +259,9 @@ TEST_F(SocketRequestorTest, testBadSocketReleaseAnswers) { SocketRequestor::SocketError); } -// Helper test class that creates a random domain socket +// Helper test class that creates a randomly named domain socket +// Upon init, it will only reserve the name (and place an empty file in its +// place). // When run() is called, it creates the socket, forks, and the child will // listen for a connection, then send all the data passed to run to that // connection, and then close the socket @@ -292,7 +293,7 @@ public: return (path_); } - // create socket, fork, and serve if child + // create socket, fork, and serve if child (child will exit when done) void run(std::vector data) { try { create(); @@ -349,8 +350,6 @@ private: // when the value is -2, it will send a byte signaling CREATOR_SOCKET_OK // first, and then one byte from some string (i.e. bad data, not using // send_fd()) - // When it runs out of data, the socket is closed and the fork exists - // (it will exit too if there is any error on this side) void serve(std::vector data) { struct sockaddr_un client_address; @@ -436,15 +435,20 @@ TEST_F(SocketRequestorTest, testSocketPassing) { socket_id = doRequest(); ASSERT_EQ("foo", socket_id.second); - // Now use first one again + // Now use first socket again addAnswer("foo", ts.getPath()); socket_id = doRequest(); ASSERT_EQ("foo", socket_id.second); - // Vector is now empty, so the socket should be gone + // Vector is of first socket is now empty, so the socket should be gone addAnswer("foo", ts.getPath()); ASSERT_THROW(doRequest(), SocketRequestor::SocketError); + // Vector is of second socket is now empty too, so the socket should be gone + addAnswer("foo", ts2.getPath()); + ASSERT_THROW(doRequest(), SocketRequestor::SocketError); + + }