Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
L
libzmq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
libzmq
Commits
13ef1e4f
Commit
13ef1e4f
authored
May 27, 2012
by
Martin Hurton
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make wsa_error_to_errno pure function
parent
a8f9a0d8
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
26 additions
and
38 deletions
+26
-38
err.cpp
src/err.cpp
+14
-24
err.hpp
src/err.hpp
+1
-1
tcp_connecter.cpp
src/tcp_connecter.cpp
+2
-2
tcp_listener.cpp
src/tcp_listener.cpp
+4
-4
zmq.cpp
src/zmq.cpp
+5
-7
No files found.
src/err.cpp
View file @
13ef1e4f
...
@@ -214,46 +214,36 @@ void zmq::win_error (char *buffer_, size_t buffer_size_)
...
@@ -214,46 +214,36 @@ void zmq::win_error (char *buffer_, size_t buffer_size_)
zmq_assert
(
rc
);
zmq_assert
(
rc
);
}
}
void
zmq
::
wsa_error_to_errno
(
)
int
zmq
::
wsa_error_to_errno
(
int
errcode
)
{
{
int
errcode
=
WSAGetLastError
();
switch
(
errcode
)
{
switch
(
errcode
)
{
case
WSAEINPROGRESS
:
case
WSAEINPROGRESS
:
errno
=
EAGAIN
;
return
EAGAIN
;
return
;
case
WSAEBADF
:
case
WSAEBADF
:
errno
=
EBADF
;
return
EBADF
;
return
;
case
WSAEINVAL
:
case
WSAEINVAL
:
errno
=
EINVAL
;
return
EINVAL
;
return
;
case
WSAEMFILE
:
case
WSAEMFILE
:
errno
=
EMFILE
;
return
EMFILE
;
return
;
case
WSAEFAULT
:
case
WSAEFAULT
:
errno
=
EFAULT
;
return
EFAULT
;
return
;
case
WSAEPROTONOSUPPORT
:
case
WSAEPROTONOSUPPORT
:
errno
=
EPROTONOSUPPORT
;
return
EPROTONOSUPPORT
;
return
;
case
WSAENOBUFS
:
case
WSAENOBUFS
:
errno
=
ENOBUFS
;
return
ENOBUFS
;
return
;
case
WSAENETDOWN
:
case
WSAENETDOWN
:
errno
=
ENETDOWN
;
return
ENETDOWN
;
return
;
case
WSAEADDRINUSE
:
case
WSAEADDRINUSE
:
errno
=
EADDRINUSE
;
return
EADDRINUSE
;
return
;
case
WSAEADDRNOTAVAIL
:
case
WSAEADDRNOTAVAIL
:
errno
=
EADDRNOTAVAIL
;
return
EADDRNOTAVAIL
;
return
;
case
WSAEAFNOSUPPORT
:
case
WSAEAFNOSUPPORT
:
errno
=
EAFNOSUPPORT
;
return
EAFNOSUPPORT
;
return
;
default
:
default
:
wsa_assert
(
false
);
wsa_assert
(
false
);
}
}
// Not reachable
return
0
;
}
}
#endif
#endif
src/err.hpp
View file @
13ef1e4f
...
@@ -57,7 +57,7 @@ namespace zmq
...
@@ -57,7 +57,7 @@ namespace zmq
const
char
*
wsa_error
();
const
char
*
wsa_error
();
const
char
*
wsa_error_no
(
int
no_
);
const
char
*
wsa_error_no
(
int
no_
);
void
win_error
(
char
*
buffer_
,
size_t
buffer_size_
);
void
win_error
(
char
*
buffer_
,
size_t
buffer_size_
);
void
wsa_error_to_errno
(
);
int
wsa_error_to_errno
(
int
errcode
);
}
}
// Provides convenient way to check WSA-style errors on Windows.
// Provides convenient way to check WSA-style errors on Windows.
...
...
src/tcp_connecter.cpp
View file @
13ef1e4f
...
@@ -193,7 +193,7 @@ int zmq::tcp_connecter_t::open ()
...
@@ -193,7 +193,7 @@ int zmq::tcp_connecter_t::open ()
s
=
open_socket
(
addr
->
resolved
.
tcp_addr
->
family
(),
SOCK_STREAM
,
IPPROTO_TCP
);
s
=
open_socket
(
addr
->
resolved
.
tcp_addr
->
family
(),
SOCK_STREAM
,
IPPROTO_TCP
);
#ifdef ZMQ_HAVE_WINDOWS
#ifdef ZMQ_HAVE_WINDOWS
if
(
s
==
INVALID_SOCKET
)
{
if
(
s
==
INVALID_SOCKET
)
{
wsa_error_to_errno
(
);
errno
=
wsa_error_to_errno
(
WSAGetLastError
()
);
return
-
1
;
return
-
1
;
}
}
#else
#else
...
@@ -226,7 +226,7 @@ int zmq::tcp_connecter_t::open ()
...
@@ -226,7 +226,7 @@ int zmq::tcp_connecter_t::open ()
errno
=
EINPROGRESS
;
errno
=
EINPROGRESS
;
return
-
1
;
return
-
1
;
}
}
wsa_error_to_errno
(
);
errno
=
wsa_error_to_errno
(
WSAGetLastError
()
);
#else
#else
if
(
rc
==
-
1
&&
errno
==
EINTR
)
{
if
(
rc
==
-
1
&&
errno
==
EINTR
)
{
errno
=
EINPROGRESS
;
errno
=
EINPROGRESS
;
...
...
src/tcp_listener.cpp
View file @
13ef1e4f
...
@@ -156,7 +156,7 @@ int zmq::tcp_listener_t::set_address (const char *addr_)
...
@@ -156,7 +156,7 @@ int zmq::tcp_listener_t::set_address (const char *addr_)
s
=
open_socket
(
address
.
family
(),
SOCK_STREAM
,
IPPROTO_TCP
);
s
=
open_socket
(
address
.
family
(),
SOCK_STREAM
,
IPPROTO_TCP
);
#ifdef ZMQ_HAVE_WINDOWS
#ifdef ZMQ_HAVE_WINDOWS
if
(
s
==
INVALID_SOCKET
)
if
(
s
==
INVALID_SOCKET
)
wsa_error_to_errno
(
);
errno
=
wsa_error_to_errno
(
WSAGetLastError
()
);
#endif
#endif
// IPv6 address family not supported, try automatic downgrade to IPv4.
// IPv6 address family not supported, try automatic downgrade to IPv4.
...
@@ -170,7 +170,7 @@ int zmq::tcp_listener_t::set_address (const char *addr_)
...
@@ -170,7 +170,7 @@ int zmq::tcp_listener_t::set_address (const char *addr_)
#ifdef ZMQ_HAVE_WINDOWS
#ifdef ZMQ_HAVE_WINDOWS
if
(
s
==
INVALID_SOCKET
)
{
if
(
s
==
INVALID_SOCKET
)
{
wsa_error_to_errno
(
);
errno
=
wsa_error_to_errno
(
WSAGetLastError
()
);
return
-
1
;
return
-
1
;
}
}
// On Windows, preventing sockets to be inherited by child processes.
// On Windows, preventing sockets to be inherited by child processes.
...
@@ -203,7 +203,7 @@ int zmq::tcp_listener_t::set_address (const char *addr_)
...
@@ -203,7 +203,7 @@ int zmq::tcp_listener_t::set_address (const char *addr_)
rc
=
bind
(
s
,
address
.
addr
(),
address
.
addrlen
());
rc
=
bind
(
s
,
address
.
addr
(),
address
.
addrlen
());
#ifdef ZMQ_HAVE_WINDOWS
#ifdef ZMQ_HAVE_WINDOWS
if
(
rc
==
SOCKET_ERROR
)
{
if
(
rc
==
SOCKET_ERROR
)
{
wsa_error_to_errno
(
);
errno
=
wsa_error_to_errno
(
WSAGetLastError
()
);
return
-
1
;
return
-
1
;
}
}
#else
#else
...
@@ -215,7 +215,7 @@ int zmq::tcp_listener_t::set_address (const char *addr_)
...
@@ -215,7 +215,7 @@ int zmq::tcp_listener_t::set_address (const char *addr_)
rc
=
listen
(
s
,
options
.
backlog
);
rc
=
listen
(
s
,
options
.
backlog
);
#ifdef ZMQ_HAVE_WINDOWS
#ifdef ZMQ_HAVE_WINDOWS
if
(
rc
==
SOCKET_ERROR
)
{
if
(
rc
==
SOCKET_ERROR
)
{
wsa_error_to_errno
(
);
errno
=
wsa_error_to_errno
(
WSAGetLastError
()
);
return
-
1
;
return
-
1
;
}
}
#else
#else
...
...
src/zmq.cpp
View file @
13ef1e4f
...
@@ -853,17 +853,15 @@ int zmq_poll (zmq_pollitem_t *items_, int nitems_, long timeout_)
...
@@ -853,17 +853,15 @@ int zmq_poll (zmq_pollitem_t *items_, int nitems_, long timeout_)
#if defined ZMQ_HAVE_WINDOWS
#if defined ZMQ_HAVE_WINDOWS
int
rc
=
select
(
0
,
&
inset
,
&
outset
,
&
errset
,
ptimeout
);
int
rc
=
select
(
0
,
&
inset
,
&
outset
,
&
errset
,
ptimeout
);
if
(
unlikely
(
rc
==
SOCKET_ERROR
))
{
if
(
unlikely
(
rc
==
SOCKET_ERROR
))
{
zmq
::
wsa_error_to_errno
();
errno
=
zmq
::
wsa_error_to_errno
(
WSAGetLastError
());
if
(
errno
==
ENOTSOCK
)
wsa_assert
(
errno
==
ENOTSOCK
);
return
-
1
;
return
-
1
;
wsa_assert
(
false
);
}
}
#else
#else
int
rc
=
select
(
maxfd
+
1
,
&
inset
,
&
outset
,
&
errset
,
ptimeout
);
int
rc
=
select
(
maxfd
+
1
,
&
inset
,
&
outset
,
&
errset
,
ptimeout
);
if
(
unlikely
(
rc
==
-
1
))
{
if
(
unlikely
(
rc
==
-
1
))
{
if
(
errno
==
EINTR
||
errno
==
EBADF
)
errno_assert
(
errno
==
EINTR
||
errno
==
EBADF
);
return
-
1
;
return
-
1
;
errno_assert
(
false
);
}
}
#endif
#endif
break
;
break
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment