1
0
Fork 0
mirror of https://github.com/warmcat/libwebsockets.git synced 2025-03-09 00:00:04 +01:00

smp: fix client tsi detection

This commit is contained in:
Andy Green 2021-05-11 14:34:30 +01:00
parent fda7294bd0
commit 531f998cf8
3 changed files with 8 additions and 28 deletions

View file

@ -87,12 +87,8 @@ lws_client_connect_via_info(const struct lws_client_connect_info *i)
const struct lws_protocols *p;
const char *cisin[CIS_COUNT];
struct lws_vhost *vh, *v;
int
#if LWS_MAX_SMP > 1
tid = 0,
#endif
n, tsi = 0;
size_t size;
int n, tsi;
char *pc;
if (i->context->requested_stop_internal_loops)
@ -114,23 +110,8 @@ lws_client_connect_via_info(const struct lws_client_connect_info *i)
* PHASE 1: if SMP, find out the tsi related to current service thread
*/
#if LWS_MAX_SMP > 1
for (n = 0; n < i->context->count_threads; n++)
if (i->context->pt[n].service_tid == tid) {
lwsl_info("%s: client binds to caller tsi %d\n",
__func__, n);
tsi = n;
break;
}
/*
* this binding is sort of provisional, since when we try to insert
* into the pt fds, there may be no space and it will fail
*/
#endif
tsi = lws_pthread_self_to_tsi(i->context);
assert(tsi >= 0);
/* PHASE 2: create a bare wsi */
@ -237,11 +218,6 @@ lws_client_connect_via_info(const struct lws_client_connect_info *i)
goto bail;
}
#if LWS_MAX_SMP > 1
tid = wsi->a.vhost->protocols[0].callback(wsi,
LWS_CALLBACK_GET_THREAD_ID, NULL, NULL, 0);
#endif
/*
* PHASE 3: Choose an initial role for the wsi and do role-specific init
*

View file

@ -234,6 +234,10 @@ lws_pthread_self_to_tsi(struct lws_context *context)
struct lws_context_per_thread *pt = &context->pt[0];
int n;
/* case that we have SMP build, but don't use it */
if (context->count_threads == 1)
return 0;
for (n = 0; n < context->count_threads; n++) {
if (pthread_equal(ps, pt->self))
return n;

View file

@ -117,7 +117,7 @@ lws_plat_context_late_destroy(struct lws_context *context)
#ifdef LWS_WITH_PLUGINS
if (context->plugin_list)
lws_plugins_destroy(&context->plugin_list);
lws_plugins_destroy(&context->plugin_list, NULL, NULL);
#endif
for (n = 0; n < FD_HASHTABLE_MODULUS; n++) {