Fixes for error handling in NetChannel
- return the correct errno value instead of using -1
This commit is contained in:
parent
43dacf5951
commit
b8d07cc460
@ -684,6 +684,15 @@ bool Socket::isNonBlockingError ()
|
||||
#endif
|
||||
}
|
||||
|
||||
int Socket::errorNumber()
|
||||
{
|
||||
#if defined(WINSOCK)
|
||||
return WSAGetLastError();
|
||||
#else
|
||||
return errno;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
|
@ -101,7 +101,8 @@ public:
|
||||
void setBroadcast ( bool broadcast ) ;
|
||||
|
||||
static bool isNonBlockingError () ;
|
||||
|
||||
static int errorNumber();
|
||||
|
||||
static int select ( Socket** reads, Socket** writes, int timeout ) ;
|
||||
} ;
|
||||
|
||||
|
@ -114,7 +114,7 @@ NetChannel::send (const void * buffer, int size, int flags)
|
||||
write_blocked = true ;
|
||||
return 0;
|
||||
} else {
|
||||
this->handleError (result);
|
||||
this->handleError (errorNumber());
|
||||
close();
|
||||
return -1;
|
||||
}
|
||||
@ -134,7 +134,7 @@ NetChannel::recv (void * buffer, int size, int flags)
|
||||
} else if (isNonBlockingError ()) {
|
||||
return 0;
|
||||
} else {
|
||||
this->handleError (result);
|
||||
this->handleError (errorNumber());
|
||||
close();
|
||||
return -1;
|
||||
}
|
||||
@ -207,7 +207,7 @@ NetChannel::handleResolve()
|
||||
return 0;
|
||||
} else {
|
||||
// some other error condition
|
||||
handleError (result);
|
||||
handleError (errorNumber());
|
||||
close();
|
||||
return -1;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user