session: fix vpp exit abnormal due to application as a proxy server with ldp 05/28905/6
authorfanyf <fanyufei521@outlook.com>
Thu, 17 Sep 2020 14:10:41 +0000 (22:10 +0800)
committerFlorin Coras <florin.coras@gmail.com>
Fri, 18 Sep 2020 14:49:11 +0000 (14:49 +0000)
Type: fix

The function of application_setup_proxy() be called when application run as a
proxy server, "app_wrk->first_segment_manager" be realloced in this function,
but variable of "sm" point original memory location.

Signed-off-by: fanyf <fanyufei521@outlook.com>
Change-Id: I753c9fb60d1c0794d5eede9f3fab48381a802e3c

src/vnet/session/application.c

index 65d2f08..a0ddaed 100644 (file)
@@ -874,7 +874,15 @@ vnet_application_attach (vnet_app_attach_args_t * a)
   fs = segment_manager_get_segment_w_lock (sm, 0);
 
   if (application_is_proxy (app))
-    application_setup_proxy (app);
+    {
+      application_setup_proxy (app);
+      /*
+       * I suspect the segment manager pool gets reallocated (because a new listener
+       * is added, and each listener has a segment manager) so sm becomes a dangling
+       * reference. That's why we need to re-grab sm.
+       */
+      sm = segment_manager_get (app_wrk->first_segment_manager);
+    }
 
   ASSERT (vec_len (fs->ssvm.name) <= 128);
   a->segment = &fs->ssvm;