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
48a1e637
Commit
48a1e637
authored
Aug 29, 2017
by
sigiesec
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Problem: zmq_socket_get_peer_state is not implemented
Solution: add initial implementation
parent
cda20260
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
40 additions
and
3 deletions
+40
-3
router.cpp
src/router.cpp
+21
-0
router.hpp
src/router.hpp
+1
-0
socket_base.cpp
src/socket_base.cpp
+8
-0
socket_base.hpp
src/socket_base.hpp
+5
-1
zmq.cpp
src/zmq.cpp
+5
-2
No files found.
src/router.cpp
View file @
48a1e637
...
...
@@ -443,6 +443,27 @@ zmq::blob_t zmq::router_t::get_credential () const
return
fq
.
get_credential
();
}
int
zmq
::
router_t
::
get_peer_state
(
const
void
*
identity
,
size_t
identity_size
)
const
{
int
res
=
0
;
blob_t
identity_blob
((
unsigned
char
*
)
identity
,
identity_size
);
outpipes_t
::
const_iterator
it
=
outpipes
.
find
(
identity_blob
);
if
(
it
==
outpipes
.
end
())
{
errno
=
EHOSTUNREACH
;
return
-
1
;
}
const
outpipe_t
&
outpipe
=
it
->
second
;
if
(
outpipe
.
pipe
->
check_hwm
())
res
|=
ZMQ_POLLOUT
;
/** \todo does it make any sense to check the inpipe as well? */
return
res
;
}
bool
zmq
::
router_t
::
identify_peer
(
pipe_t
*
pipe_
)
{
msg_t
msg
;
...
...
src/router.hpp
View file @
48a1e637
...
...
@@ -64,6 +64,7 @@ namespace zmq
void
xread_activated
(
zmq
::
pipe_t
*
pipe_
);
void
xwrite_activated
(
zmq
::
pipe_t
*
pipe_
);
void
xpipe_terminated
(
zmq
::
pipe_t
*
pipe_
);
int
get_peer_state
(
const
void
*
identity
,
size_t
identity_size
)
const
;
protected
:
...
...
src/socket_base.cpp
View file @
48a1e637
...
...
@@ -221,6 +221,14 @@ zmq::socket_base_t::socket_base_t (ctx_t *parent_, uint32_t tid_, int sid_, bool
}
}
int
zmq
::
socket_base_t
::
get_peer_state
(
const
void
*
identity
,
size_t
identity_size
)
const
{
// Only ROUTER sockets support this
errno
=
ENOTSUP
;
return
-
1
;
}
zmq
::
socket_base_t
::~
socket_base_t
()
{
if
(
mailbox
)
...
...
src/socket_base.hpp
View file @
48a1e637
...
...
@@ -138,6 +138,11 @@ namespace zmq
void
event_handshake_failed_auth
(
const
std
::
string
&
addr_
,
int
err_
);
void
event_handshake_succeeded
(
const
std
::
string
&
addr_
,
int
err_
);
// Query the state of a specific peer. The default implementation
// always returns an ENOTSUP error.
virtual
int
get_peer_state
(
const
void
*
identity
,
size_t
identity_size
)
const
;
protected
:
socket_base_t
(
zmq
::
ctx_t
*
parent_
,
uint32_t
tid_
,
int
sid_
,
bool
thread_safe_
=
false
);
...
...
@@ -180,7 +185,6 @@ namespace zmq
// Delay actual destruction of the socket.
void
process_destroy
();
// Next assigned name on a zmq_connect() call used by ROUTER and STREAM socket types
std
::
string
connect_rid
;
...
...
src/zmq.cpp
View file @
48a1e637
...
...
@@ -1358,12 +1358,15 @@ int zmq_poller_wait_all (void *poller_, zmq_poller_event_t *events_, int n_event
// Peer-specific state
int
zmq_socket_get_peer_state
(
void
*
s
ocket
,
int
zmq_socket_get_peer_state
(
void
*
s
_
,
const
void
*
identity
,
size_t
identity_size
)
{
errno
=
ENOTSUP
;
zmq
::
socket_base_t
*
s
=
as_socket_base_t
(
s_
);
if
(
!
s
)
return
-
1
;
return
s
->
get_peer_state
(
identity
,
identity_size
);
}
// Timers
...
...
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