lws_libev_run(context);
- context->service_tid = context->protocols[0].callback(NULL,
- LWS_CALLBACK_GET_THREAD_ID, NULL, NULL, 0);
+ if (!context->service_tid_detected) {
+ struct lws _lws;
+
+ memset(&_lws, 0, sizeof(_lws));
+ _lws.context = context;
+
+ context->service_tid_detected = context->protocols[0].callback(
+ &_lws, LWS_CALLBACK_GET_THREAD_ID, NULL, NULL, 0);
+ }
+ context->service_tid = context->service_tid_detected;
#ifdef LWS_OPENSSL_SUPPORT
/* if we know we have non-network pending data, do not wait in poll */
if (context == NULL)
return 1;
- context->service_tid = context->protocols[0].callback(NULL,
- LWS_CALLBACK_GET_THREAD_ID, NULL, NULL, 0);
+ if (!context->service_tid_detected) {
+ struct lws _lws;
+
+ memset(&_lws, 0, sizeof(_lws));
+ _lws.context = context;
+
+ context->service_tid_detected = context->protocols[0].callback(
+ &_lws, LWS_CALLBACK_GET_THREAD_ID, NULL, NULL, 0);
+ }
+ context->service_tid = context->service_tid_detected;
for (i = 0; i < context->fds_count; ++i) {
pfd = &context->fds[i];
sampled_tid = context->service_tid;
if (sampled_tid) {
- tid = context->protocols[0].callback(NULL,
+ tid = context->protocols[0].callback(wsi,
LWS_CALLBACK_GET_THREAD_ID, NULL, NULL, 0);
if (tid == -1)
return -1;
* for pollfd event change.
*/
volatile int service_tid;
+ int service_tid_detected;
#ifndef _WIN32
int dummy_pipe_fds[2];
#endif