diff --git a/lib/libwebsockets.c b/lib/libwebsockets.c index 95fc18ac..76dc3f5d 100644 --- a/lib/libwebsockets.c +++ b/lib/libwebsockets.c @@ -1410,11 +1410,14 @@ libwebsocket_create_context(int port, const char *interf, void *user) { int n; - int fd; - struct sockaddr_in serv_addr, cli_addr; + struct sockaddr_in serv_addr; int opt = 1; struct libwebsocket_context *context = NULL; +#ifndef LWS_NO_FORK unsigned int slen; + struct sockaddr_in cli_addr; + int fd; +#endif char *p; struct libwebsocket *wsi; #ifndef LWS_NO_EXTENSIONS @@ -1866,6 +1869,7 @@ libwebsocket_create_context(int port, const char *interf, protocols[context->count_protocols].protocol_index = context->count_protocols; +#ifndef LWS_NO_FORK fd = socket(AF_INET, SOCK_STREAM, 0); if (fd < 0) { lwsl_err("ERROR opening socket\n"); @@ -1921,7 +1925,9 @@ libwebsocket_create_context(int port, const char *interf, context->count_protocols; insert_wsi_socket_into_fds(context, wsi); +#endif } + #ifndef LWS_NO_EXTENSIONS /* * give all extensions a chance to create any per-context @@ -2083,7 +2089,12 @@ libwebsockets_broadcast(const struct libwebsocket_protocols *protocol, int n; struct libwebsocket *wsi; + if (!context) + return 1; + +#ifndef LWS_NO_FORK if (!protocol->broadcast_socket_user_fd) { +#endif /* * We are either running unforked / flat, or we are being * called from poll thread context @@ -2125,6 +2136,7 @@ libwebsockets_broadcast(const struct libwebsocket_protocols *protocol, } return 0; +#ifndef LWS_NO_FORK } /* @@ -2140,6 +2152,7 @@ libwebsockets_broadcast(const struct libwebsocket_protocols *protocol, n = send(protocol->broadcast_socket_user_fd, buf, len, MSG_NOSIGNAL); return n; +#endif } int diff --git a/lib/private-libwebsockets.h b/lib/private-libwebsockets.h index bc0567f7..526a7887 100644 --- a/lib/private-libwebsockets.h +++ b/lib/private-libwebsockets.h @@ -321,7 +321,9 @@ struct libwebsocket { LWS_SEND_BUFFER_POST_PADDING]; int rx_user_buffer_head; enum libwebsocket_write_protocol rx_frame_type; +#ifndef LWS_NO_FORK int protocol_index_for_broadcast_proxy; +#endif enum pending_timeout pending_timeout; unsigned long pending_timeout_limit; diff --git a/lib/server.c b/lib/server.c index 40cbe20e..4134d48f 100644 --- a/lib/server.c +++ b/lib/server.c @@ -297,6 +297,7 @@ int lws_server_socket_service(struct libwebsocket_context *context, insert_wsi_socket_into_fds(context, new_wsi); break; +#ifndef LWS_NO_FORK case LWS_CONNMODE_BROADCAST_PROXY_LISTENER: /* as we are listening, POLLIN means accept() is needed */ @@ -418,6 +419,7 @@ bail_prox_listener: buf + LWS_SEND_BUFFER_PRE_PADDING, len); } break; +#endif default: break; } diff --git a/test-server/test-server.c b/test-server/test-server.c index 2d9b5f81..51b65ce6 100644 --- a/test-server/test-server.c +++ b/test-server/test-server.c @@ -33,7 +33,9 @@ static int close_testing; #ifdef EXTERNAL_POLL +#ifndef LWS_NO_FORK #define LWS_NO_FORK +#endif int max_poll_elements;