VCL: improve debug output

- Refactor debug output to include vpp handle associated
  with session id where appropriate.
- Fix vcom_connect return value on error.
- Refactor vcom_socket_epoll_pwait().
- Fix sock_test_server/client connect failure handling.

Change-Id: I2649596aa4b8a77d9bd876409a76810cb2785797
Signed-off-by: Dave Wallace <dwallacelf@gmail.com>
This commit is contained in:
Dave Wallace
2017-11-24 21:44:06 -05:00
parent 60d48bbd13
commit ee45d41a10
7 changed files with 355 additions and 231 deletions

View File

@ -525,6 +525,11 @@ sock_test_connect_test_sockets (uint32_t num_test_sockets)
#ifdef VCL_TEST
rv = vppcom_session_connect (tsock->fd, &scm->server_endpt);
if (rv)
{
errno = -rv;
rv = -1;
}
#else
rv =
connect (tsock->fd, (struct sockaddr *) &scm->server_addr,
@ -533,9 +538,10 @@ sock_test_connect_test_sockets (uint32_t num_test_sockets)
if (rv < 0)
{
errno_val = errno;
perror ("ERROR in main()");
perror ("ERROR in sock_test_connect_test_sockets()");
fprintf (stderr, "ERROR: connect failed (errno = %d)!\n",
errno_val);
return -1;
}
tsock->cfg = ctrl->cfg;
sock_test_socket_buf_alloc (tsock);
@ -632,6 +638,7 @@ cfg_num_test_sockets_set (void)
{
ctrl->cfg.num_test_sockets = num_test_sockets;
sock_test_connect_test_sockets (num_test_sockets);
sock_test_cfg_dump (&ctrl->cfg, 1 /* is_client */ );
}
else
@ -965,6 +972,11 @@ main (int argc, char **argv)
#ifdef VCL_TEST
rv = vppcom_session_connect (ctrl->fd, &scm->server_endpt);
if (rv)
{
errno = -rv;
rv = -1;
}
#else
rv =
connect (ctrl->fd, (struct sockaddr *) &scm->server_addr,
@ -976,6 +988,7 @@ main (int argc, char **argv)
perror ("ERROR in main()");
fprintf (stderr, "ERROR: connect failed (errno = %d)!\n",
errno_val);
return -1;
}
sock_test_cfg_sync (ctrl);

View File

@ -315,6 +315,7 @@ new_client (void)
errno_val = errno;
perror ("ERROR in new_client()");
fprintf (stderr, "ERROR: accept failed (errno = %d)!\n", errno_val);
return;
}
printf ("SERVER: Got a connection -- fd = %d (0x%08x)!\n",
@ -681,6 +682,7 @@ main (int argc, char **argv)
close (client_fd);
#endif
conn_pool_free (conn);
printf ("SERVER: Closed client fd %d\n", client_fd);
#if ! SOCK_SERVER_USE_EPOLL
if (ssm->nfds == (ssm->listen_fd + 1))
#else

View File

@ -1951,6 +1951,12 @@ vcom_connect (int __fd, __CONST_SOCKADDR_ARG __addr, socklen_t __len)
case AF_INET:
case AF_INET6:
rv = vcom_socket_connect (__fd, __addr, __len);
if (!rv)
{
errno = -rv;
return -1;
}
break;
default:
@ -1977,7 +1983,7 @@ connect (int __fd, __CONST_SOCKADDR_ARG __addr, socklen_t __len)
"'%04d'='%04d', '%p', '%04d'\n",
pid, (unsigned long) tid, (unsigned long) tid,
rv, __fd, __addr, __len);
if (rv != 0)
if (!rv)
{
errno = -rv;
return -1;

View File

@ -3011,12 +3011,10 @@ vcom_socket_epoll_pwait (int __epfd, struct epoll_event *__events,
{
vcom_socket_main_t *vsm = &vcom_socket_main;
int rv = -EBADF;
int rv2;
double time_to_wait = (double) 0;
double timeout, now = 0;
vcom_epoll_t *vepoll;
i32 vep_idx;
static struct epoll_event *libc_ev = 0;
/* validate __event */
if (!__events || (__timeout < -1))
@ -3070,42 +3068,40 @@ vcom_socket_epoll_pwait (int __epfd, struct epoll_event *__events,
"__timeout = %d)\n",
getpid (), vepoll->vcl_cnt, vepoll->libc_cnt,
time_to_wait, __timeout);
vec_validate (libc_ev, __maxevents);
timeout = clib_time_now (&vsm->clib_time) + time_to_wait;
do
{
rv = vppcom_epoll_wait (vep_idx, __events, __maxevents, 0);
rv2 = libc_epoll_pwait (__epfd, libc_ev, __maxevents, 1, __ss);
if (VCOM_DEBUG == 666)
fprintf (stderr, "[%d] vcom_socket_epoll_pwait: "
"rv = %d, rv2 = %d, timeout = %f, now = %f\n",
getpid (), rv, rv2, timeout, now);
if ((rv > 0) || (rv2 > 0))
if (rv > 0)
{
if (VCOM_DEBUG > 2)
fprintf (stderr, "[%d] vcom_socket_epoll_pwait: "
"rv = %d, rv2 = %d\n", getpid (), rv, rv2);
int n = __maxevents - rv;
n = rv2 <= n ? rv2 : n;
rv = (rv > 0) ? rv : 0;
clib_memcpy (&__events[rv], libc_ev, n * sizeof (*libc_ev));
rv += rv2;
"vppcom_epoll_wait() returned %d\n", getpid (), rv);
goto out;
}
else if ((rv < 0) || (rv2 < 0))
else if (rv < 0)
{
if (rv < 0)
fprintf (stderr,
"[%d] ERROR: vppcom_epoll_wait() returned %d\n",
getpid (), rv);
if (rv2 < 0)
{
fprintf (stderr,
"[%d] ERROR: libc_epoll_wait() failed, errno %d\n",
getpid (), errno);
rv = (rv < 0) ? rv : -errno;
}
if (VCOM_DEBUG > 2)
fprintf (stderr, "[%d] ERROR: vcom_socket_epoll_pwait: "
"vppcom_epoll_wait() returned %d\n", getpid (), rv);
goto out;
}
rv = libc_epoll_pwait (__epfd, __events, __maxevents, 1, __ss);
if (rv > 0)
{
if (VCOM_DEBUG > 2)
fprintf (stderr, "[%d] vcom_socket_epoll_pwait: "
"libc_epoll_pwait() returned %d\n", getpid (), rv);
goto out;
}
else if (rv < 0)
{
int errno_val = errno;
perror ("libc_epoll_wait");
fprintf (stderr, "[%d] vcom_socket_epoll_pwait: "
"libc_epoll_wait() failed, errno %d\n",
getpid (), errno_val);
goto out;
}
if (__timeout != -1)
@ -3113,9 +3109,7 @@ vcom_socket_epoll_pwait (int __epfd, struct epoll_event *__events,
}
while (now < timeout);
}
out:
vec_reset_length (libc_ev);
return rv;
}

File diff suppressed because it is too large Load Diff

View File

@ -64,6 +64,7 @@ typedef enum
VPPCOM_EINVAL = -EINVAL,
VPPCOM_EBADFD = -EBADFD,
VPPCOM_EAFNOSUPPORT = -EAFNOSUPPORT,
VPPCOM_ECONNABORTED = -ECONNABORTED,
VPPCOM_ECONNRESET = -ECONNRESET,
VPPCOM_ENOTCONN = -ENOTCONN,
VPPCOM_ECONNREFUSED = -ECONNREFUSED,
@ -120,6 +121,10 @@ vppcom_retval_str (int retval)
st = "VPPCOM_EAFNOSUPPORT";
break;
case VPPCOM_ECONNABORTED:
st = "VPPCOM_ECONNABORTED";
break;
case VPPCOM_ECONNRESET:
st = "VPPCOM_ECONNRESET";
break;

View File

@ -246,6 +246,14 @@ while ! [[ $run_test ]] && (( $# > 0 )) ; do
shift
done
if [ -z "$VCL_DEBUG" ] ; then
if [ "$title_dbg" = "-DEBUG" ] ; then
VCL_DEBUG=1
else
VCL_DEBUG=0
fi
fi
VCL_LDPRELOAD_LIB_DIR="${VCL_LDPRELOAD_LIB_DIR:-$lib64_dir}"
if [ -z "$WS_ROOT" ] ; then
@ -763,7 +771,7 @@ docker_preload() {
gdb_cmdfile=$VPPCOM_SERVER_GDB_CMDFILE
set_pre_cmd $emacs_server $gdb_server $docker_ld_preload_lib
write_script_header $cmd2_file $tmp_gdb_cmdfile "$title2" "sleep 2"
echo "docker run -it -v $vpp_shm_dir:$vpp_shm_dir -v $vpp_dir:$docker_vpp_dir -v $lib64_dir:$docker_lib64_dir -v $ld_preload_dir:$docker_ld_preload_dir -v $vcl_config_dir:$docker_vcl_config_dir -p $sock_srvr_port:$sock_srvr_port -e VCL_CONFIG=${docker_vcl_config_dir}$vcl_config -e LD_LIBRARY_PATH=$docker_lib64_dir:$docker_ld_preload_dir ${docker_ld_preload}$docker_os ${docker_app_dir}${srvr_app}" >> $cmd2_file
echo "docker run -it -v $vpp_shm_dir:$vpp_shm_dir -v $vpp_dir:$docker_vpp_dir -v $lib64_dir:$docker_lib64_dir -v $ld_preload_dir:$docker_ld_preload_dir -v $vcl_config_dir:$docker_vcl_config_dir -p $sock_srvr_port:$sock_srvr_port -e VCL_DEBUG=$VCL_DEBUG -e VCL_CONFIG=${docker_vcl_config_dir}$vcl_config -e LD_LIBRARY_PATH=$docker_lib64_dir:$docker_ld_preload_dir ${docker_ld_preload}$docker_os ${docker_app_dir}${srvr_app}" >> $cmd2_file
write_script_footer $cmd2_file $perf_server
chmod +x $cmd2_file
fi
@ -775,7 +783,7 @@ docker_preload() {
set_pre_cmd $emacs_client $gdb_client $docker_ld_preload_lib
write_script_header $cmd3_file $tmp_gdb_cmdfile "$title3" "sleep 4"
echo "$get_docker_server_ip4addr" >> $cmd3_file
echo "docker run -it --cpuset-cpus='4-7' -v $vpp_shm_dir:$vpp_shm_dir -v $vpp_dir:$docker_vpp_dir -v $lib64_dir:$docker_lib64_dir -v $ld_preload_dir:$docker_ld_preload_dir -v $vcl_config_dir:$docker_vcl_config_dir -e VCL_CONFIG=${docker_vcl_config_dir}$vcl_config -e LD_LIBRARY_PATH=$docker_lib64_dir ${docker_ld_preload}$docker_os ${docker_app_dir}${clnt_app}" >> $cmd3_file
echo "docker run -it --cpuset-cpus='4-7' -v $vpp_shm_dir:$vpp_shm_dir -v $vpp_dir:$docker_vpp_dir -v $lib64_dir:$docker_lib64_dir -v $ld_preload_dir:$docker_ld_preload_dir -v $vcl_config_dir:$docker_vcl_config_dir -e VCL_DEBUG=$VCL_DEBUG -e VCL_CONFIG=${docker_vcl_config_dir}$vcl_config -e LD_LIBRARY_PATH=$docker_lib64_dir ${docker_ld_preload}$docker_os ${docker_app_dir}${clnt_app}" >> $cmd3_file
write_script_footer $cmd3_file $perf_client
chmod +x $cmd3_file
fi