Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
A
Actor Framework
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
cpp-libs
Actor Framework
Commits
eed5e9ca
Commit
eed5e9ca
authored
Jun 01, 2019
by
Joseph Noir
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Separate error check from string conversion
parent
c39c2eae
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
22 additions
and
8 deletions
+22
-8
libcaf_io/src/tcp.cpp
libcaf_io/src/tcp.cpp
+11
-4
libcaf_io/src/udp.cpp
libcaf_io/src/udp.cpp
+10
-3
libcaf_openssl/src/middleman_actor.cpp
libcaf_openssl/src/middleman_actor.cpp
+1
-1
No files found.
libcaf_io/src/tcp.cpp
View file @
eed5e9ca
...
...
@@ -34,8 +34,9 @@ using caf::io::network::is_error;
using
caf
::
io
::
network
::
rw_state
;
using
caf
::
io
::
network
::
native_socket
;
using
caf
::
io
::
network
::
socket_size_type
;
using
caf
::
io
::
network
::
last_socket_error
;
using
caf
::
io
::
network
::
no_sigpipe_io_flag
;
using
caf
::
io
::
network
::
last_
socket_error_as_string
;
using
caf
::
io
::
network
::
socket_error_as_string
;
namespace
caf
{
namespace
policy
{
...
...
@@ -46,7 +47,10 @@ rw_state tcp::read_some(size_t& result, native_socket fd, void* buf,
auto
sres
=
::
recv
(
fd
,
reinterpret_cast
<
io
::
network
::
socket_recv_ptr
>
(
buf
),
len
,
no_sigpipe_io_flag
);
if
(
is_error
(
sres
,
true
))
{
CAF_LOG_ERROR
(
"recv failed:"
<<
last_socket_error_as_string
());
// Make sure WSAGetLastError gets called immediately on Windows.
auto
err
=
last_socket_error
();
CAF_IGNORE_UNUSED
(
err
);
CAF_LOG_ERROR
(
"recv failed:"
<<
socket_error_as_string
(
err
));
return
rw_state
::
failure
;
}
else
if
(
sres
==
0
)
{
// recv returns 0 when the peer has performed an orderly shutdown
...
...
@@ -64,7 +68,10 @@ rw_state tcp::write_some(size_t& result, native_socket fd, const void* buf,
auto
sres
=
::
send
(
fd
,
reinterpret_cast
<
io
::
network
::
socket_send_ptr
>
(
buf
),
len
,
no_sigpipe_io_flag
);
if
(
is_error
(
sres
,
true
))
{
CAF_LOG_ERROR
(
"send failed:"
<<
last_socket_error_as_string
());
// Make sure WSAGetLastError gets called immediately on Windows.
auto
err
=
last_socket_error
();
CAF_IGNORE_UNUSED
(
err
);
CAF_LOG_ERROR
(
"send failed:"
<<
socket_error_as_string
(
err
));
return
rw_state
::
failure
;
}
CAF_LOG_DEBUG
(
CAF_ARG
(
len
)
<<
CAF_ARG
(
fd
)
<<
CAF_ARG
(
sres
));
...
...
@@ -83,7 +90,7 @@ bool tcp::try_accept(native_socket& result, native_socket fd) {
if
(
result
==
invalid_native_socket
)
{
auto
err
=
last_socket_error
();
if
(
!
would_block_or_temporarily_unavailable
(
err
))
{
CAF_LOG_ERROR
(
"accept failed:"
<<
last_socket_error_as_string
(
));
CAF_LOG_ERROR
(
"accept failed:"
<<
socket_error_as_string
(
err
));
return
false
;
}
}
...
...
libcaf_io/src/udp.cpp
View file @
eed5e9ca
...
...
@@ -33,7 +33,8 @@ using caf::io::network::ip_endpoint;
using
caf
::
io
::
network
::
native_socket
;
using
caf
::
io
::
network
::
signed_size_type
;
using
caf
::
io
::
network
::
socket_size_type
;
using
caf
::
io
::
network
::
last_socket_error_as_string
;
using
caf
::
io
::
network
::
last_socket_error
;
using
caf
::
io
::
network
::
socket_error_as_string
;
namespace
caf
{
namespace
policy
{
...
...
@@ -46,7 +47,10 @@ bool udp::read_datagram(size_t& result, native_socket fd, void* buf,
auto
sres
=
::
recvfrom
(
fd
,
static_cast
<
io
::
network
::
socket_recv_ptr
>
(
buf
),
buf_len
,
0
,
ep
.
address
(),
&
len
);
if
(
is_error
(
sres
,
true
))
{
CAF_LOG_ERROR
(
"recvfrom failed:"
<<
last_socket_error_as_string
());
// Make sure WSAGetLastError gets called immediately on Windows.
auto
err
=
last_socket_error
();
CAF_IGNORE_UNUSED
(
err
);
CAF_LOG_ERROR
(
"recvfrom failed:"
<<
socket_error_as_string
(
err
));
return
false
;
}
if
(
sres
==
0
)
...
...
@@ -66,7 +70,10 @@ bool udp::write_datagram(size_t& result, native_socket fd, void* buf,
auto
sres
=
::
sendto
(
fd
,
reinterpret_cast
<
io
::
network
::
socket_send_ptr
>
(
buf
),
buf_len
,
0
,
ep
.
caddress
(),
len
);
if
(
is_error
(
sres
,
true
))
{
CAF_LOG_ERROR
(
"sendto failed:"
<<
last_socket_error_as_string
());
// Make sure WSAGetLastError gets called immediately on Windows.
auto
err
=
last_socket_error
();
CAF_IGNORE_UNUSED
(
err
);
CAF_LOG_ERROR
(
"sendto failed:"
<<
socket_error_as_string
(
err
));
return
false
;
}
result
=
(
sres
>
0
)
?
static_cast
<
size_t
>
(
sres
)
:
0
;
...
...
libcaf_openssl/src/middleman_actor.cpp
View file @
eed5e9ca
...
...
@@ -85,7 +85,7 @@ struct ssl_policy {
auto
err
=
io
::
network
::
last_socket_error
();
if
(
!
io
::
network
::
would_block_or_temporarily_unavailable
(
err
))
CAF_LOG_ERROR
(
"accept failed:"
<<
io
::
network
::
last_socket_error_as_string
(
));
<<
io
::
network
::
socket_error_as_string
(
err
));
return
false
;
}
io
::
network
::
child_process_inherit
(
result
,
false
);
...
...
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