@@ -69,8 +69,6 @@ _lws_change_pollfd(struct lws *wsi, int _and, int _or, struct lws_pollargs *pa)
69
69
context = wsi -> a .context ;
70
70
pt = & context -> pt [(int )wsi -> tsi ];
71
71
72
- assert (wsi -> position_in_fds_table < (int )pt -> fds_count );
73
-
74
72
#if !defined(LWS_WITH_EVENT_LIBS )
75
73
/*
76
74
* This only applies when we use the default poll() event loop.
@@ -112,10 +110,11 @@ _lws_change_pollfd(struct lws *wsi, int _and, int _or, struct lws_pollargs *pa)
112
110
113
111
ftp -> _and = _and ;
114
112
ftp -> _or = _or ;
115
- ftp -> fd_index = wsi -> position_in_fds_table ;
116
113
ftp -> next = NULL ;
117
114
118
115
lws_pt_lock (pt , __func__ );
116
+ assert (wsi -> position_in_fds_table < (int )pt -> fds_count );
117
+ ftp -> fd_index = wsi -> position_in_fds_table ;
119
118
120
119
/* place at END of list to maintain order */
121
120
ftp1 = (struct lws_foreign_thread_pollfd * * )
@@ -144,13 +143,16 @@ _lws_change_pollfd(struct lws *wsi, int _and, int _or, struct lws_pollargs *pa)
144
143
*/
145
144
_or |= LWS_POLLHUP ;
146
145
#endif
147
-
146
+ lws_pt_lock (pt , __func__ );
147
+ assert (wsi -> position_in_fds_table < (int )pt -> fds_count );
148
148
pfd = & pt -> fds [wsi -> position_in_fds_table ];
149
- pa -> fd = wsi -> desc .sockfd ;
150
- lwsl_wsi_debug (wsi , "fd %d events %d -> %d" , pa -> fd , pfd -> events ,
151
- (pfd -> events & ~_and ) | _or );
152
149
pa -> prev_events = pfd -> events ;
153
150
pa -> events = pfd -> events = (short )((pfd -> events & ~_and ) | _or );
151
+ lws_pt_unlock (pt );
152
+
153
+ pa -> fd = wsi -> desc .sockfd ;
154
+ lwsl_wsi_debug (wsi , "fd %d events %d -> %d" , pa -> fd , pa -> prev_events ,
155
+ pa -> events );
154
156
155
157
if (wsi -> mux_substream )
156
158
return 0 ;
@@ -621,10 +623,7 @@ lws_callback_on_writable_all_protocol_vhost(const struct lws_vhost *vhost,
621
623
lws_dll2_get_head (& vhost -> same_vh_protocol_owner [n ])) {
622
624
wsi = lws_container_of (d , struct lws , same_vh_protocol );
623
625
624
- assert (wsi -> a .protocol &&
625
- wsi -> a .protocol -> callback == protocol -> callback &&
626
- !strcmp (protocol -> name , wsi -> a .protocol -> name ));
627
-
626
+ assert (wsi -> a .protocol == protocol );
628
627
lws_callback_on_writable (wsi );
629
628
630
629
} lws_end_foreach_dll_safe (d , d1 );
0 commit comments