tcp: improve builtin http server
[vpp.git] / src / vnet / session / application.c
index 8a95371..25a4efa 100644 (file)
@@ -106,7 +106,8 @@ application_del (application_t * app)
   /*
    * Cleanup segment managers
    */
-  if (app->connects_seg_manager != (u32) ~ 0)
+  if ((app->connects_seg_manager != (u32) ~ 0) &&
+      (app->connects_seg_manager != app->first_segment_manager))
     {
       sm = segment_manager_get (app->connects_seg_manager);
       segment_manager_del (sm);
@@ -224,15 +225,17 @@ application_alloc_segment_manager (application_t * app)
 {
   segment_manager_t *sm = 0;
 
-  if (app->first_segment_manager != (u32) ~ 0)
+  if (app->first_segment_manager != (u32) ~ 0
+      && app->first_segment_manager_in_use == 0)
     {
       sm = segment_manager_get (app->first_segment_manager);
+      app->first_segment_manager_in_use = 1;
       return sm;
     }
 
   sm = segment_manager_new ();
-  if (segment_manager_init (sm, &app->sm_properties, 0))
-    return 0;
+  sm->properties = &app->sm_properties;
+
   return sm;
 }
 
@@ -300,7 +303,11 @@ application_stop_listen (application_t * srv, u64 handle)
 
   sm = segment_manager_get (*indexp);
   segment_manager_del (sm);
-  srv->first_segment_manager = ~0;
+  if (srv->first_segment_manager == *indexp)
+    {
+      srv->first_segment_manager_in_use = 0;
+      srv->first_segment_manager = ~0;
+    }
   hash_unset (srv->listeners_table, handle);
   listen_session_del (listener);
 
@@ -328,7 +335,7 @@ application_open_session (application_t * app, session_type_t sst,
     return rv;
 
   /* Store api_context for when the reply comes. Not the nicest thing
-   * but better allocating a separate half-open pool.  */
+   * but better than allocating a separate half-open pool. */
   tc->s_index = api_context;
 
   return 0;
@@ -366,6 +373,12 @@ app_get_name_from_reg_index (application_t * app)
   return app_name;
 }
 
+int
+application_is_proxy (application_t * app)
+{
+  return !(app->flags & APP_OPTIONS_FLAGS_IS_PROXY);
+}
+
 u8 *
 format_application_listener (u8 * s, va_list * args)
 {