+static void
+vcl_cleanup_bapi (void)
+{
+ api_main_t *am = &api_main;
+
+ am->my_client_index = ~0;
+ am->my_registration = 0;
+ am->vl_input_queue = 0;
+ am->msg_index_by_name_and_crc = 0;
+
+ vl_client_api_unmap ();
+}
+
+void
+vcl_app_fork_child_handler (void)
+{
+ u8 *child_name;
+ int rv;
+
+ vcm->current_pid = getpid ();
+ vcl_set_worker_index (0);
+
+ VDBG (0, "initializing forked child");
+ child_name = format (0, "%v-child-%u%c", vcm->app_name, getpid (), 0);
+
+ vcl_cleanup_bapi ();
+ vppcom_api_hookup ();
+ vcm->app_state = STATE_APP_START;
+ rv = vppcom_connect_to_vpp ((char *) child_name);
+ vec_free (child_name);
+ if (rv)
+ {
+ VERR ("couldn't connect to VPP!");
+ return;
+ }
+
+ vcm->app_state = STATE_APP_ADDING_WORKER;
+ vcl_send_app_worker_add_del (1 /* is_add */ );
+ if (vcl_wait_for_app_state_change (STATE_APP_READY))
+ {
+ VERR ("failed to add worker to vpp");
+ return;
+ }
+ VDBG (0, "forked child main worker initialized");
+}
+