Skip to content

Commit c6df8f6

Browse files
Merge pull request #457 from ejohnstown/child-listen
Child Listener
2 parents 57247a1 + 95431c3 commit c6df8f6

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

apps/wolfsshd/wolfsshd.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ typedef struct WOLFSSHD_CONNECTION {
102102
WOLFSSH_CTX* ctx;
103103
WOLFSSHD_AUTH* auth;
104104
int fd;
105+
int listenFd;
105106
char ip[INET_ADDRSTRLEN];
106107
} WOLFSSHD_CONNECTION;
107108

@@ -812,12 +813,14 @@ static int NewConnection(WOLFSSHD_CONNECTION* conn)
812813
if (ret == WS_SUCCESS) {
813814
if (pd == 0) {
814815
/* child process */
816+
WCLOSESOCKET(conn->listenFd);
815817
signal(SIGINT, SIG_DFL);
816818
(void)HandleConnection((void*)conn);
817819
exit(0);
818820
}
819821
else {
820822
wolfSSH_Log(WS_LOG_INFO, "[SSHD] Spawned new process %d\n", pd);
823+
WCLOSESOCKET(conn->fd);
821824
}
822825
}
823826

@@ -1049,6 +1052,7 @@ int main(int argc, char** argv)
10491052
socklen_t clientAddrSz = sizeof(clientAddr);
10501053
#endif
10511054
conn.auth = auth;
1055+
conn.listenFd = listenFd;
10521056

10531057
/* wait for a connection */
10541058
if (PendingConnection(listenFd)) {

0 commit comments

Comments
 (0)