diff options
author | Keith Burns <alagalah@gmail.com> | 2017-10-10 17:47:38 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@fd.io> | 2017-10-10 17:47:38 +0000 |
commit | e366e723d9afac1af35529a0e959e7226d000d6f (patch) | |
tree | 89ac8dacaa1953e25914c608fd885e6be6a31124 /vcl-ldpreload | |
parent | 7e4ce408388ce1954cc079e24183ab4fed438909 (diff) | |
parent | be6a76706785f960f825220b4c89eb1f46382857 (diff) |
Merge "LD_PRELOAD epoll_wait implementation"
Diffstat (limited to 'vcl-ldpreload')
-rw-r--r-- | vcl-ldpreload/src/libvcl-ldpreload/vcom.c | 8 | ||||
-rw-r--r-- | vcl-ldpreload/src/libvcl-ldpreload/vcom_socket.c | 47 |
2 files changed, 48 insertions, 7 deletions
diff --git a/vcl-ldpreload/src/libvcl-ldpreload/vcom.c b/vcl-ldpreload/src/libvcl-ldpreload/vcom.c index 7a13249..e148ce0 100644 --- a/vcl-ldpreload/src/libvcl-ldpreload/vcom.c +++ b/vcl-ldpreload/src/libvcl-ldpreload/vcom.c @@ -2822,12 +2822,12 @@ epoll_wait (int __epfd, struct epoll_event *__events, pid, rv, __epfd, __events, __maxevents, __timeout); - if (rv != 0) + if (rv < 0) { errno = -rv; return -1; } - return 0; + return rv; } else { @@ -2883,12 +2883,12 @@ epoll_pwait (int __epfd, struct epoll_event *__events, rv, __epfd, __events, __maxevents, __timeout, __ss); - if (rv != 0) + if (rv < 0) { errno = -rv; return -1; } - return 0; + return rv; } else { diff --git a/vcl-ldpreload/src/libvcl-ldpreload/vcom_socket.c b/vcl-ldpreload/src/libvcl-ldpreload/vcom_socket.c index 415d277..560cc7f 100644 --- a/vcl-ldpreload/src/libvcl-ldpreload/vcom_socket.c +++ b/vcl-ldpreload/src/libvcl-ldpreload/vcom_socket.c @@ -2643,7 +2643,48 @@ vcom_socket_epoll_pwait (int __epfd, struct epoll_event *__events, int __maxevents, int __timeout, const __sigset_t *__ss) { - return -ENOSYS; + int rv = -EBADF; + + /* in seconds eg. 3.123456789 seconds */ + double time_to_wait = (double) 0; + + i32 vep_idx; + + /* validate __event */ + if (!__events) + { + rv = -EFAULT; + goto out; + } + + /* validate __timeout */ + if (__timeout > 0) + { + time_to_wait = (double) __timeout / (double) 1000; + } + else if (__timeout == 0) + { + time_to_wait = (double) 0; + } + else if (__timeout == -1) + { + time_to_wait = ~0; + } + else + { + rv = -EBADF; + goto out; + } + + /* get vep_idx */ + vep_idx = vcom_socket_get_vep_idx (__epfd); + if (vep_idx != INVALID_VEP_IDX) + { + rv = vppcom_epoll_wait (vep_idx, __events, + __maxevents, time_to_wait); + } +out: + return rv; } int @@ -2742,7 +2783,7 @@ vcom_socket_main_show (void) hash_foreach (epfd, vepitemidxs, vsm->epitemidxs_by_epfd, ({ - printf("\n[ "); + printf("\n[ '%04d': ", epfd); vec_foreach (vepitemidxs_var,vepitemidxs) { printf("'%04d' ", (int)vepitemidxs_var[0]); @@ -2756,7 +2797,7 @@ vcom_socket_main_show (void) hash_foreach (fd, vepitemidxs, vsm->epitemidxs_by_fd, ({ - printf("\n{ "); + printf("\n{ '%04d': ", fd); vec_foreach (vepitemidxs_var,vepitemidxs) { printf("'%04d' ", (int)vepitemidxs_var[0]); |