Lines Matching refs:req
206 void uv__process_tcp_shutdown_req(uv_loop_t* loop, uv_tcp_t* stream, uv_shutdown_t *req) { in uv__process_tcp_shutdown_req() argument
209 assert(req); in uv__process_tcp_shutdown_req()
226 if (req->cb) in uv__process_tcp_shutdown_req()
227 req->cb(req, err); in uv__process_tcp_shutdown_req()
235 uv_tcp_accept_t* req; in uv__tcp_endgame() local
245 req = &handle->tcp.serv.accept_reqs[i]; in uv__tcp_endgame()
246 if (req->wait_handle != INVALID_HANDLE_VALUE) { in uv__tcp_endgame()
247 UnregisterWait(req->wait_handle); in uv__tcp_endgame()
248 req->wait_handle = INVALID_HANDLE_VALUE; in uv__tcp_endgame()
250 if (req->event_handle != NULL) { in uv__tcp_endgame()
251 CloseHandle(req->event_handle); in uv__tcp_endgame()
252 req->event_handle = NULL; in uv__tcp_endgame()
356 uv_req_t* req; in post_completion() local
359 req = (uv_req_t*) context; in post_completion()
360 assert(req != NULL); in post_completion()
361 handle = (uv_tcp_t*)req->data; in post_completion()
366 req->u.io.overlapped.InternalHigh, in post_completion()
368 &req->u.io.overlapped)) { in post_completion()
375 uv_write_t* req; in post_write_completion() local
378 req = (uv_write_t*) context; in post_write_completion()
379 assert(req != NULL); in post_write_completion()
380 handle = (uv_tcp_t*)req->handle; in post_write_completion()
385 req->u.io.overlapped.InternalHigh, in post_write_completion()
387 &req->u.io.overlapped)) { in post_write_completion()
393 static void uv__tcp_queue_accept(uv_tcp_t* handle, uv_tcp_accept_t* req) { in uv__tcp_queue_accept() argument
401 assert(req->accept_socket == INVALID_SOCKET); in uv__tcp_queue_accept()
413 SET_REQ_ERROR(req, WSAGetLastError()); in uv__tcp_queue_accept()
414 uv__insert_pending_req(loop, (uv_req_t*)req); in uv__tcp_queue_accept()
421 SET_REQ_ERROR(req, GetLastError()); in uv__tcp_queue_accept()
422 uv__insert_pending_req(loop, (uv_req_t*)req); in uv__tcp_queue_accept()
429 memset(&(req->u.io.overlapped), 0, sizeof(req->u.io.overlapped)); in uv__tcp_queue_accept()
431 assert(req->event_handle != NULL); in uv__tcp_queue_accept()
432 req->u.io.overlapped.hEvent = (HANDLE) ((ULONG_PTR) req->event_handle | 1); in uv__tcp_queue_accept()
437 (void*)req->accept_buffer, in uv__tcp_queue_accept()
442 &req->u.io.overlapped); in uv__tcp_queue_accept()
446 req->accept_socket = accept_socket; in uv__tcp_queue_accept()
448 uv__insert_pending_req(loop, (uv_req_t*)req); in uv__tcp_queue_accept()
451 req->accept_socket = accept_socket; in uv__tcp_queue_accept()
454 req->wait_handle == INVALID_HANDLE_VALUE && in uv__tcp_queue_accept()
455 !RegisterWaitForSingleObject(&req->wait_handle, in uv__tcp_queue_accept()
456 req->event_handle, post_completion, (void*) req, in uv__tcp_queue_accept()
458 SET_REQ_ERROR(req, GetLastError()); in uv__tcp_queue_accept()
459 uv__insert_pending_req(loop, (uv_req_t*)req); in uv__tcp_queue_accept()
463 SET_REQ_ERROR(req, WSAGetLastError()); in uv__tcp_queue_accept()
464 uv__insert_pending_req(loop, (uv_req_t*)req); in uv__tcp_queue_accept()
470 CloseHandle(req->event_handle); in uv__tcp_queue_accept()
471 req->event_handle = NULL; in uv__tcp_queue_accept()
478 uv_read_t* req; in uv__tcp_queue_read() local
486 req = &handle->read_req; in uv__tcp_queue_read()
487 memset(&req->u.io.overlapped, 0, sizeof(req->u.io.overlapped)); in uv__tcp_queue_read()
494 memset(&(req->u.io.overlapped), 0, sizeof(req->u.io.overlapped)); in uv__tcp_queue_read()
496 assert(req->event_handle != NULL); in uv__tcp_queue_read()
497 req->u.io.overlapped.hEvent = (HANDLE) ((ULONG_PTR) req->event_handle | 1); in uv__tcp_queue_read()
506 &req->u.io.overlapped, in uv__tcp_queue_read()
514 req->u.io.overlapped.InternalHigh = bytes; in uv__tcp_queue_read()
515 uv__insert_pending_req(loop, (uv_req_t*)req); in uv__tcp_queue_read()
519 req->wait_handle == INVALID_HANDLE_VALUE && in uv__tcp_queue_read()
520 !RegisterWaitForSingleObject(&req->wait_handle, in uv__tcp_queue_read()
521 req->event_handle, post_completion, (void*) req, in uv__tcp_queue_read()
523 SET_REQ_ERROR(req, GetLastError()); in uv__tcp_queue_read()
524 uv__insert_pending_req(loop, (uv_req_t*)req); in uv__tcp_queue_read()
528 SET_REQ_ERROR(req, WSAGetLastError()); in uv__tcp_queue_read()
529 uv__insert_pending_req(loop, (uv_req_t*)req); in uv__tcp_queue_read()
551 uv_tcp_accept_t* req; in uv__tcp_listen() local
606 req = &handle->tcp.serv.accept_reqs[i]; in uv__tcp_listen()
607 UV_REQ_INIT(req, UV_ACCEPT); in uv__tcp_listen()
608 req->accept_socket = INVALID_SOCKET; in uv__tcp_listen()
609 req->data = handle; in uv__tcp_listen()
611 req->wait_handle = INVALID_HANDLE_VALUE; in uv__tcp_listen()
613 req->event_handle = CreateEvent(NULL, 0, 0, NULL); in uv__tcp_listen()
614 if (req->event_handle == NULL) { in uv__tcp_listen()
618 req->event_handle = NULL; in uv__tcp_listen()
621 uv__tcp_queue_accept(handle, req); in uv__tcp_listen()
628 req = &handle->tcp.serv.accept_reqs[i]; in uv__tcp_listen()
629 UV_REQ_INIT(req, UV_ACCEPT); in uv__tcp_listen()
630 req->accept_socket = INVALID_SOCKET; in uv__tcp_listen()
631 req->data = handle; in uv__tcp_listen()
632 req->wait_handle = INVALID_HANDLE_VALUE; in uv__tcp_listen()
633 req->event_handle = NULL; in uv__tcp_listen()
645 uv_tcp_accept_t* req = server->tcp.serv.pending_accepts; in uv__tcp_accept() local
647 if (!req) { in uv__tcp_accept()
652 if (req->accept_socket == INVALID_SOCKET) { in uv__tcp_accept()
664 req->accept_socket, in uv__tcp_accept()
668 closesocket(req->accept_socket); in uv__tcp_accept()
676 server->tcp.serv.pending_accepts = req->next_pending; in uv__tcp_accept()
677 req->next_pending = NULL; in uv__tcp_accept()
678 req->accept_socket = INVALID_SOCKET; in uv__tcp_accept()
683 uv__tcp_queue_accept(server, req); in uv__tcp_accept()
767 static int uv__tcp_try_connect(uv_connect_t* req, in uv__tcp_try_connect() argument
829 UV_REQ_INIT(req, UV_CONNECT); in uv__tcp_try_connect()
830 req->handle = (uv_stream_t*) handle; in uv__tcp_try_connect()
831 req->cb = cb; in uv__tcp_try_connect()
832 memset(&req->u.io.overlapped, 0, sizeof(req->u.io.overlapped)); in uv__tcp_try_connect()
838 uv__insert_pending_req(loop, (uv_req_t*)req); in uv__tcp_try_connect()
848 &req->u.io.overlapped); in uv__tcp_try_connect()
854 uv__insert_pending_req(loop, (uv_req_t*)req); in uv__tcp_try_connect()
892 uv_write_t* req, in uv__tcp_write() argument
900 UV_REQ_INIT(req, UV_WRITE); in uv__tcp_write()
901 req->handle = (uv_stream_t*) handle; in uv__tcp_write()
902 req->cb = cb; in uv__tcp_write()
905 memset(&(req->u.io.overlapped), 0, sizeof(req->u.io.overlapped)); in uv__tcp_write()
907 req->event_handle = CreateEvent(NULL, 0, 0, NULL); in uv__tcp_write()
908 if (req->event_handle == NULL) { in uv__tcp_write()
911 req->u.io.overlapped.hEvent = (HANDLE) ((ULONG_PTR) req->event_handle | 1); in uv__tcp_write()
912 req->wait_handle = INVALID_HANDLE_VALUE; in uv__tcp_write()
920 &req->u.io.overlapped, in uv__tcp_write()
925 req->u.io.queued_bytes = 0; in uv__tcp_write()
929 uv__insert_pending_req(loop, (uv_req_t*) req); in uv__tcp_write()
932 req->u.io.queued_bytes = uv__count_bufs(bufs, nbufs); in uv__tcp_write()
936 handle->write_queue_size += req->u.io.queued_bytes; in uv__tcp_write()
938 !RegisterWaitForSingleObject(&req->wait_handle, in uv__tcp_write()
939 req->event_handle, post_write_completion, (void*) req, in uv__tcp_write()
941 SET_REQ_ERROR(req, GetLastError()); in uv__tcp_write()
942 uv__insert_pending_req(loop, (uv_req_t*)req); in uv__tcp_write()
946 req->u.io.queued_bytes = 0; in uv__tcp_write()
950 SET_REQ_ERROR(req, WSAGetLastError()); in uv__tcp_write()
951 uv__insert_pending_req(loop, (uv_req_t*) req); in uv__tcp_write()
983 uv_req_t* req) { in uv__process_tcp_read_req() argument
992 if (!REQ_SUCCESS(req)) { in uv__process_tcp_read_req()
1001 err = GET_REQ_SOCK_ERROR(req); in uv__process_tcp_read_req()
1017 if (req->u.io.overlapped.InternalHigh > 0) { in uv__process_tcp_read_req()
1020 req->u.io.overlapped.InternalHigh, in uv__process_tcp_read_req()
1023 if (req->u.io.overlapped.InternalHigh < handle->tcp.conn.read_buffer.len) { in uv__process_tcp_read_req()
1112 uv_write_t* req) { in uv__process_tcp_write_req() argument
1117 assert(handle->write_queue_size >= req->u.io.queued_bytes); in uv__process_tcp_write_req()
1118 handle->write_queue_size -= req->u.io.queued_bytes; in uv__process_tcp_write_req()
1123 if (req->wait_handle != INVALID_HANDLE_VALUE) { in uv__process_tcp_write_req()
1124 UnregisterWait(req->wait_handle); in uv__process_tcp_write_req()
1125 req->wait_handle = INVALID_HANDLE_VALUE; in uv__process_tcp_write_req()
1127 if (req->event_handle != NULL) { in uv__process_tcp_write_req()
1128 CloseHandle(req->event_handle); in uv__process_tcp_write_req()
1129 req->event_handle = NULL; in uv__process_tcp_write_req()
1133 if (req->cb) { in uv__process_tcp_write_req()
1134 err = uv_translate_sys_error(GET_REQ_SOCK_ERROR(req)); in uv__process_tcp_write_req()
1139 req->cb(req, err); in uv__process_tcp_write_req()
1160 uv_tcp_accept_t* req = (uv_tcp_accept_t*) raw_req; in uv__process_tcp_accept_req() local
1168 if (req->accept_socket == INVALID_SOCKET) { in uv__process_tcp_accept_req()
1173 err = GET_REQ_SOCK_ERROR(req); in uv__process_tcp_accept_req()
1178 } else if (REQ_SUCCESS(req) && in uv__process_tcp_accept_req()
1179 setsockopt(req->accept_socket, in uv__process_tcp_accept_req()
1184 req->next_pending = handle->tcp.serv.pending_accepts; in uv__process_tcp_accept_req()
1185 handle->tcp.serv.pending_accepts = req; in uv__process_tcp_accept_req()
1195 closesocket(req->accept_socket); in uv__process_tcp_accept_req()
1196 req->accept_socket = INVALID_SOCKET; in uv__process_tcp_accept_req()
1198 uv__tcp_queue_accept(handle, req); in uv__process_tcp_accept_req()
1207 uv_connect_t* req) { in uv__process_tcp_connect_req() argument
1222 } else if (REQ_SUCCESS(req)) { in uv__process_tcp_connect_req()
1237 err = GET_REQ_SOCK_ERROR(req); in uv__process_tcp_connect_req()
1239 req->cb(req, uv_translate_sys_error(err)); in uv__process_tcp_connect_req()
1455 uv_tcp_accept_t* req = &tcp->tcp.serv.accept_reqs[i]; in uv__tcp_close() local
1456 if (req->accept_socket != INVALID_SOCKET) { in uv__tcp_close()
1457 closesocket(req->accept_socket); in uv__tcp_close()
1458 req->accept_socket = INVALID_SOCKET; in uv__tcp_close()
1552 int uv__tcp_connect(uv_connect_t* req, in uv__tcp_connect() argument
1559 err = uv__tcp_try_connect(req, handle, addr, addrlen, cb); in uv__tcp_connect()