diff options
author | Dave Wallace <dwallacelf@gmail.com> | 2017-11-02 22:04:42 -0400 |
---|---|---|
committer | Florin Coras <florin.coras@gmail.com> | 2017-11-06 00:58:20 +0000 |
commit | e695cb4dbdb6f9424ac5a567799e67f791fad328 (patch) | |
tree | d586fe252d4613f792f0618c9cb8e0d0f394846d /src/vcl/vcom.c | |
parent | 6c36f53ff0419d27f3e5720a42e0b43d5e7157f0 (diff) |
VCL_LDPRELOAD: mixed libc/vcl epoll fd's
Change-Id: Ibc82781ddef5ea0517220b9054db3d53ec348c6c
Signed-off-by: Dave Wallace <dwallacelf@gmail.com>
Diffstat (limited to 'src/vcl/vcom.c')
-rw-r--r-- | src/vcl/vcom.c | 99 |
1 files changed, 23 insertions, 76 deletions
diff --git a/src/vcl/vcom.c b/src/vcl/vcom.c index be1e4c5b47a..b215771e70c 100644 --- a/src/vcl/vcom.c +++ b/src/vcl/vcom.c @@ -2792,55 +2792,20 @@ epoll_ctl (int __epfd, int __op, int __fd, struct epoll_event *__event) int rv; pid_t pid = getpid (); - if (is_vcom_epfd (__epfd)) - { - /* TBD: currently limiting epoll to support only vcom fds */ - if (is_vcom_socket_fd (__fd)) - { - rv = vcom_epoll_ctl (__epfd, __op, __fd, __event); - if (VCOM_DEBUG > 0) - fprintf (stderr, - "[%d] epoll_ctl: " - "'%04d'='%04d', '%04d', '%04d'\n", - pid, rv, __epfd, __op, __fd); - if (rv != 0) - { - errno = -rv; - return -1; - } - return 0; - } - else - { - /* - * TBD: currently epoll does not support kernel fds - * or epoll fds */ - errno = EBADF; - return -1; - } - } - else + rv = vcom_epoll_ctl (__epfd, __op, __fd, __event); + if (VCOM_DEBUG > 0) + fprintf (stderr, + "[%d] epoll_ctl: " + "'%04d'='%04d', '%04d', '%04d'\n", pid, rv, __epfd, __op, __fd); + if (rv != 0) { - /* epfd is not an epoll file descriptor */ - errno = EINVAL; + errno = -rv; return -1; } return 0; } int -vcom_epoll_wait (int __epfd, struct epoll_event *__events, - int __maxevents, int __timeout) -{ - if (vcom_init () != 0) - { - return -1; - } - - return vcom_epoll_pwait (__epfd, __events, __maxevents, __timeout, NULL); -} - -int epoll_wait (int __epfd, struct epoll_event *__events, int __maxevents, int __timeout) { @@ -2849,50 +2814,30 @@ epoll_wait (int __epfd, struct epoll_event *__events, if (__maxevents <= 0 || __maxevents > EP_MAX_EVENTS) { + fprintf (stderr, "[%d] ERROR: epoll_wait() invalid maxevents %d\n", + pid, __maxevents); errno = EINVAL; return -1; } - if (is_vcom_epfd (__epfd)) - { - rv = vcom_epoll_wait (__epfd, __events, __maxevents, __timeout); - if (VCOM_DEBUG > 0) - fprintf (stderr, - "[%d] epoll_wait: " - "'%04d'='%04d', '%p', " - "'%04d', '%04d'\n", - pid, rv, __epfd, __events, __maxevents, __timeout); - if (rv < 0) - { - errno = -rv; - return -1; - } - return rv; - } - else + rv = + vcom_socket_epoll_pwait (__epfd, __events, __maxevents, __timeout, NULL); + if (VCOM_DEBUG > 0) + fprintf (stderr, + "[%d] epoll_wait: " + "'%04d'='%04d', '%p', " + "'%04d', '%04d'\n", + pid, rv, __epfd, __events, __maxevents, __timeout); + if (rv < 0) { - errno = EINVAL; + errno = -rv; return -1; } - return 0; + return rv; } int -vcom_epoll_pwait (int __epfd, struct epoll_event *__events, - int __maxevents, int __timeout, const __sigset_t * __ss) -{ - if (vcom_init () != 0) - { - return -1; - } - - /* implementation */ - return vcom_socket_epoll_pwait (__epfd, __events, - __maxevents, __timeout, __ss); -} - -int epoll_pwait (int __epfd, struct epoll_event *__events, int __maxevents, int __timeout, const __sigset_t * __ss) { @@ -2907,7 +2852,9 @@ epoll_pwait (int __epfd, struct epoll_event *__events, if (is_vcom_epfd (__epfd)) { - rv = vcom_epoll_pwait (__epfd, __events, __maxevents, __timeout, __ss); + rv = + vcom_socket_epoll_pwait (__epfd, __events, __maxevents, __timeout, + __ss); if (VCOM_DEBUG > 0) fprintf (stderr, "[%d] epoll_pwait: " |