Lines Matching refs:handle

77 static void uv__fast_poll_submit_poll_req(uv_loop_t* loop, uv_poll_t* handle) {  in uv__fast_poll_submit_poll_req()  argument
83 if (handle->submitted_events_1 == 0) { in uv__fast_poll_submit_poll_req()
84 req = &handle->poll_req_1; in uv__fast_poll_submit_poll_req()
85 afd_poll_info = &handle->afd_poll_info_1; in uv__fast_poll_submit_poll_req()
86 handle->submitted_events_1 = handle->events; in uv__fast_poll_submit_poll_req()
87 handle->mask_events_1 = 0; in uv__fast_poll_submit_poll_req()
88 handle->mask_events_2 = handle->events; in uv__fast_poll_submit_poll_req()
89 } else if (handle->submitted_events_2 == 0) { in uv__fast_poll_submit_poll_req()
90 req = &handle->poll_req_2; in uv__fast_poll_submit_poll_req()
91 afd_poll_info = &handle->afd_poll_info_2; in uv__fast_poll_submit_poll_req()
92 handle->submitted_events_2 = handle->events; in uv__fast_poll_submit_poll_req()
93 handle->mask_events_1 = handle->events; in uv__fast_poll_submit_poll_req()
94 handle->mask_events_2 = 0; in uv__fast_poll_submit_poll_req()
109 afd_poll_info->Handles[0].Handle = (HANDLE) handle->socket; in uv__fast_poll_submit_poll_req()
113 if (handle->events & UV_READABLE) { in uv__fast_poll_submit_poll_req()
117 if (handle->events & UV_DISCONNECT) { in uv__fast_poll_submit_poll_req()
121 if (handle->events & UV_WRITABLE) { in uv__fast_poll_submit_poll_req()
127 result = uv__msafd_poll((SOCKET) handle->peer_socket, in uv__fast_poll_submit_poll_req()
139 static void uv__fast_poll_process_poll_req(uv_loop_t* loop, uv_poll_t* handle, in uv__fast_poll_process_poll_req() argument
144 if (req == &handle->poll_req_1) { in uv__fast_poll_process_poll_req()
145 afd_poll_info = &handle->afd_poll_info_1; in uv__fast_poll_process_poll_req()
146 handle->submitted_events_1 = 0; in uv__fast_poll_process_poll_req()
147 mask_events = handle->mask_events_1; in uv__fast_poll_process_poll_req()
148 } else if (req == &handle->poll_req_2) { in uv__fast_poll_process_poll_req()
149 afd_poll_info = &handle->afd_poll_info_2; in uv__fast_poll_process_poll_req()
150 handle->submitted_events_2 = 0; in uv__fast_poll_process_poll_req()
151 mask_events = handle->mask_events_2; in uv__fast_poll_process_poll_req()
160 if (error != WSAEINTR && handle->events != 0) { in uv__fast_poll_process_poll_req()
161 handle->events = 0; /* Stop the watcher */ in uv__fast_poll_process_poll_req()
162 handle->poll_cb(handle, uv_translate_sys_error(error), 0); in uv__fast_poll_process_poll_req()
180 events &= handle->events & ~mask_events; in uv__fast_poll_process_poll_req()
184 handle->events = 0; in uv__fast_poll_process_poll_req()
185 if (uv__is_active(handle)) in uv__fast_poll_process_poll_req()
186 uv__handle_stop(handle); in uv__fast_poll_process_poll_req()
190 handle->poll_cb(handle, 0, events); in uv__fast_poll_process_poll_req()
194 if ((handle->events & ~(handle->submitted_events_1 | in uv__fast_poll_process_poll_req()
195 handle->submitted_events_2)) != 0) { in uv__fast_poll_process_poll_req()
196 uv__fast_poll_submit_poll_req(loop, handle); in uv__fast_poll_process_poll_req()
197 } else if ((handle->flags & UV_HANDLE_CLOSING) && in uv__fast_poll_process_poll_req()
198 handle->submitted_events_1 == 0 && in uv__fast_poll_process_poll_req()
199 handle->submitted_events_2 == 0) { in uv__fast_poll_process_poll_req()
200 uv__want_endgame(loop, (uv_handle_t*) handle); in uv__fast_poll_process_poll_req()
271 uv_poll_t* handle = (uv_poll_t*) req->data; in uv__slow_poll_thread_proc() local
277 assert(handle->type == UV_POLL); in uv__slow_poll_thread_proc()
280 if (handle->events & UV_READABLE) { in uv__slow_poll_thread_proc()
282 rfds.fd_array[0] = handle->socket; in uv__slow_poll_thread_proc()
287 if (handle->events & UV_WRITABLE) { in uv__slow_poll_thread_proc()
289 wfds.fd_array[0] = handle->socket; in uv__slow_poll_thread_proc()
291 efds.fd_array[0] = handle->socket; in uv__slow_poll_thread_proc()
305 SET_REQ_ERROR(&handle->poll_req_1, WSAGetLastError()); in uv__slow_poll_thread_proc()
306 POST_COMPLETION_FOR_REQ(handle->loop, req); in uv__slow_poll_thread_proc()
315 assert(rfds.fd_array[0] == handle->socket); in uv__slow_poll_thread_proc()
321 assert(wfds.fd_array[0] == handle->socket); in uv__slow_poll_thread_proc()
325 assert(efds.fd_array[0] == handle->socket); in uv__slow_poll_thread_proc()
332 POST_COMPLETION_FOR_REQ(handle->loop, req); in uv__slow_poll_thread_proc()
338 static void uv__slow_poll_submit_poll_req(uv_loop_t* loop, uv_poll_t* handle) { in uv__slow_poll_submit_poll_req() argument
342 if (handle->submitted_events_1 == 0) { in uv__slow_poll_submit_poll_req()
343 req = &handle->poll_req_1; in uv__slow_poll_submit_poll_req()
344 handle->submitted_events_1 = handle->events; in uv__slow_poll_submit_poll_req()
345 handle->mask_events_1 = 0; in uv__slow_poll_submit_poll_req()
346 handle->mask_events_2 = handle->events; in uv__slow_poll_submit_poll_req()
347 } else if (handle->submitted_events_2 == 0) { in uv__slow_poll_submit_poll_req()
348 req = &handle->poll_req_2; in uv__slow_poll_submit_poll_req()
349 handle->submitted_events_2 = handle->events; in uv__slow_poll_submit_poll_req()
350 handle->mask_events_1 = handle->events; in uv__slow_poll_submit_poll_req()
351 handle->mask_events_2 = 0; in uv__slow_poll_submit_poll_req()
368 static void uv__slow_poll_process_poll_req(uv_loop_t* loop, uv_poll_t* handle, in uv__slow_poll_process_poll_req() argument
373 if (req == &handle->poll_req_1) { in uv__slow_poll_process_poll_req()
374 handle->submitted_events_1 = 0; in uv__slow_poll_process_poll_req()
375 mask_events = handle->mask_events_1; in uv__slow_poll_process_poll_req()
376 } else if (req == &handle->poll_req_2) { in uv__slow_poll_process_poll_req()
377 handle->submitted_events_2 = 0; in uv__slow_poll_process_poll_req()
378 mask_events = handle->mask_events_2; in uv__slow_poll_process_poll_req()
386 if (handle->events != 0) { in uv__slow_poll_process_poll_req()
388 handle->events = 0; /* Stop the watcher */ in uv__slow_poll_process_poll_req()
389 handle->poll_cb(handle, uv_translate_sys_error(err), 0); in uv__slow_poll_process_poll_req()
393 int events = req->u.io.overlapped.InternalHigh & handle->events & ~mask_events; in uv__slow_poll_process_poll_req()
395 handle->poll_cb(handle, 0, events); in uv__slow_poll_process_poll_req()
399 if ((handle->events & ~(handle->submitted_events_1 | in uv__slow_poll_process_poll_req()
400 handle->submitted_events_2)) != 0) { in uv__slow_poll_process_poll_req()
401 uv__slow_poll_submit_poll_req(loop, handle); in uv__slow_poll_process_poll_req()
402 } else if ((handle->flags & UV_HANDLE_CLOSING) && in uv__slow_poll_process_poll_req()
403 handle->submitted_events_1 == 0 && in uv__slow_poll_process_poll_req()
404 handle->submitted_events_2 == 0) { in uv__slow_poll_process_poll_req()
405 uv__want_endgame(loop, (uv_handle_t*) handle); in uv__slow_poll_process_poll_req()
410 int uv_poll_init(uv_loop_t* loop, uv_poll_t* handle, int fd) { in uv_poll_init() argument
411 return uv_poll_init_socket(loop, handle, (SOCKET) uv__get_osfhandle(fd)); in uv_poll_init()
415 int uv_poll_init_socket(uv_loop_t* loop, uv_poll_t* handle, in uv_poll_init_socket() argument
447 uv__handle_init(loop, (uv_handle_t*) handle, UV_POLL); in uv_poll_init_socket()
448 handle->socket = socket; in uv_poll_init_socket()
449 handle->events = 0; in uv_poll_init_socket()
468 handle->peer_socket = peer_socket; in uv_poll_init_socket()
471 handle->flags |= UV_HANDLE_POLL_SLOW; in uv_poll_init_socket()
475 handle->submitted_events_1 = 0; in uv_poll_init_socket()
476 UV_REQ_INIT(&handle->poll_req_1, UV_POLL_REQ); in uv_poll_init_socket()
477 handle->poll_req_1.data = handle; in uv_poll_init_socket()
479 handle->submitted_events_2 = 0; in uv_poll_init_socket()
480 UV_REQ_INIT(&handle->poll_req_2, UV_POLL_REQ); in uv_poll_init_socket()
481 handle->poll_req_2.data = handle; in uv_poll_init_socket()
487 static int uv__poll_set(uv_poll_t* handle, int events, uv_poll_cb cb) { in uv__poll_set() argument
490 assert(handle->type == UV_POLL); in uv__poll_set()
491 assert(!(handle->flags & UV_HANDLE_CLOSING)); in uv__poll_set()
495 handle->events = events; in uv__poll_set()
496 handle->poll_cb = cb; in uv__poll_set()
498 if (handle->events == 0) { in uv__poll_set()
499 uv__handle_stop(handle); in uv__poll_set()
503 uv__handle_start(handle); in uv__poll_set()
504 submitted_events = handle->submitted_events_1 | handle->submitted_events_2; in uv__poll_set()
506 if (handle->events & ~submitted_events) { in uv__poll_set()
507 if (handle->flags & UV_HANDLE_POLL_SLOW) { in uv__poll_set()
508 uv__slow_poll_submit_poll_req(handle->loop, handle); in uv__poll_set()
510 uv__fast_poll_submit_poll_req(handle->loop, handle); in uv__poll_set()
518 int uv_poll_start(uv_poll_t* handle, int events, uv_poll_cb cb) { in uv_poll_start() argument
519 return uv__poll_set(handle, events, cb); in uv_poll_start()
523 int uv_poll_stop(uv_poll_t* handle) { in uv_poll_stop() argument
524 return uv__poll_set(handle, 0, handle->poll_cb); in uv_poll_stop()
528 void uv__process_poll_req(uv_loop_t* loop, uv_poll_t* handle, uv_req_t* req) { in uv__process_poll_req() argument
529 if (!(handle->flags & UV_HANDLE_POLL_SLOW)) { in uv__process_poll_req()
530 uv__fast_poll_process_poll_req(loop, handle, req); in uv__process_poll_req()
532 uv__slow_poll_process_poll_req(loop, handle, req); in uv__process_poll_req()
537 int uv__poll_close(uv_loop_t* loop, uv_poll_t* handle) { in uv__poll_close() argument
542 handle->events = 0; in uv__poll_close()
543 uv__handle_closing(handle); in uv__poll_close()
545 if (handle->submitted_events_1 == 0 && in uv__poll_close()
546 handle->submitted_events_2 == 0) { in uv__poll_close()
547 uv__want_endgame(loop, (uv_handle_t*) handle); in uv__poll_close()
551 if (handle->flags & UV_HANDLE_POLL_SLOW) in uv__poll_close()
559 afd_poll_info.Handles[0].Handle = (HANDLE) handle->socket; in uv__poll_close()
563 result = uv__msafd_poll(handle->socket, in uv__poll_close()
578 void uv__poll_endgame(uv_loop_t* loop, uv_poll_t* handle) { in uv__poll_endgame() argument
579 assert(handle->flags & UV_HANDLE_CLOSING); in uv__poll_endgame()
580 assert(!(handle->flags & UV_HANDLE_CLOSED)); in uv__poll_endgame()
582 assert(handle->submitted_events_1 == 0); in uv__poll_endgame()
583 assert(handle->submitted_events_2 == 0); in uv__poll_endgame()
585 uv__handle_close(handle); in uv__poll_endgame()