File tree Expand file tree Collapse file tree 7 files changed +25
-6
lines changed
Expand file tree Collapse file tree 7 files changed +25
-6
lines changed Original file line number Diff line number Diff line change @@ -67,6 +67,9 @@ struct lws_event_loop_ops {
6767 void (* destroy_wsi )(struct lws * wsi );
6868 /* return nonzero if caller thread is not loop service thread */
6969 int (* foreign_thread )(struct lws_context * context , int tsi );
70+ /* optional: custom implementation for faking POLLIN for buffered.
71+ * return nonzero if any wsi faked */
72+ int (* fake_POLLIN_override )(struct lws_context * context , int tsi );
7073
7174 uint8_t flags ;
7275
Original file line number Diff line number Diff line change @@ -491,6 +491,7 @@ static const struct lws_event_loop_ops event_loop_ops_glib = {
491491 /* destroy_pt */ elops_destroy_pt_glib ,
492492 /* destroy wsi */ elops_destroy_wsi_glib ,
493493 /* foreign_thread */ NULL ,
494+ /* fake_POLLIN */ NULL ,
494495
495496 /* flags */ LELOF_DESTROY_FINAL ,
496497
Original file line number Diff line number Diff line change @@ -443,6 +443,7 @@ static const struct lws_event_loop_ops event_loop_ops_ev = {
443443 /* destroy_pt */ elops_destroy_pt_ev ,
444444 /* destroy wsi */ elops_destroy_wsi_ev ,
445445 /* foreign_thread */ NULL ,
446+ /* fake_POLLIN */ NULL ,
446447
447448 /* flags */ 0 ,
448449
Original file line number Diff line number Diff line change @@ -495,6 +495,7 @@ static const struct lws_event_loop_ops event_loop_ops_event = {
495495 /* destroy_pt */ elops_destroy_pt_event ,
496496 /* destroy wsi */ elops_destroy_wsi_event ,
497497 /* foreign_thread */ NULL ,
498+ /* fake_POLLIN */ NULL ,
498499
499500 /* flags */ 0 ,
500501
Original file line number Diff line number Diff line change @@ -926,6 +926,7 @@ static const struct lws_event_loop_ops event_loop_ops_uv = {
926926 /* destroy_pt */ elops_destroy_pt_uv ,
927927 /* destroy wsi */ NULL ,
928928 /* foreign_thread */ elops_foreign_thread_uv ,
929+ /* fake_POLLIN */ NULL ,
929930
930931 /* flags */ 0 ,
931932
Original file line number Diff line number Diff line change @@ -301,6 +301,7 @@ static const struct lws_event_loop_ops event_loop_ops_uloop = {
301301 /* destroy_pt */ elops_destroy_pt_uloop ,
302302 /* destroy wsi */ elops_destroy_wsi_uloop ,
303303 /* foreign_thread */ NULL ,
304+ /* fake_POLLIN */ NULL ,
304305
305306 /* flags */ 0 ,
306307
Original file line number Diff line number Diff line change @@ -40,12 +40,23 @@ lws_tls_fake_POLLIN_for_buffered(struct lws_context_per_thread *pt)
4040 struct lws * wsi = lws_container_of (p , struct lws ,
4141 tls .dll_pending_tls );
4242
43- if (wsi -> position_in_fds_table >= 0 ) {
44-
45- pt -> fds [wsi -> position_in_fds_table ].revents = (short )
46- (pt -> fds [wsi -> position_in_fds_table ].revents |
47- (pt -> fds [wsi -> position_in_fds_table ].events & LWS_POLLIN ));
48- ret |= pt -> fds [wsi -> position_in_fds_table ].revents & LWS_POLLIN ;
43+ /*
44+ * ... allow custom event loop to override our POLLIN-setting
45+ * implementation if it knows how to do it better for its case
46+ */
47+
48+ if (pt -> context -> event_loop_ops &&
49+ pt -> context -> event_loop_ops -> fake_POLLIN_override )
50+ pt -> context -> event_loop_ops -> fake_POLLIN_override (
51+ pt -> context , pt -> tid );
52+ else {
53+ if (wsi -> position_in_fds_table >= 0 ) {
54+
55+ pt -> fds [wsi -> position_in_fds_table ].revents = (short )
56+ (pt -> fds [wsi -> position_in_fds_table ].revents |
57+ (pt -> fds [wsi -> position_in_fds_table ].events & LWS_POLLIN ));
58+ ret |= pt -> fds [wsi -> position_in_fds_table ].revents & LWS_POLLIN ;
59+ }
4960 }
5061
5162 } lws_end_foreach_dll_safe (p , p1 );
You can’t perform that action at this time.
0 commit comments