Browse Source

[trac366] Small fixups

Michal 'vorner' Vaner 14 years ago
parent
commit
20f12e8672
2 changed files with 11 additions and 13 deletions
  1. 4 4
      src/bin/sockcreator/README
  2. 7 9
      src/bin/sockcreator/sockcreator.cc

+ 4 - 4
src/bin/sockcreator/README

@@ -33,10 +33,10 @@ must be a socket, not pipe.
   like hton called on them).
 
   The answer to this is either 'S' and then the socket is passed using sendmsg
-  if it is successful. If it fails, 'E' is returned, followed by either
-  'S' or 'B' (either socket() or bind() call failed). Then there is one int
-  (architecture-dependent length and endianess), which is the errno value
-  after the failure.
+  if it is successful (it uses our send_fd, you can use recv_fd to read it).
+  If it fails, 'E' is returned, followed by either 'S' or 'B' (either socket()
+  or bind() call failed). Then there is one int (architecture-dependent length
+  and endianess), which is the errno value after the failure.
 
 The creator may also send these messages at any time (but not in the middle
 of another message):

+ 7 - 9
src/bin/sockcreator/sockcreator.cc

@@ -41,15 +41,6 @@ get_sock(const int type, struct sockaddr *bind_addr, const socklen_t addr_len)
     return sock;
 }
 
-int
-send_fd(const int, const int) {
-    return 0;
-}
-
-int
-run(const int input_fd, const int output_fd, const get_sock_t get_sock,
-    const send_fd_t send_fd)
-{
 // These are macros so they can exit the function
 #define READ(WHERE, HOW_MANY) do { \
         size_t how_many = (HOW_MANY); \
@@ -57,15 +48,22 @@ run(const int input_fd, const int output_fd, const get_sock_t get_sock,
             return 1; \
         } \
     } while (0)
+
 #define WRITE(WHAT, HOW_MANY) do { \
         if (!write_data(output_fd, (WHAT), (HOW_MANY))) { \
             return 2; \
         } \
     } while (0)
+
 #define DEFAULT \
     default: /* Unrecognized part of protocol */ \
         WRITE("FI", 2); \
         return 3;
+
+int
+run(const int input_fd, const int output_fd, const get_sock_t get_sock,
+    const send_fd_t send_fd)
+{
     for (;;) {
         // Read the command
         char command;