| 6 | #include "hook.h" |
| 7 | |
| 8 | socket_t WINAPI acl_fiber_socket(int domain, int type, int protocol) |
| 9 | { |
| 10 | socket_t sockfd; |
| 11 | |
| 12 | if (sys_socket == NULL) { |
| 13 | hook_once(); |
| 14 | if (sys_socket == NULL) { |
| 15 | return -1; |
| 16 | } |
| 17 | } |
| 18 | |
| 19 | sockfd = (*sys_socket)(domain, type, protocol); |
| 20 | |
| 21 | if (!var_hook_sys_api) { |
| 22 | return sockfd; |
| 23 | } |
| 24 | |
| 25 | #if 0 |
| 26 | /* We shouldn't set NON_BLOCKING where because the NON_BLOCKING will |
| 27 | * be checked in acl_fiber_connect(). -- zsx, 2022.01.21 |
| 28 | */ |
| 29 | if (sockfd != INVALID_SOCKET) { |
| 30 | non_blocking(sockfd, NON_BLOCKING); |
| 31 | } else { |
| 32 | fiber_save_errno(acl_fiber_last_error()); |
| 33 | } |
| 34 | #else |
| 35 | if (sockfd == INVALID_SOCKET) { |
| 36 | fiber_save_errno(acl_fiber_last_error()); |
| 37 | } else { |
| 38 | FILE_EVENT *fe = fiber_file_open(sockfd); |
| 39 | file_event_init(fe, sockfd); |
| 40 | } |
| 41 | #endif |
| 42 | |
| 43 | return sockfd; |
| 44 | } |
| 45 | |
| 46 | int WINAPI acl_fiber_listen(socket_t sockfd, int backlog) |
| 47 | { |
no test coverage detected
searching dependent graphs…