vcl: fix coverity warnings
[vpp.git] / src / vcl / vppcom.c
index 773350a..be3081e 100644 (file)
@@ -795,7 +795,11 @@ vcl_intercept_sigchld_handler (int signum, siginfo_t * si, void *uc)
   if (vcl_get_worker_index () == ~0)
     return;
 
-  sigaction (SIGCHLD, &old_sa, 0);
+  if (sigaction (SIGCHLD, &old_sa, 0))
+    {
+      VERR ("couldn't restore sigchld");
+      exit (-1);
+    }
 
   wrk = vcl_worker_get_current ();
   if (wrk->forked_child == ~0)
@@ -1551,15 +1555,11 @@ vppcom_session_read_internal (uint32_t session_handle, void *buf, int n,
          e = svm_msg_q_msg_data (mq, &msg);
          svm_msg_q_unlock (mq);
          if (!vcl_is_rx_evt_for_session (e, s->session_index, is_ct))
-           {
-             vcl_handle_mq_event (wrk, e);
-             svm_msg_q_free_msg (mq, &msg);
-             continue;
-           }
+           vcl_handle_mq_event (wrk, e);
          svm_msg_q_free_msg (mq, &msg);
 
-         if (PREDICT_FALSE (s->session_state == STATE_VPP_CLOSING))
-           return 0;
+         if (PREDICT_FALSE (s->session_state == STATE_DISCONNECT))
+           return VPPCOM_ECONNRESET;
        }
     }
 
@@ -1644,15 +1644,11 @@ vppcom_session_read_segments (uint32_t session_handle,
          e = svm_msg_q_msg_data (mq, &msg);
          svm_msg_q_unlock (mq);
          if (!vcl_is_rx_evt_for_session (e, s->session_index, is_ct))
-           {
-             vcl_handle_mq_event (wrk, e);
-             svm_msg_q_free_msg (mq, &msg);
-             continue;
-           }
+           vcl_handle_mq_event (wrk, e);
          svm_msg_q_free_msg (mq, &msg);
 
-         if (PREDICT_FALSE (s->session_state == STATE_VPP_CLOSING))
-           return 0;
+         if (PREDICT_FALSE (s->session_state == STATE_DISCONNECT))
+           return VPPCOM_ECONNRESET;
        }
     }
 
@@ -1802,12 +1798,12 @@ vppcom_session_write_inline (uint32_t session_handle, void *buf, size_t n,
          if (!vcl_is_tx_evt_for_session (e, s->session_index, is_ct))
            vcl_handle_mq_event (wrk, e);
          svm_msg_q_free_msg (mq, &msg);
+
+         if (PREDICT_FALSE (!(s->session_state & STATE_OPEN)))
+           return VPPCOM_ECONNRESET;
        }
     }
 
-  if (PREDICT_FALSE (!(s->session_state & STATE_OPEN)))
-    return VPPCOM_ECONNRESET;
-
   ASSERT (FIFO_EVENT_APP_TX + 1 == SESSION_IO_EVT_CT_TX);
   et = FIFO_EVENT_APP_TX + vcl_session_is_ct (s);
   if (is_flush && !vcl_session_is_ct (s))