Browse Source

Close the listen sockets in child processes

By keeping the listen sockets open, the children were preventing the
daemon from being restarted cleanly. Once the child has forked these
listen sockets are no longer needed by that process, so can be closed.
tags/1.2
Chris Butler 10 years ago
parent
commit
0fc199d5bc
1 changed files with 4 additions and 0 deletions
  1. 4
    0
      postsrsd.c

+ 4
- 0
postsrsd.c View File

431
         conn = accept(fds[i].fd, NULL, NULL);
431
         conn = accept(fds[i].fd, NULL, NULL);
432
         if (conn < 0) continue;
432
         if (conn < 0) continue;
433
         if (fork() == 0) {
433
         if (fork() == 0) {
434
+          // close listen sockets so that we don't stop the main daemon process from restarting
435
+          close(forward_sock);
436
+          close(reverse_sock);
437
+
434
           fp = fdopen(conn, "r+");
438
           fp = fdopen(conn, "r+");
435
           if (fp == NULL) exit(EXIT_FAILURE);
439
           if (fp == NULL) exit(EXIT_FAILURE);
436
           fds[2].fd = conn;
440
           fds[2].fd = conn;

Loading…
Cancel
Save