diff --git a/lib/client-handshake.c b/lib/client-handshake.c index eed9b5ef..7fa4f90c 100644 --- a/lib/client-handshake.c +++ b/lib/client-handshake.c @@ -176,7 +176,7 @@ lws_client_connect_2(struct lws *wsi) lws_set_timeout(wsi, PENDING_TIMEOUT_AWAITING_CONNECT_RESPONSE, AWAITING_TIMEOUT); - n = lws_socket_bind(context, wsi->sock, 0, wsi->vhost->iface); + n = lws_socket_bind(wsi->vhost, wsi->sock, 0, wsi->vhost->iface); if (n < 0) goto failed; } diff --git a/lib/libwebsockets.c b/lib/libwebsockets.c index 2a242823..77096da0 100644 --- a/lib/libwebsockets.c +++ b/lib/libwebsockets.c @@ -1485,7 +1485,7 @@ lws_extension_callback_pm_deflate(struct lws_context *context, #endif LWS_EXTERN int -lws_socket_bind(struct lws_context *context, int sockfd, int port, +lws_socket_bind(struct lws_vhost *vhost, int sockfd, int port, const char *iface) { #if LWS_POSIX @@ -1502,7 +1502,7 @@ lws_socket_bind(struct lws_context *context, int sockfd, int port, struct sockaddr *v; #ifdef LWS_USE_UNIX_SOCK - if (LWS_UNIX_SOCK_ENABLED(context)) { + if (LWS_UNIX_SOCK_ENABLED(vhost)) { v = (struct sockaddr *)&serv_unix; n = sizeof(struct sockaddr_un); bzero((char *) &serv_unix, sizeof(serv_unix)); @@ -1519,7 +1519,7 @@ lws_socket_bind(struct lws_context *context, int sockfd, int port, } else #endif #ifdef LWS_USE_IPV6 - if (LWS_IPV6_ENABLED(context)) { + if (LWS_IPV6_ENABLED(vhost->context)) { v = (struct sockaddr *)&serv_addr6; n = sizeof(struct sockaddr_in6); bzero((char *) &serv_addr6, sizeof(serv_addr6)); @@ -1536,7 +1536,7 @@ lws_socket_bind(struct lws_context *context, int sockfd, int port, serv_addr4.sin_family = AF_INET; if (iface && - interface_to_sa(context, iface, + interface_to_sa(vhost->context, iface, (struct sockaddr_in *)v, n) < 0) { lwsl_err("Unable to find interface %s\n", iface); return -1; @@ -1547,7 +1547,7 @@ lws_socket_bind(struct lws_context *context, int sockfd, int port, n = bind(sockfd, v, n); #ifdef LWS_USE_UNIX_SOCK - if (n < 0 && LWS_UNIX_SOCK_ENABLED(context)) { + if (n < 0 && LWS_UNIX_SOCK_ENABLED(vhost)) { lwsl_err("ERROR on binding fd %d to \"%s\" (%d %d)\n", sockfd, iface, n, LWS_ERRNO); return -1; diff --git a/lib/private-libwebsockets.h b/lib/private-libwebsockets.h index 89ab5411..a2c938e4 100644 --- a/lib/private-libwebsockets.h +++ b/lib/private-libwebsockets.h @@ -850,10 +850,10 @@ LWS_EXTERN void lws_feature_status_libuv(struct lws_context_creation_info *info) #endif #ifdef LWS_USE_UNIX_SOCK -#define LWS_UNIX_SOCK_ENABLED(context) \ - (context->options & LWS_SERVER_OPTION_UNIX_SOCK) +#define LWS_UNIX_SOCK_ENABLED(vhost) \ + (vhost->options & LWS_SERVER_OPTION_UNIX_SOCK) #else -#define LWS_UNIX_SOCK_ENABLED(context) (0) +#define LWS_UNIX_SOCK_ENABLED(vhost) (0) #endif enum uri_path_states { URIPS_IDLE, @@ -1282,7 +1282,7 @@ struct lws { LWS_EXTERN int log_level; LWS_EXTERN int -lws_socket_bind(struct lws_context *context, int sockfd, int port, +lws_socket_bind(struct lws_vhost *vhost, int sockfd, int port, const char *iface); LWS_EXTERN void diff --git a/lib/server.c b/lib/server.c index b2ea3f6f..2b6d16e1 100644 --- a/lib/server.c +++ b/lib/server.c @@ -62,7 +62,7 @@ lws_context_init_server(struct lws_context_creation_info *info, for (m = 0; m < limit; m++) { #ifdef LWS_USE_UNIX_SOCK - if (LWS_UNIX_SOCK_ENABLED(vhost->context)) + if (LWS_UNIX_SOCK_ENABLED(vhost)) sockfd = socket(AF_UNIX, SOCK_STREAM, 0); else #endif @@ -103,7 +103,7 @@ lws_context_init_server(struct lws_context_creation_info *info, lws_plat_set_socket_options(vhost, sockfd); #if LWS_POSIX - n = lws_socket_bind(vhost->context, sockfd, info->port, info->iface); + n = lws_socket_bind(vhost, sockfd, info->port, info->iface); if (n < 0) goto bail; info->port = n; @@ -139,7 +139,7 @@ lws_context_init_server(struct lws_context_creation_info *info, #endif if (!lws_check_opt(info->options, LWS_SERVER_OPTION_EXPLICIT_VHOSTS)) { #ifdef LWS_USE_UNIX_SOCK - if (LWS_UNIX_SOCK_ENABLED(vhost->context)) + if (LWS_UNIX_SOCK_ENABLED(vhost)) lwsl_notice(" Listening on \"%s\"\n", info->iface); else #endif