C websockify: add --run-once option.

This commit is contained in:
Joel Martin
2012-04-13 10:36:16 -05:00
parent aef7ab3a57
commit 37c0c80a93
3 changed files with 23 additions and 4 deletions
+14 -2
View File
@@ -754,11 +754,23 @@ void start_server() {
handler_msg("got client connection from %s\n",
inet_ntoa(cli_addr.sin_addr));
handler_msg("forking handler process\n");
pid = fork();
if (!settings.run_once) {
handler_msg("forking handler process\n");
pid = fork();
}
if (pid == 0) { // handler process
ws_ctx = do_handshake(csock);
if (settings.run_once) {
if (ws_ctx == NULL) {
// Not a real WebSocket connection
continue;
} else {
// Successful connection, stop listening for new
// connections
close(lsock);
}
}
if (ws_ctx == NULL) {
handler_msg("No connection after handshake\n");
break; // Child process exits