@@ -59,7 +59,7 @@ static SgObject wait_selector(unix_context_t *ctx, int nsock,
59
59
{
60
60
SgObject cp , r = SG_NIL ;
61
61
int i , c , n = nsock + 1 ;
62
- struct kevent * evm , ev ;
62
+ struct kevent * evm ;
63
63
64
64
evm = SG_NEW_ATOMIC2 (struct kevent * , n * sizeof (struct kevent ));
65
65
i = 0 ;
@@ -82,10 +82,22 @@ static SgObject wait_selector(unix_context_t *ctx, int nsock,
82
82
interrupted_unix_stop (ctx );
83
83
} else if (evm [i ].filter == EVFILT_READ ) {
84
84
r = Sg_Cons (evm [i ].udata , r );
85
+ #if 0
85
86
EV_SET (& ev , evm [i ].ident , EVFILT_READ , EV_DELETE , 0 , 0 , NULL );
86
87
kevent (ctx -> fd , & ev , 1 , NULL , 0 , 0 ); /* reset event of the target socket */
88
+ #endif
87
89
}
88
90
}
91
+
92
+ i = 0 ;
93
+ SG_FOR_EACH (cp , sockets ) {
94
+ int fd = SG_SOCKET (SG_CAAR (cp ))-> socket ;
95
+ EV_SET (& evm [i ++ ], fd , EVFILT_READ , EV_DELETE , 0 , 0 , NULL );
96
+ if (i == nsock ) break ;
97
+ }
98
+ EV_SET (& evm [i ++ ], ctx -> stop_fd , EVFILT_READ , EV_DELETE , 0 , 0 , NULL );
99
+ kevent (ctx -> fd , evm , n , NULL , 0 , 0 );
100
+
89
101
return r ;
90
102
}
91
103
0 commit comments