LD_PRELOAD poll implementation

- add poll implementation
- implementation based on vppcom_poll
- implementation based on vppcom_select
- currently vppcom_select implementation is picked

Change-Id: If6c2862ae72e9969335aca5b8085957c98287dc0
Signed-off-by: shrinivasan ganapathy <shrinivasanganapathy@gmail.com>
Signed-off-by: Dave Wallace <dwallacelf@gmail.com>
This commit is contained in:
shrinivasan ganapathy
2017-10-15 15:46:09 -07:00
committed by Keith Burns
parent 7876d39f14
commit 1d35963766
7 changed files with 749 additions and 5 deletions

File diff suppressed because it is too large Load Diff

View File

@ -178,6 +178,12 @@ extern int
vcom_epoll_pwait (int __epfd, struct epoll_event *__events,
int __maxevents, int __timeout, const __sigset_t * __ss);
/*
* NOTE: observed __nfds is less than 128 from kubecon strace files
* for the POC, it's fair to assume that nfds is less than 1024.
* TBD: make it thread safe and design to scale.
* */
#define MAX_POLL_NFDS_DEFAULT 1024
extern int vcom_poll (struct pollfd *__fds, nfds_t __nfds, int __timeout);
#ifdef __USE_GNU

View File

@ -23,6 +23,8 @@
#include <fcntl.h>
#include <sys/epoll.h>
#include <signal.h>
#include <poll.h>
/*

File diff suppressed because it is too large Load Diff

View File

@ -448,6 +448,17 @@ vcom_socket_epoll_pwait (int __epfd, struct epoll_event *__events,
int __maxevents, int __timeout,
const __sigset_t * __ss);
/*
* handle only vcom fds
*/
int vcom_socket_poll (struct pollfd *__fds, nfds_t __nfds, int __timeout);
#ifdef __USE_GNU
int
vcom_socket_ppoll (struct pollfd *__fds, nfds_t __nfds,
const struct timespec *__timeout, const __sigset_t * __ss);
#endif
#endif /* included_vcom_socket_h */
/*

View File

@ -263,6 +263,15 @@ typedef int (*__libc_epoll_pwait) (int __epfd, struct epoll_event * __events,
int __maxevents, int __timeout,
const __sigset_t * __ss);
typedef int (*__libc_poll) (struct pollfd * __fds, nfds_t __nfds,
int __timeout);
#ifdef __USE_GNU
typedef int (*__libc_ppoll) (struct pollfd * __fds, nfds_t __nfds,
const struct timespec * __timeout,
const __sigset_t * __ss);
#endif
#define SWRAP_SYMBOL_ENTRY(i) \
union { \
@ -334,6 +343,10 @@ struct swrap_libc_symbols
SWRAP_SYMBOL_ENTRY (epoll_ctl);
SWRAP_SYMBOL_ENTRY (epoll_wait);
SWRAP_SYMBOL_ENTRY (epoll_pwait);
SWRAP_SYMBOL_ENTRY (poll);
#ifdef __USE_GNU
SWRAP_SYMBOL_ENTRY (ppoll);
#endif
};
struct swrap
@ -811,6 +824,25 @@ libc_epoll_pwait (int __epfd, struct epoll_event *__events,
__ss);
}
int
libc_poll (struct pollfd *__fds, nfds_t __nfds, int __timeout)
{
swrap_bind_symbol_libc (poll);
return swrap.libc.symbols._libc_poll.f (__fds, __nfds, __timeout);
}
#ifdef __USE_GNU
int
libc_ppoll (struct pollfd *__fds, nfds_t __nfds,
const struct timespec *__timeout, const __sigset_t * __ss)
{
swrap_bind_symbol_libc (ppoll);
return swrap.libc.symbols._libc_ppoll.f (__fds, __nfds, __timeout, __ss);
}
#endif
static void
swrap_thread_prepare (void)
{

View File

@ -63,6 +63,7 @@
#include <sys/ioctl.h>
#include <sys/select.h>
#include <sys/epoll.h>
#include <poll.h>
#include <sys/uio.h>
#include <stdlib.h>
@ -212,6 +213,13 @@ int libc_epoll_pwait (int __epfd, struct epoll_event *__events,
int __maxevents, int __timeout,
const __sigset_t * __ss);
int libc_poll (struct pollfd *__fds, nfds_t __nfds, int __timeout);
#ifdef __USE_GNU
int libc_ppoll (struct pollfd *__fds, nfds_t __nfds,
const struct timespec *__timeout, const __sigset_t * __ss);
#endif
void swrap_constructor (void);
void swrap_destructor (void);