Maybe called by the fcntl API being hooked.
| 57 | |
| 58 | // Maybe called by the fcntl API being hooked. |
| 59 | int kqueue_try_register(int kqfd) |
| 60 | { |
| 61 | int sys_kqfd; |
| 62 | EVENT *ev; |
| 63 | KQUEUE *kq; |
| 64 | |
| 65 | if (kqfd < 0) { |
| 66 | return -1; |
| 67 | } |
| 68 | |
| 69 | ev = fiber_io_event(); |
| 70 | if (ev == NULL) { |
| 71 | return -1; |
| 72 | } |
| 73 | |
| 74 | sys_kqfd = (int) event_handle(ev); |
| 75 | assert(sys_kqfd >= 0); |
| 76 | |
| 77 | if (kqfd != sys_kqfd) { |
| 78 | ITER iter; |
| 79 | int found = 0; |
| 80 | foreach(iter, __kqfds) { |
| 81 | KQUEUE *tmp = (KQUEUE *) iter.data; |
| 82 | if (tmp->kqfd == kqfd) { |
| 83 | found = 1; |
| 84 | break; |
| 85 | } |
| 86 | } |
| 87 | if (!found) { |
| 88 | return -1; |
| 89 | } |
| 90 | } |
| 91 | |
| 92 | kqfd = kqfd >= 0 ? dup(kqfd) : socket(AF_INET, SOCK_STREAM, 0); |
| 93 | if (kqfd < 0) { |
| 94 | msg_error("%s(%d): create fd error: %s", |
| 95 | __FILE__, __LINE__, last_serror()); |
| 96 | return -1; |
| 97 | } |
| 98 | |
| 99 | kq = kqueue_alloc(kqfd); |
| 100 | return kq->kqfd; |
| 101 | } |
| 102 | |
| 103 | /****************************************************************************/ |
| 104 |
nothing calls this directly
no test coverage detected
searching dependent graphs…