From 3fa221f9d6796da9d0fbd46dfcdd66a02344e45c Mon Sep 17 00:00:00 2001 From: Andy Green Date: Thu, 1 Oct 2020 10:30:00 +0100 Subject: [PATCH] smp: lws_wsi_tsi This lets you find out the SMP Thread Service Index (tsi) that a wsi is bound to. This allows you to, eg, filter a global wsi list so you can find the ones that exist in your service thread context. --- include/libwebsockets/lws-misc.h | 9 +++++++++ lib/core-net/wsi.c | 7 +++++++ 2 files changed, 16 insertions(+) diff --git a/include/libwebsockets/lws-misc.h b/include/libwebsockets/lws-misc.h index 2a33eba53..073108ad4 100644 --- a/include/libwebsockets/lws-misc.h +++ b/include/libwebsockets/lws-misc.h @@ -335,6 +335,15 @@ lws_get_library_version(void); LWS_VISIBLE LWS_EXTERN void * lws_wsi_user(struct lws *wsi); +/** + * lws_wsi_tsi() - get the service thread index the wsi is bound to + * \param wsi: lws connection + * + * Only useful is LWS_MAX_SMP > 1 + */ +LWS_VISIBLE LWS_EXTERN int +lws_wsi_tsi(struct lws *wsi); + /** * lws_set_wsi_user() - set the user data associated with the client connection * \param wsi: lws connection diff --git a/lib/core-net/wsi.c b/lib/core-net/wsi.c index 58c8e2bc6..2a8064edf 100644 --- a/lib/core-net/wsi.c +++ b/lib/core-net/wsi.c @@ -640,6 +640,13 @@ lws_wsi_user(struct lws *wsi) return wsi->user_space; } +int +lws_wsi_tsi(struct lws *wsi) +{ + return wsi->tsi; +} + + void lws_set_wsi_user(struct lws *wsi, void *data) {