vcl: remove perror ldp call
[vpp.git] / src / vcl / ldp.c
index a8062b4..64155ea 100644 (file)
@@ -195,7 +195,7 @@ ldp_alloc_workers (void)
 {
   if (ldp->workers)
     return;
-  pool_alloc (ldp->workers, LDP_MAX_NWORKERS);
+  ldp->workers = vec_new (ldp_worker_ctx_t, LDP_MAX_NWORKERS);
 }
 
 static void
@@ -288,7 +288,11 @@ ldp_init (void)
   ldp_worker_ctx_t *ldpw;
   int rv;
 
-  ASSERT (!ldp->init);
+  if (ldp->init)
+    {
+      LDBG (0, "LDP is initialized already");
+      return 0;
+    }
 
   ldp_init_cfg ();
   ldp->init = 1;
@@ -308,11 +312,9 @@ ldp_init (void)
     }
   ldp->vcl_needs_real_epoll = 0;
   ldp_alloc_workers ();
-  ldpw = ldp_worker_get_current ();
 
-  pool_foreach (ldpw, ldp->workers)  {
+  vec_foreach (ldpw, ldp->workers)
     clib_memset (&ldpw->clib_time, 0, sizeof (ldpw->clib_time));
-  }
 
   LDBG (0, "LDP initialization: done!");
 
@@ -1863,7 +1865,6 @@ sendmmsg (int fd, struct mmsghdr *vmessages, unsigned int vlen, int flags)
       if (size < 0)
        {
          int errno_val = errno;
-         perror (func_str);
          clib_warning ("LDP<%d>: ERROR: fd %d (0x%x): %s() failed! "
                        "rv %d, errno = %d", getpid (), fd, fd,
                        func_str, size, errno_val);
@@ -1890,7 +1891,7 @@ recvmsg (int fd, struct msghdr * msg, int flags)
     {
       struct iovec *iov = msg->msg_iov;
       ssize_t max_deq, total = 0;
-      int i, rv;
+      int i, rv = 0;
 
       max_deq = vls_attr (vlsh, VPPCOM_ATTR_GET_NREAD, 0, 0);
       if (!max_deq)
@@ -2677,6 +2678,7 @@ ldp_epoll_pwait_eventfd (int epfd, struct epoll_event *events,
       timeout = 0;
       if (rv >= maxevents)
        goto done;
+      maxevents -= rv;
     }
   else if (PREDICT_FALSE (rv < 0))
     {
@@ -2689,7 +2691,7 @@ epoll_again:
 
   libc_evts = &events[rv];
   libc_num_ev =
-    libc_epoll_pwait (libc_epfd, libc_evts, maxevents - rv, timeout, sigmask);
+    libc_epoll_pwait (libc_epfd, libc_evts, maxevents, timeout, sigmask);
   if (libc_num_ev <= 0)
     {
       rv = rv >= 0 ? rv : -1;