misc: move to new pool_foreach macros
[vpp.git] / src / vcl / vcl_locked.c
index 5758dc4..5beaecd 100644 (file)
@@ -219,7 +219,10 @@ vls_mt_add (void)
    * vcl worker with vpp. Otherwise, all threads use the same vcl worker, so
    * update the vcl worker's thread local worker index variable */
   if (vls_mt_wrk_supported ())
-    vls_register_vcl_worker ();
+    {
+      if (vppcom_worker_register () != VPPCOM_OK)
+       VERR ("failed to register worker");
+    }
   else
     vcl_set_worker_index (vlsl->vls_wrk_index);
 }
@@ -736,7 +739,7 @@ vls_share_sessions (vls_worker_t * vls_parent_wrk, vls_worker_t * vls_wrk)
   vcl_locked_session_t *vls, *parent_vls;
 
   /* *INDENT-OFF* */
-  pool_foreach (vls, vls_wrk->vls_pool, ({
+  pool_foreach (vls, vls_wrk->vls_pool)  {
     /* Initialize sharing on parent session */
     if (vls->shared_data_index == ~0)
       {
@@ -745,7 +748,7 @@ vls_share_sessions (vls_worker_t * vls_parent_wrk, vls_worker_t * vls_wrk)
        vls->shared_data_index = parent_vls->shared_data_index;
       }
     vls_share_session (vls_wrk, vls);
-  }));
+  }
   /* *INDENT-ON* */
 }
 
@@ -760,7 +763,6 @@ vls_worker_copy_on_fork (vcl_worker_t * parent_wrk)
   /*
    * init vcl worker
    */
-  wrk->vpp_event_queues = vec_dup (parent_wrk->vpp_event_queues);
   wrk->sessions = pool_dup (parent_wrk->sessions);
   wrk->session_index_by_vpp_handles =
     hash_dup (parent_wrk->session_index_by_vpp_handles);
@@ -794,7 +796,7 @@ vls_mt_acq_locks (vcl_locked_session_t * vls, vls_mt_ops_t op, int *locks_acq)
       s = vcl_session_get (wrk, vls->session_index);
       if (PREDICT_FALSE (!s))
        return;
-      is_nonblk = VCL_SESS_ATTR_TEST (s->attr, VCL_SESS_ATTR_NONBLOCK);
+      is_nonblk = vcl_session_has_attr (s, VCL_SESS_ATTR_NONBLOCK);
     }
 
   switch (op)
@@ -896,14 +898,15 @@ vls_mt_session_migrate (vcl_locked_session_t * vls)
   VDBG (1, "migrate session of worker (session): %u (%u) -> %u (%u)",
        vls->owner_vcl_wrk_index, src_sid, wrk_index, sid);
 
-  if (PREDICT_FALSE (session->is_vep && session->vep.next_sh != ~0))
+  if (PREDICT_FALSE ((session->flags & VCL_SESSION_F_IS_VEP)
+                    && session->vep.next_sh != ~0))
     {
       /* TODO: rollback? */
       VERR ("can't migrate nonempty epoll session");
       ASSERT (0);
       return;
     }
-  else if (PREDICT_FALSE (!session->is_vep &&
+  else if (PREDICT_FALSE (!(session->flags & VCL_SESSION_F_IS_VEP) &&
                          session->session_state != VCL_STATE_CLOSED))
     {
       /* TODO: rollback? */
@@ -1377,11 +1380,11 @@ vls_unshare_vcl_worker_sessions (vcl_worker_t * wrk)
   is_current = current_wrk == wrk->wrk_index;
 
   /* *INDENT-OFF* */
-  pool_foreach (s, wrk->sessions, ({
+  pool_foreach (s, wrk->sessions)  {
     vls = vls_get (vls_si_wi_to_vlsh (s->session_index, wrk->wrk_index));
     if (vls && (is_current || vls_is_shared_by_wrk (vls, current_wrk)))
       vls_unshare_session (vls, wrk);
-  }));
+  }
   /* *INDENT-ON* */
 }
 
@@ -1712,11 +1715,7 @@ vls_use_real_epoll (void)
 void
 vls_register_vcl_worker (void)
 {
-  if (vppcom_worker_register () != VPPCOM_OK)
-    {
-      VERR ("failed to register worker");
-      return;
-    }
+  vls_mt_add ();
 }
 
 /*