MCPcopy Create free account
hub / github.com/acl-dev/acl / kqueue_try_register

Function kqueue_try_register

lib_fiber/c/src/hook/kqueue.c:59–101  ·  view source on GitHub ↗

Maybe called by the fcntl API being hooked.

Source from the content-addressed store, hash-verified

57
58// Maybe called by the fcntl API being hooked.
59int 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

Callers

nothing calls this directly

Calls 6

kqueue_allocFunction · 0.85
socketFunction · 0.70
fiber_io_eventFunction · 0.50
event_handleFunction · 0.50
msg_errorFunction · 0.50
last_serrorFunction · 0.50

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…