fix websockets behavior in net_socket_read_wait

This commit is contained in:
清歌 2020-09-18 21:18:31 +08:00
parent 4317cb7af8
commit 059a2a0a35
2 changed files with 9 additions and 2 deletions

View file

@ -2232,8 +2232,11 @@ int net_socket_read_wait(NETSOCKET sock, int time)
if(sock.web_ipv4sock >= 0)
{
int maxfd = websocket_fd_set(sock.web_ipv4sock, &readfds);
if (maxfd > sockid)
if(maxfd > sockid)
{
sockid = maxfd;
FD_SET(sockid, &readfds);
}
}
#endif
@ -2245,7 +2248,10 @@ int net_socket_read_wait(NETSOCKET sock, int time)
if(sock.ipv4sock >= 0 && FD_ISSET(sock.ipv4sock, &readfds))
return 1;
#if defined(CONF_WEBSOCKETS)
if(sock.web_ipv4sock >= 0 && FD_ISSET(sockid, &readfds))
return 1;
#endif
if(sock.ipv6sock >= 0 && FD_ISSET(sock.ipv6sock, &readfds))
return 1;

View file

@ -293,6 +293,7 @@ int websocket_fd_set(int socket, fd_set *set)
lws_context *context = contexts[socket].context;
if(context == NULL)
return -1;
lws_service(context, -1);
context_data *ctx_data = (context_data *)lws_context_user(context);
int max = 0;
for(auto const &x : ctx_data->port_map)