fix crash on close
This commit is contained in:
		@@ -144,18 +144,16 @@ namespace ix
 | 
				
			|||||||
        // This value needs to be forced when shutting down, it is restored later
 | 
					        // This value needs to be forced when shutting down, it is restored later
 | 
				
			||||||
        _automaticReconnection = false;
 | 
					        _automaticReconnection = false;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        // sync close
 | 
				
			||||||
        close();
 | 
					        close();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (!_thread.joinable())
 | 
					        if (_thread.joinable())
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            _automaticReconnection = automaticReconnection;
 | 
					            _stop = true;
 | 
				
			||||||
            return;
 | 
					            _thread.join();
 | 
				
			||||||
 | 
					            _stop = false;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        _stop = true;
 | 
					 | 
				
			||||||
        _thread.join();
 | 
					 | 
				
			||||||
        _stop = false;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        _automaticReconnection = automaticReconnection;
 | 
					        _automaticReconnection = automaticReconnection;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -289,10 +287,8 @@ namespace ix
 | 
				
			|||||||
    {
 | 
					    {
 | 
				
			||||||
        setThreadName(getUrl());
 | 
					        setThreadName(getUrl());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        while (true)
 | 
					        while (getReadyState() != WebSocket_ReadyState_Closed)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            if (_stop && !isClosing()) return;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            // 1. Make sure we are always connected
 | 
					            // 1. Make sure we are always connected
 | 
				
			||||||
            reconnectPerpetuallyIfDisconnected();
 | 
					            reconnectPerpetuallyIfDisconnected();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -91,7 +91,6 @@ namespace ix
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        void setUrl(const std::string& url);
 | 
					        void setUrl(const std::string& url);
 | 
				
			||||||
        void setPerMessageDeflateOptions(const WebSocketPerMessageDeflateOptions& perMessageDeflateOptions);
 | 
					        void setPerMessageDeflateOptions(const WebSocketPerMessageDeflateOptions& perMessageDeflateOptions);
 | 
				
			||||||
        void setHandshakeTimeout(int handshakeTimeoutSecs);
 | 
					 | 
				
			||||||
        void setHeartBeatPeriod(int heartBeatPeriodSecs);
 | 
					        void setHeartBeatPeriod(int heartBeatPeriodSecs);
 | 
				
			||||||
        void setPingInterval(int pingIntervalSecs); // alias of setHeartBeatPeriod
 | 
					        void setPingInterval(int pingIntervalSecs); // alias of setHeartBeatPeriod
 | 
				
			||||||
        void setPingTimeout(int pingTimeoutSecs);
 | 
					        void setPingTimeout(int pingTimeoutSecs);
 | 
				
			||||||
@@ -142,7 +141,6 @@ namespace ix
 | 
				
			|||||||
        static void invokeTrafficTrackerCallback(size_t size, bool incoming);
 | 
					        static void invokeTrafficTrackerCallback(size_t size, bool incoming);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        // Server
 | 
					        // Server
 | 
				
			||||||
        void setSocketFileDescriptor(int fd);
 | 
					 | 
				
			||||||
        WebSocketInitResult connectToSocket(int fd, int timeoutSecs);
 | 
					        WebSocketInitResult connectToSocket(int fd, int timeoutSecs);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        WebSocketTransport _ws;
 | 
					        WebSocketTransport _ws;
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user