Bug fix for the free server framework code

| 1 Comment

A user of my free server framework code has reported an error and supplied a fix.

The problem is that he's been having connections closing and returning ERROR_CONNECTION_ABORTED and the free code doesn't handle this situation very well and this was causing his I/O threads to terminate and leaving him with an unresponsive server. Interestingly I've never had this problem reported before and haven't been able to duplicate the issue but I thought it would be useful to publish the fix in case anyone else comes across the problem.

His suggested fix is to change the code in CSocketServer::WorkerThread::Run() from

   else if (e.GetError() != WSA_OPERATION_ABORTED)
   {
      throw;
   }

to

   else if (e.GetError() != WSA_OPERATION_ABORTED &&
            e.GetError() != ERROR_CONNECTION_ABORTED)
   {
      throw;
   }

Which should do the job.

Note that the licensed code does not have this problem as it deals with connection errors in a much more robust and inclusive manner.

Thanks to Matthias Baur for sharing the solution with us.

1 Comment

Matthias Baur was right. Besides, ERROR_SEM_TIMEOUT returned sometimes.

Leave a comment