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
04798607
Commit
04798607
authored
Nov 21, 2018
by
Dominik Charousset
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix sign-conversion warnings
parent
4e16a694
Changes
15
Show whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
61 additions
and
48 deletions
+61
-48
libcaf_core/caf/detail/parser/ascii_to_int.hpp
libcaf_core/caf/detail/parser/ascii_to_int.hpp
+8
-2
libcaf_core/caf/detail/parser/read_ipv4_address.hpp
libcaf_core/caf/detail/parser/read_ipv4_address.hpp
+2
-2
libcaf_core/caf/policy/work_stealing.hpp
libcaf_core/caf/policy/work_stealing.hpp
+3
-2
libcaf_core/src/actor_system.cpp
libcaf_core/src/actor_system.cpp
+0
-5
libcaf_core/src/config_option_set.cpp
libcaf_core/src/config_option_set.cpp
+3
-2
libcaf_core/src/ipv4_address.cpp
libcaf_core/src/ipv4_address.cpp
+2
-1
libcaf_core/src/ipv6_address.cpp
libcaf_core/src/ipv6_address.cpp
+2
-1
libcaf_core/src/make_config_option.cpp
libcaf_core/src/make_config_option.cpp
+3
-3
libcaf_core/src/scheduled_actor.cpp
libcaf_core/src/scheduled_actor.cpp
+5
-5
libcaf_core/src/string_algorithms.cpp
libcaf_core/src/string_algorithms.cpp
+3
-2
libcaf_core/src/uri.cpp
libcaf_core/src/uri.cpp
+2
-1
libcaf_core/test/streambuf.cpp
libcaf_core/test/streambuf.cpp
+2
-2
libcaf_io/caf/io/network/receive_buffer.hpp
libcaf_io/caf/io/network/receive_buffer.hpp
+1
-1
libcaf_openssl/src/manager.cpp
libcaf_openssl/src/manager.cpp
+21
-19
tools/caf-run.cpp
tools/caf-run.cpp
+4
-0
No files found.
libcaf_core/caf/detail/parser/ascii_to_int.hpp
View file @
04798607
...
@@ -27,7 +27,9 @@ template <int Base, class T>
...
@@ -27,7 +27,9 @@ template <int Base, class T>
struct
ascii_to_int
{
struct
ascii_to_int
{
// @pre `c` is a valid ASCII digit, i.e., matches [0-9].
// @pre `c` is a valid ASCII digit, i.e., matches [0-9].
constexpr
T
operator
()(
char
c
)
const
{
constexpr
T
operator
()(
char
c
)
const
{
return
c
-
'0'
;
// Result is guaranteed to have a value between 0 and 10 and can be safely
// cast to any integer type.
return
static_cast
<
T
>
(
c
-
'0'
);
}
}
};
};
...
@@ -38,7 +40,11 @@ struct ascii_to_int<16, T> {
...
@@ -38,7 +40,11 @@ struct ascii_to_int<16, T> {
// Numbers start at position 48 in the ASCII table.
// Numbers start at position 48 in the ASCII table.
// Uppercase characters start at position 65 in the ASCII table.
// Uppercase characters start at position 65 in the ASCII table.
// Lowercase characters start at position 97 in the ASCII table.
// Lowercase characters start at position 97 in the ASCII table.
return
c
<=
'9'
?
c
-
'0'
:
(
c
<=
'F'
?
10
+
(
c
-
'A'
)
:
10
+
(
c
-
'a'
));
// Result is guaranteed to have a value between 0 and 16 and can be safely
// cast to any integer type.
return
static_cast
<
T
>
(
c
<=
'9'
?
c
-
'0'
:
(
c
<=
'F'
?
10
+
(
c
-
'A'
)
:
10
+
(
c
-
'a'
)));
}
}
};
};
...
...
libcaf_core/caf/detail/parser/read_ipv4_address.hpp
View file @
04798607
...
@@ -43,8 +43,8 @@ struct read_ipv4_octet_consumer {
...
@@ -43,8 +43,8 @@ struct read_ipv4_octet_consumer {
std
::
array
<
uint8_t
,
4
>
bytes
;
std
::
array
<
uint8_t
,
4
>
bytes
;
int
octets
=
0
;
int
octets
=
0
;
inline
void
value
(
uint8_t
octet
)
{
void
value
(
uint8_t
octet
)
{
bytes
[
octets
++
]
=
octet
;
bytes
[
static_cast
<
size_t
>
(
octets
++
)
]
=
octet
;
}
}
};
};
...
...
libcaf_core/caf/policy/work_stealing.hpp
View file @
04798607
...
@@ -140,8 +140,9 @@ public:
...
@@ -140,8 +140,9 @@ public:
// dequeue attempts
// dequeue attempts
auto
&
strategies
=
d
(
self
).
strategies
;
auto
&
strategies
=
d
(
self
).
strategies
;
resumable
*
job
=
nullptr
;
resumable
*
job
=
nullptr
;
for
(
int
k
=
0
;
k
<
2
;
++
k
)
{
// iterate over the first two strategies
for
(
size_t
k
=
0
;
k
<
2
;
++
k
)
{
// iterate over the first two strategies
for
(
size_t
i
=
0
;
i
<
strategies
[
k
].
attempts
;
i
+=
strategies
[
k
].
step_size
)
{
for
(
size_t
i
=
0
;
i
<
strategies
[
k
].
attempts
;
i
+=
strategies
[
k
].
step_size
)
{
job
=
d
(
self
).
queue
.
take_head
();
job
=
d
(
self
).
queue
.
take_head
();
if
(
job
)
if
(
job
)
return
job
;
return
job
;
...
...
libcaf_core/src/actor_system.cpp
View file @
04798607
...
@@ -47,11 +47,6 @@ struct kvstate {
...
@@ -47,11 +47,6 @@ struct kvstate {
std
::
unordered_map
<
key_type
,
std
::
pair
<
mapped_type
,
subscriber_set
>>
data
;
std
::
unordered_map
<
key_type
,
std
::
pair
<
mapped_type
,
subscriber_set
>>
data
;
std
::
unordered_map
<
strong_actor_ptr
,
topic_set
>
subscribers
;
std
::
unordered_map
<
strong_actor_ptr
,
topic_set
>
subscribers
;
static
const
char
*
name
;
static
const
char
*
name
;
template
<
class
Processor
>
friend
void
serialize
(
Processor
&
proc
,
kvstate
&
x
,
unsigned
int
)
{
proc
&
x
.
data
;
proc
&
x
.
subscribers
;
}
};
};
const
char
*
kvstate
::
name
=
"config_server"
;
const
char
*
kvstate
::
name
=
"config_server"
;
...
...
libcaf_core/src/config_option_set.cpp
View file @
04798607
...
@@ -177,8 +177,9 @@ auto config_option_set::parse(config_map& config, argument_iterator first,
...
@@ -177,8 +177,9 @@ auto config_option_set::parse(config_map& config, argument_iterator first,
if
(
opt
==
nullptr
)
if
(
opt
==
nullptr
)
return
{
pec
::
not_an_option
,
i
};
return
{
pec
::
not_an_option
,
i
};
auto
code
=
consume
(
*
opt
,
auto
code
=
consume
(
*
opt
,
assign_op
==
npos
?
i
->
end
()
assign_op
==
npos
:
i
->
begin
()
+
assign_op
+
1
,
?
i
->
end
()
:
i
->
begin
()
+
static_cast
<
ptrdiff_t
>
(
assign_op
+
1
),
i
->
end
());
i
->
end
());
if
(
code
!=
pec
::
success
)
if
(
code
!=
pec
::
success
)
return
{
code
,
i
};
return
{
code
,
i
};
...
...
libcaf_core/src/ipv4_address.cpp
View file @
04798607
...
@@ -94,7 +94,8 @@ error parse(string_view str, ipv4_address& dest) {
...
@@ -94,7 +94,8 @@ error parse(string_view str, ipv4_address& dest) {
parser
::
read_ipv4_address
(
res
,
f
);
parser
::
read_ipv4_address
(
res
,
f
);
if
(
res
.
code
==
pec
::
success
)
if
(
res
.
code
==
pec
::
success
)
return
none
;
return
none
;
return
make_error
(
res
.
code
,
res
.
line
,
res
.
column
);
return
make_error
(
res
.
code
,
static_cast
<
size_t
>
(
res
.
line
),
static_cast
<
size_t
>
(
res
.
column
));
}
}
}
// namespace caf
}
// namespace caf
libcaf_core/src/ipv6_address.cpp
View file @
04798607
...
@@ -217,7 +217,8 @@ error parse(string_view str, ipv6_address& dest) {
...
@@ -217,7 +217,8 @@ error parse(string_view str, ipv6_address& dest) {
parser
::
read_ipv6_address
(
res
,
f
);
parser
::
read_ipv6_address
(
res
,
f
);
if
(
res
.
code
==
pec
::
success
)
if
(
res
.
code
==
pec
::
success
)
return
none
;
return
none
;
return
make_error
(
res
.
code
,
res
.
line
,
res
.
column
);
return
make_error
(
res
.
code
,
static_cast
<
size_t
>
(
res
.
line
),
static_cast
<
size_t
>
(
res
.
column
));
}
}
}
// namespace caf
}
// namespace caf
libcaf_core/src/make_config_option.cpp
View file @
04798607
...
@@ -104,15 +104,15 @@ meta_state ms_res_meta{
...
@@ -104,15 +104,15 @@ meta_state ms_res_meta{
return
make_error
(
pec
::
type_mismatch
);
return
make_error
(
pec
::
type_mismatch
);
},
},
[](
void
*
ptr
,
const
config_value
&
x
)
{
[](
void
*
ptr
,
const
config_value
&
x
)
{
*
static_cast
<
size_t
*>
(
ptr
)
=
get
<
timespan
>
(
x
).
count
()
/
1000000
;
*
static_cast
<
size_t
*>
(
ptr
)
=
static_cast
<
size_t
>
(
get
<
timespan
>
(
x
).
count
()
/
1000000
);
},
},
[](
const
void
*
ptr
)
->
config_value
{
[](
const
void
*
ptr
)
->
config_value
{
auto
ival
=
static_cast
<
int64_t
>
(
*
static_cast
<
const
size_t
*>
(
ptr
));
auto
ival
=
static_cast
<
int64_t
>
(
*
static_cast
<
const
size_t
*>
(
ptr
));
timespan
val
{
ival
*
1000000
};
timespan
val
{
ival
*
1000000
};
return
config_value
{
val
};
return
config_value
{
val
};
},
},
detail
::
type_name
<
timespan
>
()
detail
::
type_name
<
timespan
>
()};
};
}
// namespace
}
// namespace
...
...
libcaf_core/src/scheduled_actor.cpp
View file @
04798607
...
@@ -130,12 +130,12 @@ scheduled_actor::scheduled_actor(actor_config& cfg)
...
@@ -130,12 +130,12 @@ scheduled_actor::scheduled_actor(actor_config& cfg)
CAF_ASSERT
(
interval
.
count
()
>
0
);
CAF_ASSERT
(
interval
.
count
()
>
0
);
stream_ticks_
.
interval
(
interval
);
stream_ticks_
.
interval
(
interval
);
CAF_ASSERT
(
sys_cfg
.
stream_max_batch_delay
.
count
()
>
0
);
CAF_ASSERT
(
sys_cfg
.
stream_max_batch_delay
.
count
()
>
0
);
max_batch_delay_ticks_
=
sys_cfg
.
stream_max_batch_delay
.
count
()
auto
div
=
[](
timespan
x
,
timespan
y
)
{
/
interval
.
count
();
return
static_cast
<
size_t
>
(
x
.
count
()
/
y
.
count
());
};
max_batch_delay_ticks_
=
div
(
sys_cfg
.
stream_max_batch_delay
,
interval
);
CAF_ASSERT
(
max_batch_delay_ticks_
>
0
);
CAF_ASSERT
(
max_batch_delay_ticks_
>
0
);
CAF_ASSERT
(
sys_cfg
.
stream_credit_round_interval
.
count
()
>
0
);
credit_round_ticks_
=
div
(
sys_cfg
.
stream_credit_round_interval
,
interval
);
credit_round_ticks_
=
sys_cfg
.
stream_credit_round_interval
.
count
()
/
interval
.
count
();
CAF_ASSERT
(
credit_round_ticks_
>
0
);
CAF_ASSERT
(
credit_round_ticks_
>
0
);
CAF_LOG_DEBUG
(
CAF_ARG
(
interval
)
<<
CAF_ARG
(
max_batch_delay_ticks_
)
CAF_LOG_DEBUG
(
CAF_ARG
(
interval
)
<<
CAF_ARG
(
max_batch_delay_ticks_
)
<<
CAF_ARG
(
credit_round_ticks_
));
<<
CAF_ARG
(
credit_round_ticks_
));
...
...
libcaf_core/src/string_algorithms.cpp
View file @
04798607
...
@@ -75,10 +75,11 @@ void replace_all(std::string& str, string_view what, string_view with) {
...
@@ -75,10 +75,11 @@ void replace_all(std::string& str, string_view what, string_view with) {
while
(
i
!=
str
.
end
())
{
while
(
i
!=
str
.
end
())
{
auto
before
=
std
::
distance
(
str
.
begin
(),
i
);
auto
before
=
std
::
distance
(
str
.
begin
(),
i
);
CAF_ASSERT
(
before
>=
0
);
CAF_ASSERT
(
before
>=
0
);
str
.
replace
(
i
,
i
+
what
.
size
(),
with
.
begin
(),
with
.
end
());
auto
ws
=
static_cast
<
decltype
(
before
)
>
(
what
.
size
());
str
.
replace
(
i
,
i
+
ws
,
with
.
begin
(),
with
.
end
());
// Iterator i became invalidated -> use new iterator pointing to the first
// Iterator i became invalidated -> use new iterator pointing to the first
// character after the replaced text.
// character after the replaced text.
i
=
next
(
str
.
begin
()
+
before
+
w
ith
.
size
()
);
i
=
next
(
str
.
begin
()
+
before
+
w
s
);
}
}
}
}
...
...
libcaf_core/src/uri.cpp
View file @
04798607
...
@@ -105,7 +105,8 @@ error parse(string_view str, uri& dest) {
...
@@ -105,7 +105,8 @@ error parse(string_view str, uri& dest) {
dest
=
builder
.
make
();
dest
=
builder
.
make
();
return
none
;
return
none
;
}
}
return
make_error
(
res
.
code
,
res
.
line
,
res
.
column
);
return
make_error
(
res
.
code
,
static_cast
<
size_t
>
(
res
.
line
),
static_cast
<
size_t
>
(
res
.
column
));
}
}
}
// namespace caf
}
// namespace caf
libcaf_core/test/streambuf.cpp
View file @
04798607
...
@@ -131,11 +131,11 @@ CAF_TEST(containerbuf_reset_get_area) {
...
@@ -131,11 +131,11 @@ CAF_TEST(containerbuf_reset_get_area) {
std
::
vector
<
char
>
buf
;
std
::
vector
<
char
>
buf
;
vectorbuf
vb
{
buf
};
vectorbuf
vb
{
buf
};
// We can always write to the underlying buffer; no put area needed.
// We can always write to the underlying buffer; no put area needed.
auto
n
=
vb
.
sputn
(
str
.
data
(),
st
r
.
size
(
));
auto
n
=
vb
.
sputn
(
str
.
data
(),
st
atic_cast
<
std
::
streamsize
>
(
str
.
size
()
));
CAF_REQUIRE_EQUAL
(
n
,
6
);
CAF_REQUIRE_EQUAL
(
n
,
6
);
// Readjust the get area.
// Readjust the get area.
CAF_REQUIRE_EQUAL
(
buf
.
size
(),
6u
);
CAF_REQUIRE_EQUAL
(
buf
.
size
(),
6u
);
vb
.
pubsetbuf
(
buf
.
data
()
+
3
,
buf
.
size
()
-
3
);
vb
.
pubsetbuf
(
buf
.
data
()
+
3
,
static_cast
<
std
::
streamsize
>
(
buf
.
size
()
-
3
)
);
// Now read from a new get area into a buffer.
// Now read from a new get area into a buffer.
char
bar
[
3
];
char
bar
[
3
];
n
=
vb
.
sgetn
(
bar
,
3
);
n
=
vb
.
sgetn
(
bar
,
3
);
...
...
libcaf_io/caf/io/network/receive_buffer.hpp
View file @
04798607
...
@@ -184,7 +184,7 @@ public:
...
@@ -184,7 +184,7 @@ public:
return
pos
;
return
pos
;
auto
offset
=
static_cast
<
size_t
>
(
std
::
distance
(
begin
(),
pos
));
auto
offset
=
static_cast
<
size_t
>
(
std
::
distance
(
begin
(),
pos
));
auto
old_size
=
size_
;
auto
old_size
=
size_
;
resize
(
old_size
+
n
);
resize
(
old_size
+
static_cast
<
size_t
>
(
n
)
);
pos
=
begin
()
+
offset
;
pos
=
begin
()
+
offset
;
if
(
offset
!=
old_size
)
{
if
(
offset
!=
old_size
)
{
memmove
(
pos
+
n
,
pos
,
old_size
-
offset
);
memmove
(
pos
+
n
,
pos
,
old_size
-
offset
);
...
...
libcaf_openssl/src/manager.cpp
View file @
04798607
...
@@ -39,45 +39,48 @@ CAF_POP_WARNINGS
...
@@ -39,45 +39,48 @@ CAF_POP_WARNINGS
#include "caf/openssl/middleman_actor.hpp"
#include "caf/openssl/middleman_actor.hpp"
#if OPENSSL_VERSION_NUMBER < 0x10100000L
struct
CRYPTO_dynlock_value
{
struct
CRYPTO_dynlock_value
{
std
::
mutex
mtx
;
std
::
mutex
mtx
;
};
};
namespace
caf
{
namespace
{
namespace
openssl
{
#if OPENSSL_VERSION_NUMBER < 0x10100000L
int
init_count
=
0
;
static
int
init_count
=
0
;
static
std
::
mutex
init_mutex
;
std
::
mutex
init_mutex
;
static
std
::
vector
<
std
::
mutex
>
mutexes
;
std
::
vector
<
std
::
mutex
>
mutexes
;
static
void
locking_function
(
int
mode
,
int
n
,
void
locking_function
(
int
mode
,
int
n
,
const
char
*
,
int
)
{
const
char
*
/* file */
,
int
/* line */
)
{
if
(
mode
&
CRYPTO_LOCK
)
if
(
mode
&
CRYPTO_LOCK
)
mutexes
[
n
].
lock
();
mutexes
[
static_cast
<
size_t
>
(
n
)
].
lock
();
else
else
mutexes
[
n
].
unlock
();
mutexes
[
static_cast
<
size_t
>
(
n
)
].
unlock
();
}
}
static
CRYPTO_dynlock_value
*
dynlock_create
(
const
char
*
/* file */
,
CRYPTO_dynlock_value
*
dynlock_create
(
const
char
*
,
int
)
{
int
/* line */
)
{
return
new
CRYPTO_dynlock_value
;
return
new
CRYPTO_dynlock_value
{};
}
}
static
void
dynlock_lock
(
int
mode
,
CRYPTO_dynlock_value
*
dynlock
,
void
dynlock_lock
(
int
mode
,
CRYPTO_dynlock_value
*
dynlock
,
const
char
*
,
int
)
{
const
char
*
/* file */
,
int
/* line */
)
{
if
(
mode
&
CRYPTO_LOCK
)
if
(
mode
&
CRYPTO_LOCK
)
dynlock
->
mtx
.
lock
();
dynlock
->
mtx
.
lock
();
else
else
dynlock
->
mtx
.
unlock
();
dynlock
->
mtx
.
unlock
();
}
}
static
void
dynlock_destroy
(
CRYPTO_dynlock_value
*
dynlock
,
void
dynlock_destroy
(
CRYPTO_dynlock_value
*
dynlock
,
const
char
*
,
int
)
{
const
char
*
/* file */
,
int
/* line */
)
{
delete
dynlock
;
delete
dynlock
;
}
}
}
// namespace <anonymous>
#endif
#endif
namespace
caf
{
namespace
openssl
{
manager
::~
manager
()
{
manager
::~
manager
()
{
#if OPENSSL_VERSION_NUMBER < 0x10100000L
#if OPENSSL_VERSION_NUMBER < 0x10100000L
std
::
lock_guard
<
std
::
mutex
>
lock
{
init_mutex
};
std
::
lock_guard
<
std
::
mutex
>
lock
{
init_mutex
};
...
@@ -119,12 +122,11 @@ void manager::init(actor_system_config&) {
...
@@ -119,12 +122,11 @@ void manager::init(actor_system_config&) {
if
(
system
().
config
().
openssl_key
.
size
()
==
0
)
if
(
system
().
config
().
openssl_key
.
size
()
==
0
)
CAF_RAISE_ERROR
(
"No private key configured for SSL endpoint"
);
CAF_RAISE_ERROR
(
"No private key configured for SSL endpoint"
);
}
}
#if OPENSSL_VERSION_NUMBER < 0x10100000L
#if OPENSSL_VERSION_NUMBER < 0x10100000L
std
::
lock_guard
<
std
::
mutex
>
lock
{
init_mutex
};
std
::
lock_guard
<
std
::
mutex
>
lock
{
init_mutex
};
++
init_count
;
++
init_count
;
if
(
init_count
==
1
)
{
if
(
init_count
==
1
)
{
mutexes
=
std
::
vector
<
std
::
mutex
>
(
CRYPTO_num_locks
())
;
mutexes
=
std
::
vector
<
std
::
mutex
>
{
static_cast
<
size_t
>
(
CRYPTO_num_locks
())}
;
CRYPTO_set_locking_callback
(
locking_function
);
CRYPTO_set_locking_callback
(
locking_function
);
CRYPTO_set_dynlock_create_callback
(
dynlock_create
);
CRYPTO_set_dynlock_create_callback
(
dynlock_create
);
CRYPTO_set_dynlock_lock_callback
(
dynlock_lock
);
CRYPTO_set_dynlock_lock_callback
(
dynlock_lock
);
...
...
tools/caf-run.cpp
View file @
04798607
...
@@ -244,6 +244,8 @@ void bootstrap(actor_system& system,
...
@@ -244,6 +244,8 @@ void bootstrap(actor_system& system,
return 1; \
return 1; \
} while (true)
} while (true)
namespace
{
struct
config
:
actor_system_config
{
struct
config
:
actor_system_config
{
config
()
{
config
()
{
opt_group
{
custom_options_
,
"global"
}
opt_group
{
custom_options_
,
"global"
}
...
@@ -254,6 +256,8 @@ struct config : actor_system_config {
...
@@ -254,6 +256,8 @@ struct config : actor_system_config {
string
wdir
;
string
wdir
;
};
};
}
// namespace <anonymous>
int
main
(
int
argc
,
char
**
argv
)
{
int
main
(
int
argc
,
char
**
argv
)
{
config
cfg
;
config
cfg
;
cfg
.
parse
(
argc
,
argv
);
cfg
.
parse
(
argc
,
argv
);
...
...
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