Websocket crash on server close

I have a turn based multiplayer game. So when i see an inactive user i kick him of the server (close the websocket connection from the server). For some reason this causes a crash on ios (i have NOT tested other devices) about 80-90% of the time.

I am sorry if the issue has been reported allredy.

BTW i am useing tomcats websocket server

Screenshot attached (file Websocket.cpp) :slight_smile:


Screen Shot 2013-09-10 at 7.37.11 PM.png (31.7 KB)

So the way i do this i have a ccbi scene that opens a WS connection to the server /login and after they login and start the game i close that WS connection on client and start a new scene that opens a connection to /game. THEN when i close my websocket connection on the server i get that crash.

So i saw that void WebSocket::onSubThreadEnded() is empty anyway so just comment the crashing line out. Seems to fix it :slight_smile:

Iā€™m so sorry to see thatā€¦

void WsThreadHelper::quitSubThread()
{
    _needQuit = true;  // this may be called when connection is close, and then _ws must be deleted.
    // set _needQuit true is not safe enough to ensure _ws lives after wsThreadEntryFunc exiting...
    // may be we should block here until wsThreadEntryFunc thread end
}

void* WsThreadHelper::wsThreadEntryFunc(void* arg)
{
    _ws->onSubThreadStarted();

    while (!_needQuit)
    {
        if (_ws->onSubThreadLoop())
        {
            break;
        }
    }

    _ws->onSubThreadEnded();  // this code run after quitSubThread(), and most of the time _ws is deleted

    return (void*)0;
}

By the way,onSubThreadEnded is a virtual function, commenting the line is a bad solutionā€¦
Will this issue be fixed in next release?

Thereā€™s pending PR related to this issue.