mirror of
https://github.com/darlinghq/darling-libkqueue.git
synced 2024-11-26 21:20:38 +00:00
Use a special version of dup
libsystem_kernel's `sys_dup` and `sys_dup2` call `kqueue_dup`, so if we use the normal `dup` call in libkqueue, we end up recursing back into libkqueue (unecessarily).
This commit is contained in:
parent
f3f8cb99b0
commit
8b748d1070
@ -69,7 +69,9 @@ extern long int syscall (long int __sysno, ...);
|
||||
*/
|
||||
#define KNOTE_PLATFORM_SPECIFIC \
|
||||
int kn_epollfd; /* A copy of filter->epfd */ \
|
||||
char kn_extra_buffer[64]; /* Extra data buffer used by some filters (EVFILT_MACHPORT) */ \
|
||||
union { \
|
||||
char kn_extra_buffer[64]; /* Extra data buffer used by some filters (EVFILT_MACHPORT) */ \
|
||||
}; \
|
||||
union { \
|
||||
int kn_timerfd; \
|
||||
int kn_signalfd; \
|
||||
|
@ -28,6 +28,8 @@
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <darling/emulation/ext/for-libkqueue.h>
|
||||
|
||||
#include "private.h"
|
||||
|
||||
/*
|
||||
@ -185,7 +187,7 @@ evfilt_read_knote_create(struct filter *filt, struct knote *kn)
|
||||
return (0);
|
||||
}
|
||||
else {
|
||||
kn->kdata.kn_dupfd = dup(kn->kev.ident);
|
||||
kn->kdata.kn_dupfd = _dup_4libkqueue(kn->kev.ident);
|
||||
fcntl(kn->kdata.kn_dupfd, F_SETFD, FD_CLOEXEC);
|
||||
if (epoll_ctl(kn->kn_epollfd, EPOLL_CTL_ADD, kn->kdata.kn_dupfd, &ev) < 0) {
|
||||
dbg_printf("epoll_ctl(2): %s", strerror(errno));
|
||||
|
@ -28,6 +28,8 @@
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <darling/emulation/ext/for-libkqueue.h>
|
||||
|
||||
#include "private.h"
|
||||
|
||||
int
|
||||
@ -82,7 +84,7 @@ evfilt_socket_knote_create(struct filter *filt, struct knote *kn)
|
||||
ev.data.ptr = kn;
|
||||
|
||||
/* Duplicate the fd to workaround epoll's poor design */
|
||||
kn->kdata.kn_dupfd = dup(kn->kev.ident);
|
||||
kn->kdata.kn_dupfd = _dup_4libkqueue(kn->kev.ident);
|
||||
|
||||
if (epoll_ctl(kn->kn_epollfd, EPOLL_CTL_ADD, kn->kdata.kn_dupfd, &ev) < 0) {
|
||||
dbg_printf("epoll_ctl(2): %s", strerror(errno));
|
||||
|
Loading…
Reference in New Issue
Block a user