Browse Source

[805-merged] suggested changes: check non 0 result of send_fd in general;
close the function if send_fd fails.

JINMEI Tatuya 13 years ago
parent
commit
61d3224981
1 changed files with 5 additions and 1 deletions
  1. 5 1
      src/bin/sockcreator/sockcreator.cc

+ 5 - 1
src/bin/sockcreator/sockcreator.cc

@@ -131,7 +131,11 @@ run(const int input_fd, const int output_fd, const get_sock_t get_sock,
                 if (result >= 0) { // We got the socket
                 if (result >= 0) { // We got the socket
                     WRITE("S", 1);
                     WRITE("S", 1);
                     // FIXME: Check the output and write a test for it
                     // FIXME: Check the output and write a test for it
-                    if (send_fd_fun(output_fd, result) == FD_SYSTEM_ERROR) {
+                    if (send_fd_fun(output_fd, result) != 0) {
+                        // We'll soon abort ourselves, but make sure we still
+                        // close the socket; don't bother if it fails as the
+                        // higher level result (abort) is the same.
+                        close_fun(result);
                         return 3;
                         return 3;
                     }
                     }
                     // Don't leak the socket
                     // Don't leak the socket