Browse Source

[1522] some more cleanup

Jelte Jansen 13 years ago
parent
commit
cccc0f378a

+ 0 - 2
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);

+ 11 - 7
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<int> 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<int> 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);
+
+
 }