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
2524e268
Commit
2524e268
authored
Jun 25, 2014
by
Pieter Hintjens
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Code cleanups
parent
859b43f1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
22 additions
and
41 deletions
+22
-41
socket_base.cpp
src/socket_base.cpp
+13
-29
thread.cpp
src/thread.cpp
+6
-9
ypipe.hpp
src/ypipe.hpp
+3
-3
No files found.
src/socket_base.cpp
View file @
2524e268
...
...
@@ -189,9 +189,13 @@ int zmq::socket_base_t::parse_uri (const char *uri_,
int
zmq
::
socket_base_t
::
check_protocol
(
const
std
::
string
&
protocol_
)
{
// First check out whether the protcol is something we are aware of.
if
(
protocol_
!=
"inproc"
&&
protocol_
!=
"ipc"
&&
protocol_
!=
"tcp"
&&
protocol_
!=
"pgm"
&&
protocol_
!=
"epgm"
&&
protocol_
!=
"tipc"
&&
protocol_
!=
"norm"
)
{
if
(
protocol_
!=
"inproc"
&&
protocol_
!=
"ipc"
&&
protocol_
!=
"tcp"
&&
protocol_
!=
"pgm"
&&
protocol_
!=
"epgm"
&&
protocol_
!=
"tipc"
&&
protocol_
!=
"norm"
)
{
errno
=
EPROTONOSUPPORT
;
return
-
1
;
}
...
...
@@ -356,12 +360,7 @@ int zmq::socket_base_t::bind (const char *addr_)
// Parse addr_ string.
std
::
string
protocol
;
std
::
string
address
;
rc
=
parse_uri
(
addr_
,
protocol
,
address
);
if
(
rc
!=
0
)
return
-
1
;
rc
=
check_protocol
(
protocol
);
if
(
rc
!=
0
)
if
(
parse_uri
(
addr_
,
protocol
,
address
)
||
check_protocol
(
protocol
))
return
-
1
;
if
(
protocol
==
"inproc"
)
{
...
...
@@ -464,12 +463,7 @@ int zmq::socket_base_t::connect (const char *addr_)
// Parse addr_ string.
std
::
string
protocol
;
std
::
string
address
;
rc
=
parse_uri
(
addr_
,
protocol
,
address
);
if
(
rc
!=
0
)
return
-
1
;
rc
=
check_protocol
(
protocol
);
if
(
rc
!=
0
)
if
(
parse_uri
(
addr_
,
protocol
,
address
)
||
check_protocol
(
protocol
))
return
-
1
;
if
(
protocol
==
"inproc"
)
{
...
...
@@ -743,12 +737,7 @@ int zmq::socket_base_t::term_endpoint (const char *addr_)
// Parse addr_ string.
std
::
string
protocol
;
std
::
string
address
;
rc
=
parse_uri
(
addr_
,
protocol
,
address
);
if
(
rc
!=
0
)
return
-
1
;
rc
=
check_protocol
(
protocol
);
if
(
rc
!=
0
)
if
(
parse_uri
(
addr_
,
protocol
,
address
)
||
check_protocol
(
protocol
))
return
-
1
;
// Disconnect an inproc socket
...
...
@@ -1222,12 +1211,7 @@ int zmq::socket_base_t::monitor (const char *addr_, int events_)
// Parse addr_ string.
std
::
string
protocol
;
std
::
string
address
;
int
rc
=
parse_uri
(
addr_
,
protocol
,
address
);
if
(
rc
!=
0
)
return
-
1
;
rc
=
check_protocol
(
protocol
);
if
(
rc
!=
0
)
if
(
parse_uri
(
addr_
,
protocol
,
address
)
||
check_protocol
(
protocol
))
return
-
1
;
// Event notification only supported over inproc://
...
...
@@ -1243,9 +1227,9 @@ int zmq::socket_base_t::monitor (const char *addr_, int events_)
// Never block context termination on pending event messages
int
linger
=
0
;
rc
=
zmq_setsockopt
(
monitor_socket
,
ZMQ_LINGER
,
&
linger
,
sizeof
(
linger
));
int
rc
=
zmq_setsockopt
(
monitor_socket
,
ZMQ_LINGER
,
&
linger
,
sizeof
(
linger
));
if
(
rc
==
-
1
)
stop_monitor
();
stop_monitor
();
// Spawn the monitor socket endpoint
rc
=
zmq_bind
(
monitor_socket
,
addr_
);
...
...
src/thread.cpp
View file @
2524e268
...
...
@@ -84,13 +84,11 @@ extern "C"
}
}
bool
getenvi
(
const
char
*
env_
,
int
&
result_
)
bool
getenvi
(
const
char
*
env_
,
int
&
result_
)
{
char
*
str
=
getenv
(
env_
);
if
(
str
==
NULL
)
{
char
*
str
=
getenv
(
env_
);
if
(
str
==
NULL
)
return
false
;
}
std
::
stringstream
ss
(
str
);
return
ss
>>
result_
;
...
...
@@ -104,14 +102,13 @@ void zmq::thread_t::start (thread_fn *tfn_, void *arg_)
posix_assert
(
rc
);
int
prio
;
if
(
getenvi
(
"ZMQ_THREAD_PRIO"
,
prio
))
{
if
(
getenvi
(
"ZMQ_THREAD_PRIO"
,
prio
))
{
int
policy
=
SCHED_RR
;
getenvi
(
"ZMQ_THREAD_POLICY"
,
policy
);
getenvi
(
"ZMQ_THREAD_POLICY"
,
policy
);
struct
sched_param
param
;
param
.
sched_priority
=
prio
;
rc
=
pthread_setschedparam
(
descriptor
,
policy
,
&
param
);
rc
=
pthread_setschedparam
(
descriptor
,
policy
,
&
param
);
posix_assert
(
rc
);
}
}
...
...
src/ypipe.hpp
View file @
2524e268
...
...
@@ -168,10 +168,10 @@ namespace zmq
// The pipe mustn't be empty or the function crashes.
inline
bool
probe
(
bool
(
*
fn
)(
const
T
&
))
{
bool
rc
=
check_read
();
zmq_assert
(
rc
);
bool
rc
=
check_read
();
zmq_assert
(
rc
);
return
(
*
fn
)
(
queue
.
front
());
return
(
*
fn
)
(
queue
.
front
());
}
protected
:
...
...
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