summaryrefslogtreecommitdiffstats
path: root/src/vcl
diff options
context:
space:
mode:
authorFlorin Coras <fcoras@cisco.com>2024-12-07 16:20:46 -0500
committerFlorin Coras <fcoras@cisco.com>2024-12-07 16:27:22 -0500
commit4e271dda7b7177e73199b0ccdbf047c0bb55714d (patch)
tree65e802d312d00c540adb6e4f76c1ec16bdb625de /src/vcl
parentb8af24b26d3e1cd2240a9c2ee11340ba9b696f6c (diff)
vcl: improve handling of thread cancelation in vls
Meant for multi-threaded applications that share a vls and vcl worker. Disable thread cancelation on thread new thread detection and add a new pthread cancelation point in vls_mt_mq_lock Type: improvement Change-Id: I21b16ee7c6a5ec31b8f6363325cc7ffa463c7b5c Signed-off-by: Florin Coras <fcoras@cisco.com>
Diffstat (limited to 'src/vcl')
-rw-r--r--src/vcl/vcl_locked.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/vcl/vcl_locked.c b/src/vcl/vcl_locked.c
index bae1c0d86b3..f8a306c1ba1 100644
--- a/src/vcl/vcl_locked.c
+++ b/src/vcl/vcl_locked.c
@@ -301,11 +301,18 @@ vls_mt_add (void)
}
else
vcl_set_worker_index (vlsl->vls_wrk_index);
+
+ /* Only allow new pthread to be cancled in vls_mt_mq_lock */
+ int old_state;
+ if (vlsl->vls_mt_n_threads >= 2)
+ pthread_setcancelstate (PTHREAD_CANCEL_DISABLE, &old_state);
}
static inline void
vls_mt_mq_lock (void)
{
+ /* Allow controlled cancelation of thread before grabbing mutex */
+ pthread_testcancel ();
pthread_mutex_lock (&vlsl->vls_mt_mq_mlock);
}