2859: fix websockets behavior in net_socket_read_wait r=def- a=QingGo



Co-authored-by: 清歌 <zyqingjohn@qq.com>
This commit is contained in:
bors[bot] 2020-09-18 13:30:44 +00:00 committed by GitHub
commit 32b0e52ebb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 2 deletions

View file

@ -2233,7 +2233,10 @@ int net_socket_read_wait(NETSOCKET sock, int time)
{
int maxfd = websocket_fd_set(sock.web_ipv4sock, &readfds);
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)