pool_alloc (ldp->workers, LDP_MAX_NWORKERS);
}
-static inline int
+static int
ldp_init (void)
{
ldp_worker_ctx_t *ldpw;
int rv;
- if (PREDICT_TRUE (ldp->init))
- return 0;
+ ASSERT (!ldp->init);
ldp->init = 1;
ldp->vcl_needs_real_epoll = 1;
return 0;
}
+#define ldp_init_check() \
+ if (PREDICT_FALSE (!ldp->init)) \
+ { \
+ if ((errno = -ldp_init ())) \
+ return -1; \
+ }
+
int
close (int fd)
{
vls_handle_t vlsh;
int rv, epfd;
- if ((errno = -ldp_init ()))
- return -1;
+ ldp_init_check ();
vlsh = ldp_fd_to_vlsh (fd);
if (vlsh != VLS_INVALID_HANDLE)
vls_handle_t vlsh;
ssize_t size;
- if ((errno = -ldp_init ()))
- return -1;
+ ldp_init_check ();
vlsh = ldp_fd_to_vlsh (fd);
if (vlsh != VLS_INVALID_HANDLE)
vls_handle_t vlsh;
ssize_t size = 0;
- if ((errno = -ldp_init ()))
- return -1;
+ ldp_init_check ();
vlsh = ldp_fd_to_vlsh (fd);
if (vlsh != VLS_INVALID_HANDLE)
vls_handle_t vlsh;
ssize_t size = 0;
- if ((errno = -ldp_init ()))
- return -1;
+ ldp_init_check ();
vlsh = ldp_fd_to_vlsh (fd);
if (vlsh != VLS_INVALID_HANDLE)
vls_handle_t vlsh;
int i, rv = 0;
- if ((errno = -ldp_init ()))
- return -1;
+ ldp_init_check ();
vlsh = ldp_fd_to_vlsh (fd);
if (vlsh != VLS_INVALID_HANDLE)
va_list ap;
int rv;
- if ((errno = -ldp_init ()))
- return -1;
+ ldp_init_check ();
va_start (ap, cmd);
rv = fcntl_internal (fd, cmd, ap);
va_list ap;
int rv;
- if ((errno = -ldp_init ()))
- return -1;
+ ldp_init_check ();
va_start (ap, cmd);
rv = fcntl_internal (fd, cmd, ap);
va_list ap;
int rv;
- if ((errno = -ldp_init ()))
- return -1;
+ ldp_init_check ();
va_start (ap, cmd);
u8 is_nonblocking = type & SOCK_NONBLOCK ? 1 : 0;
vls_handle_t vlsh;
- if ((errno = -ldp_init ()))
- return -1;
+ ldp_init_check ();
if (((domain == AF_INET) || (domain == AF_INET6)) &&
((sock_type == SOCK_STREAM) || (sock_type == SOCK_DGRAM)))
{
int rv, sock_type = type & ~(SOCK_CLOEXEC | SOCK_NONBLOCK);
- if ((errno = -ldp_init ()))
- return -1;
+ ldp_init_check ();
if (((domain == AF_INET) || (domain == AF_INET6)) &&
((sock_type == SOCK_STREAM) || (sock_type == SOCK_DGRAM)))
vls_handle_t vlsh;
int rv;
- if ((errno = -ldp_init ()))
- return -1;
+ ldp_init_check ();
vlsh = ldp_fd_to_vlsh (fd);
if (vlsh != VLS_INVALID_HANDLE)
int rv = 0;
int sa_len, copy_len;
- if ((errno = -ldp_init ()))
- return -1;
+ ldp_init_check ();
if (addr && len && ep)
{
vls_handle_t vlsh;
int rv;
- if ((errno = -ldp_init ()))
- return -1;
+ ldp_init_check ();
vlsh = ldp_fd_to_vlsh (fd);
if (vlsh != VLS_INVALID_HANDLE)
vls_handle_t vlsh;
int rv;
- if ((errno = -ldp_init ()))
- return -1;
+ ldp_init_check ();
if (!addr)
{
vls_handle_t vlsh;
int rv;
- if ((errno = -ldp_init ()))
- return -1;
+ ldp_init_check ();
vlsh = ldp_fd_to_vlsh (fd);
if (vlsh != VLS_INVALID_HANDLE)
vls_handle_t vlsh = ldp_fd_to_vlsh (fd);
ssize_t size;
- if ((errno = -ldp_init ()))
- return -1;
+ ldp_init_check ();
if (vlsh != VLS_INVALID_HANDLE)
{
vls_handle_t vlsh;
ssize_t size = 0;
- if ((errno = -ldp_init ()))
- return -1;
+ ldp_init_check ();
vlsh = ldp_fd_to_vlsh (out_fd);
if (vlsh != VLS_INVALID_HANDLE)
vls_handle_t vlsh;
ssize_t size;
- if ((errno = -ldp_init ()))
- return -1;
+ ldp_init_check ();
vlsh = ldp_fd_to_vlsh (fd);
if (vlsh != VLS_INVALID_HANDLE)
vls_handle_t vlsh;
ssize_t size;
- if ((errno = -ldp_init ()))
- return -1;
+ ldp_init_check ();
vlsh = ldp_fd_to_vlsh (fd);
if (vlsh != INVALID_SESSION_ID)
vls_handle_t vlsh;
ssize_t size;
- if ((errno = -ldp_init ()))
- return -1;
+ ldp_init_check ();
vlsh = ldp_fd_to_vlsh (fd);
if (vlsh != VLS_INVALID_HANDLE)
vls_handle_t vlsh;
ssize_t size;
- if ((errno = -ldp_init ()))
- return -1;
+ ldp_init_check ();
vlsh = ldp_fd_to_vlsh (fd);
if (vlsh != VLS_INVALID_HANDLE)
const char *func_str;
u32 sh = ldp_fd_to_vlsh (fd);
- if ((errno = -ldp_init ()))
- return -1;
+ ldp_init_check ();
if (sh != INVALID_SESSION_ID)
{
vls_handle_t vlsh;
ssize_t size;
- if ((errno = -ldp_init ()))
- return -1;
+ ldp_init_check ();
vlsh = ldp_fd_to_vlsh (fd);
if (vlsh != VLS_INVALID_HANDLE)
const char *func_str;
u32 sh = ldp_fd_to_vlsh (fd);
- if ((errno = -ldp_init ()))
- return -1;
+ ldp_init_check ();
if (sh != INVALID_SESSION_ID)
{
vls_handle_t vlsh;
int rv;
- if ((errno = -ldp_init ()))
- return -1;
+ ldp_init_check ();
vlsh = ldp_fd_to_vlsh (fd);
if (vlsh != VLS_INVALID_HANDLE)
vls_handle_t vlsh;
int rv;
- if ((errno = -ldp_init ()))
- return -1;
+ ldp_init_check ();
vlsh = ldp_fd_to_vlsh (fd);
if (vlsh != VLS_INVALID_HANDLE)
vls_handle_t vlsh;
int rv;
- if ((errno = -ldp_init ()))
- return -1;
+ ldp_init_check ();
vlsh = ldp_fd_to_vlsh (fd);
if (vlsh != VLS_INVALID_HANDLE)
vls_handle_t listen_vlsh, accept_vlsh;
int rv;
- if ((errno = -ldp_init ()))
- return -1;
+ ldp_init_check ();
listen_vlsh = ldp_fd_to_vlsh (listen_fd);
if (listen_vlsh != VLS_INVALID_HANDLE)
int rv = 0, flags;
u32 flags_len = sizeof (flags);
- if ((errno = -ldp_init ()))
- return -1;
+ ldp_init_check ();
vlsh = ldp_fd_to_vlsh (fd);
if (vlsh != VLS_INVALID_HANDLE)
vls_handle_t vlsh;
int rv;
- if ((errno = -ldp_init ()))
- return -1;
+ ldp_init_check ();
if (ldp->vcl_needs_real_epoll || vls_use_real_epoll ())
{
vls_handle_t vep_vlsh, vlsh;
int rv;
- if ((errno = -ldp_init ()))
- return -1;
+ ldp_init_check ();
vep_vlsh = ldp_fd_to_vlsh (epfd);
if (PREDICT_FALSE (vep_vlsh == VLS_INVALID_HANDLE))
int libc_epfd, rv = 0;
vls_handle_t ep_vlsh;
- if ((errno = -ldp_init ()))
- return -1;
+ ldp_init_check ();
if (PREDICT_FALSE (!events || (timeout < -1)))
{
int libc_epfd, rv = 0, num_ev;
vls_handle_t ep_vlsh;
- if ((errno = -ldp_init ()))
- return -1;
+ ldp_init_check ();
if (PREDICT_FALSE (!events || (timeout < -1)))
{
ppoll (struct pollfd *fds, nfds_t nfds,
const struct timespec *timeout, const sigset_t * sigmask)
{
- if ((errno = -ldp_init ()))
- return -1;
+ ldp_init_check ();
clib_warning ("LDP<%d>: LDP-TBD", getpid ());
errno = ENOSYS;