VCL_LDPRELOAD: mixed libc/vcl epoll fd's
Change-Id: Ibc82781ddef5ea0517220b9054db3d53ec348c6c
Signed-off-by: Dave Wallace <dwallacelf@gmail.com>
diff --git a/src/vcl/vcom.c b/src/vcl/vcom.c
index be1e4c5..b215771 100644
--- a/src/vcl/vcom.c
+++ b/src/vcl/vcom.c
@@ -2792,55 +2792,20 @@
int rv;
pid_t pid = getpid ();
- if (is_vcom_epfd (__epfd))
+ 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)
{
- /* 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
- {
- /* 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 @@
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_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)
{
- 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
- {
- 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 @@
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: "