GazeApi disconnect sometimes throws

Forum for development in the C++ programming language.

GazeApi disconnect sometimes throws

Postby greg » 28 Jun 2014, 23:57

In my application, I am frequently disconnecting from the server. It mostly works fine, but sometimes in gtl::Socket::disconnect( ), the call to boost::asio::ip::tcp::socket.close( ) throws a boost::system::system_error with code WSAENOTSOCK (10038).

I have tried uncommenting the shutdown( ) call, and then that guy just throws the error.

So I'm assuming there's some race condition where the underlying socket can be deleted or otherwise *poofed* but the
gtl::Socket object gets confused about this state.

I have worked around the issue by putting the boost close( ) inside a try block and catching boost::system::system_error. Because of another issue I have to delete the entire GazeApi every time after I disconnect anyway, so that will mask any issue that might arise from the state of the existing gtl::Socket object becoming confused.

Code: Select all
         try
         {
            //gjb why was this commented out?
            m_socket.shutdown(boost::asio::socket_base::shutdown_type::shutdown_both);
            m_socket.close();
         }
         catch(boost::system::system_error e)
         {
            fprintf(stderr, "socket close caught error %d\n", e.code());
         }
greg
 
Posts: 19
Joined: 19 Mar 2014, 21:05

Re: GazeApi disconnect sometimes throws

Postby Martin » 30 Jun 2014, 01:17

Thanks Greg. Responsible developer notified.
Martin
 
Posts: 567
Joined: 29 Oct 2013, 15:20


Return to C++