X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=src%2Fvat%2Fmain.c;h=723c5e8cc3ad6226d2eac076277970ea4c295ae7;hb=90a63988fa01685626b6d6a01b79ea5370f7fbac;hp=e2c9b70889a0fecef81105045862172bfbaf0abb;hpb=59b2565cd91a67ced650739f36129650830211ac;p=vpp.git diff --git a/src/vat/main.c b/src/vat/main.c index e2c9b70889a..723c5e8cc3a 100644 --- a/src/vat/main.c +++ b/src/vat/main.c @@ -308,6 +308,7 @@ main (int argc, char **argv) u8 *heap; mheap_t *h; int i; + f64 timeout; clib_mem_init (0, 128 << 20); @@ -388,7 +389,7 @@ main (int argc, char **argv) if (vam->socket_name && vat_socket_connect (vam)) fformat (stderr, "WARNING: socket connection failed"); - if (vam->socket_client_main.socket_fd == 0 + if ((!vam->socket_client_main || vam->socket_client_main->socket_fd == 0) && connect_to_vpe ("vpp_api_test") < 0) { svm_region_exit (); @@ -432,6 +433,18 @@ main (int argc, char **argv) fclose (vam->ifp); } + /* + * Particularly when running a script, don't be in a hurry to leave. + * A reply message queued to this process will end up constipating + * the allocation rings. + */ + timeout = vat_time_now (vam) + 2.0; + while (vam->result_ready == 0 && vat_time_now (vam) < timeout) + ; + + if (vat_time_now (vam) > timeout) + clib_warning ("BUG: message reply spin-wait timeout"); + vl_client_disconnect_from_vlib (); exit (0); }