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
b1035b56
Commit
b1035b56
authored
Mar 06, 2014
by
Dominik Charousset
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed includes + minor issues in MinGW build
parent
a1a11c74
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
49 additions
and
58 deletions
+49
-58
cppa/config.hpp
cppa/config.hpp
+1
-1
src/fd_util.cpp
src/fd_util.cpp
+10
-6
src/get_mac_addresses.cpp
src/get_mac_addresses.cpp
+0
-3
src/get_root_uuid.cpp
src/get_root_uuid.cpp
+27
-10
src/ipv4_acceptor.cpp
src/ipv4_acceptor.cpp
+2
-31
src/middleman.cpp
src/middleman.cpp
+2
-2
src/middleman_event_handler.cpp
src/middleman_event_handler.cpp
+5
-3
unit_testing/test_spawn.cpp
unit_testing/test_spawn.cpp
+2
-2
No files found.
cppa/config.hpp
View file @
b1035b56
...
...
@@ -140,7 +140,7 @@ std::unique_ptr<T> create_unique(Args&&... args) {
constexpr
SOCKET
invalid_socket
=
INVALID_SOCKET
;
inline
int
last_socket_error
()
{
return
WSAGetLastError
();
}
inline
bool
would_block_or_temporarily_unavailable
(
int
errcode
)
{
return
errcode
==
WSAEWOULDBLOCK
||
errcode
=
WSATRY_AGAIN
;
return
errcode
==
WSAEWOULDBLOCK
||
errcode
=
=
WSATRY_AGAIN
;
}
#else
typedef
int
native_socket_type
;
...
...
src/fd_util.cpp
View file @
b1035b56
...
...
@@ -32,9 +32,8 @@
#include <sstream>
#include <cstring>
// socket related functions
#include <sys/types.h>
#include <sys/socket.h>
#include "cppa/config.hpp"
#include "cppa/exception.hpp"
#ifdef CPPA_WINDOWS
# include <winsock2.h>
...
...
@@ -42,6 +41,8 @@
# include <windows.h>
# include <io.h>
#else
# include <sys/types.h>
# include <sys/socket.h>
# include <errno.h>
# include <netdb.h>
# include <fcntl.h>
...
...
@@ -49,7 +50,8 @@
# include <netinet/tcp.h>
#endif
#include "cppa/exception.hpp"
#include "cppa/util/scope_guard.hpp"
#include "cppa/detail/fd_util.hpp"
/************** implementation of platform-independent functions **************/
...
...
@@ -68,7 +70,8 @@ void throw_io_failure(const char* what, bool add_errno_failure) {
void
tcp_nodelay
(
native_socket_type
fd
,
bool
new_value
)
{
int
flag
=
new_value
?
1
:
0
;
if
(
setsockopt
(
fd
,
IPPROTO_TCP
,
TCP_NODELAY
,
&
flag
,
sizeof
(
flag
))
<
0
)
{
if
(
setsockopt
(
fd
,
IPPROTO_TCP
,
TCP_NODELAY
,
reinterpret_cast
<
setsockopt_ptr
>
(
&
flag
),
sizeof
(
flag
))
<
0
)
{
throw_io_failure
(
"unable to set TCP_NODELAY"
);
}
}
...
...
@@ -128,6 +131,7 @@ namespace cppa { namespace detail { namespace fd_util {
std
::
string
last_socket_error_as_string
()
{
LPTSTR
errorText
=
NULL
;
auto
hresult
=
last_socket_error
();
FormatMessage
(
// use system message tables to retrieve error text
FORMAT_MESSAGE_FROM_SYSTEM
// allocate buffer on local heap for error text
...
...
@@ -160,7 +164,7 @@ void nonblocking(native_socket_type fd, bool new_value) {
// wraps a C call and throws an IO failure if f returns an integer != 0
template
<
typename
F
,
typename
...
Ts
>
inline
void
ccall
(
const
char
*
errmsg
,
F
f
,
Ts
&&
...
args
)
{
if
(
f
(
std
::
forward
<
Ts
>
(
args
...)
)
!=
0
)
{
if
(
f
(
std
::
forward
<
Ts
>
(
args
)...
)
!=
0
)
{
throw_io_failure
(
errmsg
);
}
}
...
...
src/get_mac_addresses.cpp
View file @
b1035b56
...
...
@@ -181,9 +181,6 @@ std::vector<std::string> get_mac_addresses() {
#include <stdio.h>
#include <stdlib.h>
#include "cppa/singletons.hpp"
#include "cppa/windows/windows_tcp.hpp"
// Link with Iphlpapi.lib
// #pragma comment(lib, "IPHLPAPI.lib") -liphlpapi
namespace
{
...
...
src/get_root_uuid.cpp
View file @
b1035b56
...
...
@@ -189,34 +189,51 @@ std::string get_root_uuid() {
#elif defined(CPPA_WINDOWS)
#include <windows.h>
#include <stdio.h>
#include <tchar.h>
#include <string>
#include <iostream>
#include <algorithm>
#include <windows.h>
#include <tchar.h>
using
namespace
std
;
namespace
cppa
{
namespace
util
{
namespace
{
constexpr
size_t
max_drive_name
=
MAX_PATH
;
}
// if TCHAR is indeed a char, we can simply move rhs
void
mv
(
std
::
string
&
lhs
,
std
::
string
&&
rhs
)
{
lhs
=
std
::
move
(
rhs
);
}
// if TCHAR is defined as WCHAR, we have to do unicode conversion
void
mv
(
std
::
string
&
lhs
,
const
std
::
basic_string
<
WCHAR
>&
rhs
)
{
auto
size_needed
=
WideCharToMultiByte
(
CP_UTF8
,
0
,
rhs
.
c_str
(),
static_cast
<
int
>
(
rhs
.
size
()),
nullptr
,
0
,
nullptr
,
nullptr
);
lhs
.
resize
(
size_needed
);
WideCharToMultiByte
(
CP_UTF8
,
0
,
rhs
.
c_str
(),
static_cast
<
int
>
(
rhs
.
size
()),
&
lhs
[
0
],
size_needed
,
nullptr
,
nullptr
);
}
std
::
string
get_root_uuid
()
{
typedef
std
::
basic_string
<
TCHAR
>
tchar_str
;
string
uuid
;
char
drive_name
[
max_drive_name
];
// temporary buffer for volume name
auto
drive
=
TEXT
(
"c:
\\
"
);
// string "template" for drive specifier
TCHAR
buf
[
max_drive_name
];
// temporary buffer for volume name
tchar_str
drive
=
TEXT
(
"c:
\\
"
);
// string "template" for drive specifier
// walk through legal drive letters, skipping floppies
for
(
auto
i
=
TEXT
(
'c'
);
i
<
TEXT
(
'z'
);
i
++
)
{
for
(
TCHAR
i
=
TEXT
(
'c'
);
i
<
TEXT
(
'z'
);
i
++
)
{
// Stamp the drive for the appropriate letter.
drive
[
0
]
=
i
;
if
(
GetVolumeNameForVolumeMountPoint
(
drive
,
drive_name
,
max_drive_name
))
{
auto
first
=
drive_name
.
find
(
"Volume{"
);
if
(
GetVolumeNameForVolumeMountPoint
(
drive
.
c_str
(),
buf
,
max_drive_name
))
{
tchar_str
drive_name
=
buf
;
auto
first
=
drive_name
.
find
(
TEXT
(
"Volume{"
));
if
(
first
!=
std
::
string
::
npos
)
{
first
+=
7
;
auto
last
=
drive_name
.
find
(
"}"
,
first
);
auto
last
=
drive_name
.
find
(
TEXT
(
"}"
)
,
first
);
if
(
last
!=
std
::
string
::
npos
&&
last
>
first
)
{
uuid
=
drive_name
.
substr
(
first
,
last
-
first
);
mv
(
uuid
,
drive_name
.
substr
(
first
,
last
-
first
)
);
// UUIDs are formatted as 8-4-4-4-12 hex digits groups
auto
cpy
=
uuid
;
replace_if
(
cpy
.
begin
(),
cpy
.
end
(),
::
isxdigit
,
'F'
);
...
...
src/ipv4_acceptor.cpp
View file @
b1035b56
...
...
@@ -45,8 +45,6 @@
#ifdef CPPA_WINDOWS
# include <winsock2.h>
# include <ws2tcpip.h>
# include "cppa/singletons.hpp"
# include "cppa/windows/windows_tcp.hpp"
#else
# include <netdb.h>
# include <unistd.h>
...
...
@@ -82,40 +80,13 @@ struct socket_guard {
};
#ifdef CPPA_WINDOWS
inline
native_socket_type
do_accept
(
native_socket_type
fd
,
sockaddr
*
addr
,
socklen_t
*
addrlen
)
{
return
::
WSAAccept
(
fd
,
addr
,
addrlen
,
0
,
0
)
}
#else
inline
native_socket_type
do_accept
(
native_socket_type
fd
,
sockaddr
*
addr
,
socklen_t
*
addrlen
)
{
return
::
accept
(
fd
,
addr
,
addrlen
);
}
#endif
bool
accept_impl
(
stream_ptr_pair
&
result
,
native_socket_type
fd
,
bool
nonblocking
)
{
/*
sockaddr addr;
memset(&addr, 0, sizeof(addr));
*/
//socklen_t addrlen = sizeof(addr);
/*
socklen_t addrlen;
memset(&addrlen, 0, sizeof(addrlen));
# ifdef CPPA_WINDOWS
addrlen = sizeof(addr);
# endif
*/
sockaddr
addr
;
socklen_t
addrlen
;
memset
(
&
addr
,
0
,
sizeof
(
addr
));
memset
(
&
addrlen
,
0
,
sizeof
(
addrlen
)
);
auto
sfd
=
do_
accept
(
fd
,
&
addr
,
&
addrlen
);
socklen_t
addrlen
=
sizeof
(
addr
);
auto
sfd
=
::
accept
(
fd
,
&
addr
,
&
addrlen
);
if
(
sfd
==
invalid_socket
)
{
auto
err
=
last_socket_error
();
if
(
nonblocking
&&
would_block_or_temporarily_unavailable
(
err
))
{
...
...
src/middleman.cpp
View file @
b1035b56
...
...
@@ -79,7 +79,7 @@ using namespace std;
namespace
cppa
{
namespace
io
{
void
notify_queue_event
(
native_socket_type
fd
)
{
uint8_t
dummy
=
0
;
char
dummy
=
0
;
// on unix, we have file handles, on windows, we actually have sockets
# ifdef CPPA_WINDOWS
auto
res
=
::
send
(
fd
,
&
dummy
,
sizeof
(
dummy
),
0
);
...
...
@@ -92,7 +92,7 @@ void notify_queue_event(native_socket_type fd) {
size_t
num_queue_events
(
native_socket_type
fd
)
{
static
constexpr
size_t
num_dummies
=
64
;
uint8_t
dummies
[
num_dummies
];
char
dummies
[
num_dummies
];
// on unix, we have file handles, on windows, we actually have sockets
# ifdef CPPA_WINDOWS
auto
read_result
=
::
recv
(
fd
,
dummies
,
num_dummies
,
0
);
...
...
src/middleman_event_handler.cpp
View file @
b1035b56
...
...
@@ -111,9 +111,9 @@ void middleman_event_handler::update() {
CPPA_LOG_DEBUG
(
"new bitmask for "
<<
elem
.
ptr
<<
": "
<<
eb2str
(
mask
));
if
(
iter
==
last
||
iter
->
fd
!=
elem
.
fd
)
{
CPPA_LOG_ERROR_IF
(
mask
==
event
::
none
,
"cannot erase "
<<
ptr
<<
" (no such element)"
);
if
(
mask
!=
event
::
none
)
{
// element has been removed from m_meta by an
// previous alteration but is not put back in
m_meta
.
insert
(
iter
,
elem
);
handle_event
(
fd_meta_event
::
add
,
elem
.
fd
,
event
::
none
,
mask
,
ptr
);
...
...
@@ -138,11 +138,13 @@ void middleman_event_handler::update() {
// m_meta won't be touched inside loop
auto
first
=
m_meta
.
begin
();
auto
last
=
m_meta
.
end
();
// checks whether an element can be safely deleted,
// i.e., was not put back into m_meta by some alteration
auto
is_alive
=
[
&
](
native_socket_type
fd
)
->
bool
{
auto
iter
=
std
::
lower_bound
(
first
,
last
,
fd
,
mless
);
return
iter
!=
last
&&
iter
->
fd
==
fd
;
};
//
check whether elements in dispose list can be safely deleted
//
dispose everything that wasn't put back into m_meta again
for
(
auto
elem
:
m_dispose_list
)
{
auto
rd
=
elem
->
read_handle
();
auto
wr
=
elem
->
write_handle
();
...
...
unit_testing/test_spawn.cpp
View file @
b1035b56
...
...
@@ -833,8 +833,8 @@ void test_spawn() {
// create some actors linked to one single actor
// and kill them all through killing the link
auto
legion
=
spawn
([](
event_based_actor
*
self
)
{
CPPA_PRINT
(
"spawn 1
, 0
00 actors"
);
for
(
int
i
=
0
;
i
<
100
0
;
++
i
)
{
CPPA_PRINT
(
"spawn 100 actors"
);
for
(
int
i
=
0
;
i
<
100
;
++
i
)
{
self
->
spawn
<
event_testee
,
linked
>
();
}
self
->
become
(
others
()
>>
CPPA_UNEXPECTED_MSG_CB
());
...
...
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