Commit d514bb59 authored by Cziken's avatar Cziken Committed by Luca Boccassi

Fixed handling of WSAEWOULDBLOCK to be generic (#2260)

* Fixed handling of WSAEWOULDBLOCK to be generic

I don't know what was the intention of this early if statement but
now this is properly evaluated in wsa_error_no function if this is
performance issue I suggest moving evaluating this error code to the
beginning of wsa_error_no.

* Fixed handling of WSAEWOULDBLOCK to be generic

Introduced default pointer to const char * and overrides this as NULL
if function is called by zmq::wsa_error()

* Fixed handling of WSAEWOULDBLOCK to be generic

Introduced default pointer to const char * and overrides this as NULL
if function is called by zmq::wsa_error()
parent 2b565088
......@@ -92,15 +92,10 @@ void zmq::zmq_abort(const char *errmsg_)
const char *zmq::wsa_error()
{
const int last_error = WSAGetLastError();
// TODO: This is not a generic way to handle this...
if (last_error == WSAEWOULDBLOCK)
return NULL;
return wsa_error_no (last_error);
return wsa_error_no (WSAGetLastError(), NULL);
}
const char *zmq::wsa_error_no (int no_)
const char *zmq::wsa_error_no (int no_, const char * wsae_wouldblock_string)
{
// TODO: It seems that list of Windows socket errors is longer than this.
// Investigate whether there's a way to convert it into the string
......@@ -121,7 +116,7 @@ const char *zmq::wsa_error_no (int no_)
(no_ == WSAEMFILE) ?
"Too many open files" :
(no_ == WSAEWOULDBLOCK) ?
"Operation would block" :
wsae_wouldblock_string :
(no_ == WSAEINPROGRESS) ?
"Operation now in progress" :
(no_ == WSAEALREADY) ?
......
......@@ -65,7 +65,7 @@ namespace zmq
namespace zmq
{
const char *wsa_error ();
const char *wsa_error_no (int no_);
const char *wsa_error_no (int no_, const char * wsae_wouldblock_string = "Operation would block");
void win_error (char *buffer_, size_t buffer_size_);
int wsa_error_to_errno (int errcode);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment