aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/uri/vppcom.c48
1 files changed, 29 insertions, 19 deletions
diff --git a/src/uri/vppcom.c b/src/uri/vppcom.c
index aa307f1d333..8a8a806caf0 100644
--- a/src/uri/vppcom.c
+++ b/src/uri/vppcom.c
@@ -852,19 +852,15 @@ vl_api_unbind_sock_reply_t_handler (vl_api_unbind_sock_reply_t * mp)
clib_spinlock_lock (&vcm->sessions_lockp);
rv = vppcom_session_at_index (vcm->bind_session_index, &session);
- if (PREDICT_FALSE (rv))
+ if (rv == VPPCOM_OK)
{
- if (VPPCOM_DEBUG > 1)
- clib_warning ("[%d] invalid session, sid (%d) has been closed!",
- vcm->my_pid, vcm->bind_session_index);
- }
+ if ((VPPCOM_DEBUG > 1) && (mp->retval))
+ clib_warning ("[%d] unbind failed: %U", vcm->my_pid, format_api_error,
+ ntohl (mp->retval));
- if (mp->retval)
- clib_warning ("[%d] unbind failed: %U", vcm->my_pid, format_api_error,
- ntohl (mp->retval));
-
- vcm->bind_session_index = ~0;
- session->state = STATE_START;
+ vcm->bind_session_index = ~0;
+ session->state = STATE_START;
+ }
clib_spinlock_unlock (&vcm->sessions_lockp);
}
@@ -993,6 +989,7 @@ vl_api_accept_session_t_handler (vl_api_accept_session_t * mp)
unix_shared_memory_queue_t *);
session->state = STATE_ACCEPT;
session->is_cut_thru = 0;
+ session->is_server = 1;
session->port = ntohs (mp->port);
session->is_ip4 = mp->is_ip4;
clib_memcpy (session->ip, mp->ip, sizeof (session->ip));
@@ -1277,10 +1274,6 @@ vppcom_session_disconnect (u32 session_index)
vcm->my_pid, vppcom_retval_str (rv), rv);
return rv;
}
-
- clib_spinlock_lock (&vcm->sessions_lockp);
- pool_put_index (vcm->sessions, session_index);
- clib_spinlock_unlock (&vcm->sessions_lockp);
return VPPCOM_OK;
}
@@ -1853,14 +1846,31 @@ vppcom_session_close (uint32_t session_index)
if (session->is_cut_thru)
{
if (session->is_server)
- rv = vppcom_session_unbind_cut_thru (session);
+ {
+ rv = vppcom_session_unbind_cut_thru (session);
+ if ((VPPCOM_DEBUG > 0) && (rv < 0))
+ clib_warning ("[%d] unbind cut-thru (session %d) failed, "
+ "rv = %s (%d)",
+ vcm->my_pid, session_index,
+ vppcom_retval_str (rv), rv);
+ }
+ }
+ else if (session->is_server)
+ {
+ rv = vppcom_session_unbind (session_index);
+ if ((VPPCOM_DEBUG > 0) && (rv < 0))
+ clib_warning ("[%d] unbind (session %d) failed, rv = %s (%d)",
+ vcm->my_pid, session_index, vppcom_retval_str (rv), rv);
}
else
{
- rv = (session->is_server) ?
- vppcom_session_unbind (session_index) :
- vppcom_session_disconnect (session_index);
+ rv = vppcom_session_disconnect (session_index);
+ if ((VPPCOM_DEBUG > 0) && (rv < 0))
+ clib_warning ("[%d] disconnect (session %d) failed, rv = %s (%d)",
+ vcm->my_pid, session_index, vppcom_retval_str (rv), rv);
}
+ if (rv < 0)
+ return rv;
clib_spinlock_lock (&vcm->sessions_lockp);
pool_put_index (vcm->sessions, session_index);