warmcat / libwebsockets

canonical libwebsockets.org networking library

Home Page:https://libwebsockets.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

__wsContext = lws_create_context(&creationInfo); Thread 58: EXC_BREAKPOINT (code=1, subcode=0x18a0d620c)

toxmc opened this issue · comments

commented

code

void WsThreadHelper::onSubThreadStarted()
{
    int log_level = LLL_ERR | LLL_WARN | LLL_NOTICE | LLL_INFO/* | LLL_DEBUG | LLL_PARSER | LLL_HEADER*/ | LLL_EXT | LLL_CLIENT | LLL_LATENCY;
    lws_set_log_level(log_level, printWebSocketLog);

    memset(__defaultProtocols, 0, sizeof(2 * sizeof(struct lws_protocols)));

    __defaultProtocols[0].name = "";
    __defaultProtocols[0].callback = WebSocketCallbackWrapper::onSocketCallback;
    __defaultProtocols[0].rx_buffer_size = WS_RX_BUFFER_SIZE;
    __defaultProtocols[0].id = std::numeric_limits<uint32_t>::max();

    lws_context_creation_info creationInfo = convertToContextCreationInfo(__defaultProtocols, true);
    __wsContext = lws_create_context(&creationInfo);
}
* thread #58, stop reason = EXC_BREAKPOINT (code=1, subcode=0x18a0d620c)
    frame #0: 0x000000018a0d620c libsystem_platform.dylib`_os_once_gate_recursive_abort + 36
    frame #1: 0x000000018a0d29d8 libsystem_platform.dylib`_os_once_gate_wait + 348
    frame #2: 0x000000010606b234 libsystem_pthread.dylib`pthread_once + 100
    frame #3: 0x0000000101c749d8 testapp`CRYPTO_THREAD_run_once + 12
    frame #4: 0x0000000101c6d270 testapp`OPENSSL_init_crypto + 124
    frame #5: 0x0000000101c655c8 testapp`ERR_get_state + 168
    frame #6: 0x0000000101c6544c testapp`ERR_put_error + 44
    frame #7: 0x0000000101c5f474 testapp`DSO_dsobyaddr + 104
    frame #8: 0x0000000101c6d588 testapp`ossl_init_base_ossl_ + 84
    frame #9: 0x000000010606b29c libsystem_pthread.dylib`__pthread_once_handler + 76
    frame #10: 0x000000018a0d09e0 libsystem_platform.dylib`_os_once_callout + 32
    frame #11: 0x000000010606b234 libsystem_pthread.dylib`pthread_once + 100
    frame #12: 0x0000000101c749d8 testapp`CRYPTO_THREAD_run_once + 12
    frame #13: 0x0000000101c6d270 testapp`OPENSSL_init_crypto + 124
    frame #14: 0x0000000101c8b0b0 testapp`OPENSSL_init_ssl + 96
    frame #15: 0x0000000101cab3b4 testapp`lws_context_init_ssl_library + 72
    frame #16: 0x0000000101ca7e14 testapp`lws_create_context + 988
  * frame #17: 0x0000000101beba44 testapp`cocos2d::network::WsThreadHelper::onSubThreadStarted(this=0x00006000066ac000) at WebSocket.cpp:402:19

whether or not OPENSSL_init_crypto Called multiple times cause error !

Yeah that's an openssl thing.

You can control it by a context creation flag, LWS_SERVER_OPTION_DO_SSL_GLOBAL_INIT. But the real problem is you should only have one lws context and everything use that from the one thread.