|
@@ -148,6 +148,7 @@ static void *server_worker(void* vArgs)
|
|
// kick the client out
|
|
// kick the client out
|
|
} else if (ret == WS_SUCCESS) {
|
|
} else if (ret == WS_SUCCESS) {
|
|
if ((cli_state = alloc_state())) {
|
|
if ((cli_state = alloc_state())) {
|
|
|
|
+ // create the new CLI contex
|
|
cli_state->num_connect = threadCtx->ssh;
|
|
cli_state->num_connect = threadCtx->ssh;
|
|
cli_state->input_state = CLI_CMD;
|
|
cli_state->input_state = CLI_CMD;
|
|
cli_state->send = cli_send;
|
|
cli_state->send = cli_send;
|
|
@@ -298,7 +299,7 @@ static void ssh_server(void *arg)
|
|
#endif
|
|
#endif
|
|
wolfSSH_Init();
|
|
wolfSSH_Init();
|
|
WOLFSSH_CTX* ctx = NULL;
|
|
WOLFSSH_CTX* ctx = NULL;
|
|
- SOCKET_T listenFd = 0;
|
|
|
|
|
|
+ static SOCKET_T ssh_listen_fd = 0;
|
|
word32 defaultHighwater = EXAMPLE_HIGHWATER_MARK;
|
|
word32 defaultHighwater = EXAMPLE_HIGHWATER_MARK;
|
|
word32 threadCount = 0;
|
|
word32 threadCount = 0;
|
|
const char multipleConnections = 0;
|
|
const char multipleConnections = 0;
|
|
@@ -337,7 +338,7 @@ static void ssh_server(void *arg)
|
|
|
|
|
|
while (sSettings.sSSH.SSHEnable) {
|
|
while (sSettings.sSSH.SSHEnable) {
|
|
word16 port = sSettings.sSSH.port;
|
|
word16 port = sSettings.sSSH.port;
|
|
- tcp_listen(&listenFd, &port, 1, false, false);
|
|
|
|
|
|
+ tcp_listen(&ssh_listen_fd, &port, 1, false, false);
|
|
|
|
|
|
do {
|
|
do {
|
|
SOCKET_T clientFd = 0;
|
|
SOCKET_T clientFd = 0;
|
|
@@ -366,7 +367,7 @@ static void ssh_server(void *arg)
|
|
wolfSSH_SetHighwater(ssh, defaultHighwater);
|
|
wolfSSH_SetHighwater(ssh, defaultHighwater);
|
|
}
|
|
}
|
|
|
|
|
|
- clientFd = accept(listenFd, (struct sockaddr*)&clientAddr,
|
|
|
|
|
|
+ clientFd = accept(ssh_listen_fd, (struct sockaddr*)&clientAddr,
|
|
&clientAddrSz);
|
|
&clientAddrSz);
|
|
if (clientFd == -1)
|
|
if (clientFd == -1)
|
|
err_sys("tcp accept failed");
|
|
err_sys("tcp accept failed");
|
|
@@ -392,7 +393,10 @@ static void ssh_server(void *arg)
|
|
server_worker(threadCtx);
|
|
server_worker(threadCtx);
|
|
#endif /* SINGLE_THREADED */
|
|
#endif /* SINGLE_THREADED */
|
|
} while (multipleConnections);
|
|
} while (multipleConnections);
|
|
- WCLOSESOCKET(listenFd);
|
|
|
|
|
|
+ if (ssh_listen_fd) {
|
|
|
|
+ WCLOSESOCKET(ssh_listen_fd);
|
|
|
|
+ ssh_listen_fd = 0;
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
wolfSSH_CTX_free(ctx);
|
|
wolfSSH_CTX_free(ctx);
|