vcl: fix poll support 82/40882/3
authorFlorin Coras <[email protected]>
Sat, 11 May 2024 03:28:12 +0000 (20:28 -0700)
committerFlorin Coras <[email protected]>
Tue, 3 Dec 2024 05:11:38 +0000 (21:11 -0800)
Type: fix

Change-Id: I827f19d893153277baba3c2d0efde5f2827eb0ff
Signed-off-by: Florin Coras <[email protected]>
src/vcl/ldp.c
src/vcl/vcl_locked.c
src/vcl/vcl_locked.h

index e8cabd2..e104644 100644 (file)
@@ -2734,12 +2734,19 @@ epoll_wait (int epfd, struct epoll_event *events, int maxevents, int timeout)
 int
 poll (struct pollfd *fds, nfds_t nfds, int timeout)
 {
-  ldp_worker_ctx_t *ldpw = ldp_worker_get_current ();
   int rv, i, n_revents = 0;
+  ldp_worker_ctx_t *ldpw;
   vls_handle_t vlsh;
   vcl_poll_t *vp;
   double max_time;
 
+  ldp_init_check ();
+
+  if (PREDICT_FALSE (vppcom_worker_index () == ~0))
+    vls_register_vcl_worker ();
+
+  ldpw = ldp_worker_get_current ();
+
   LDBG (3, "fds %p, nfds %ld, timeout %d", fds, nfds, timeout);
 
   if (PREDICT_FALSE (ldpw->clib_time.init_cpu_time == 0))
@@ -2780,7 +2787,7 @@ poll (struct pollfd *fds, nfds_t nfds, int timeout)
     {
       if (vec_len (ldpw->vcl_poll))
        {
-         rv = vppcom_poll (ldpw->vcl_poll, vec_len (ldpw->vcl_poll), 0);
+         rv = vls_poll (ldpw->vcl_poll, vec_len (ldpw->vcl_poll), 0);
          if (rv < 0)
            {
              errno = -rv;
index 9f3d6b5..bae1c0d 100644 (file)
@@ -1626,6 +1626,20 @@ vls_select (int n_bits, vcl_si_set * read_map, vcl_si_set * write_map,
   return rv;
 }
 
+int
+vls_poll (vcl_poll_t *vp, uint32_t n_sids, double wait_for_time)
+{
+  int rv;
+  vcl_locked_session_t *vls = NULL;
+
+  vls_mt_detect ();
+  vls_mt_guard (vls, VLS_MT_OP_XPOLL);
+  rv = vppcom_poll (vp, n_sids, wait_for_time);
+  vls_mt_unguard ();
+  vls_handle_pending_wrk_cleanup ();
+  return rv;
+}
+
 static void
 vls_unshare_vcl_worker_sessions (vcl_worker_t * wrk)
 {
index bc13140..0e747ac 100644 (file)
@@ -48,6 +48,7 @@ int vls_epoll_wait (vls_handle_t ep_vlsh, struct epoll_event *events,
                    int maxevents, double wait_for_time);
 int vls_select (int n_bits, vcl_si_set * read_map, vcl_si_set * write_map,
                vcl_si_set * except_map, double wait_for_time);
+int vls_poll (vcl_poll_t *vp, uint32_t n_sids, double wait_for_time);
 vcl_session_handle_t vlsh_to_sh (vls_handle_t vlsh);
 vcl_session_handle_t vlsh_to_session_index (vls_handle_t vlsh);
 int vlsh_to_worker_index (vls_handle_t vlsh);