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
b1f48501
Commit
b1f48501
authored
Nov 21, 2012
by
Lourens Naudé
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Let socket event messages initialize with zmq_msg_init_data and let the framework handle cleanup
parent
f78ca629
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
50 additions
and
2 deletions
+50
-2
socket_base.cpp
src/socket_base.cpp
+4
-2
socket_base.hpp
src/socket_base.hpp
+5
-0
zmq.cpp
src/zmq.cpp
+41
-0
No files found.
src/socket_base.cpp
View file @
b1f48501
...
...
@@ -1178,8 +1178,10 @@ void zmq::socket_base_t::monitor_event (zmq_event_t event_)
{
if
(
monitor_socket
)
{
zmq_msg_t
msg
;
zmq_msg_init_size
(
&
msg
,
sizeof
(
event_
));
memcpy
(
zmq_msg_data
(
&
msg
),
&
event_
,
sizeof
(
event_
));
void
*
event_data
=
malloc
(
sizeof
(
event_
));
assert
(
event_data
);
memcpy
(
event_data
,
&
event_
,
sizeof
(
event_
));
zmq_msg_init_data
(
&
msg
,
event_data
,
sizeof
(
event_
),
zmq_free_event
,
NULL
);
zmq_sendmsg
(
monitor_socket
,
&
msg
,
0
);
zmq_msg_close
(
&
msg
);
}
...
...
src/socket_base.hpp
View file @
b1f48501
...
...
@@ -38,6 +38,11 @@
#include "clock.hpp"
#include "pipe.hpp"
extern
"C"
{
void
zmq_free_event
(
void
*
data
,
void
*
hint
);
}
namespace
zmq
{
...
...
src/zmq.cpp
View file @
b1f48501
...
...
@@ -987,6 +987,47 @@ int zmq_device (int type, void *frontend_, void *backend_)
(
zmq
::
socket_base_t
*
)
backend_
,
NULL
);
}
// Callback to free socket event data
void
zmq_free_event
(
void
*
event_data
,
void
*
hint
)
{
zmq_event_t
*
event
=
(
zmq_event_t
*
)
event_data
;
switch
(
event
->
event
)
{
case
ZMQ_EVENT_CONNECTED
:
free
(
event
->
data
.
connected
.
addr
);
break
;
case
ZMQ_EVENT_CONNECT_DELAYED
:
free
(
event
->
data
.
connect_delayed
.
addr
);
break
;
case
ZMQ_EVENT_CONNECT_RETRIED
:
free
(
event
->
data
.
connect_retried
.
addr
);
break
;
case
ZMQ_EVENT_LISTENING
:
free
(
event
->
data
.
listening
.
addr
);
break
;
case
ZMQ_EVENT_BIND_FAILED
:
free
(
event
->
data
.
bind_failed
.
addr
);
break
;
case
ZMQ_EVENT_ACCEPTED
:
free
(
event
->
data
.
accepted
.
addr
);
break
;
case
ZMQ_EVENT_ACCEPT_FAILED
:
free
(
event
->
data
.
accept_failed
.
addr
);
break
;
case
ZMQ_EVENT_CLOSED
:
free
(
event
->
data
.
closed
.
addr
);
break
;
case
ZMQ_EVENT_CLOSE_FAILED
:
free
(
event
->
data
.
close_failed
.
addr
);
break
;
case
ZMQ_EVENT_DISCONNECTED
:
free
(
event
->
data
.
disconnected
.
addr
);
break
;
}
free
(
event_data
);
}
////////////////////////////////////////////////////////////////////////////////
// 0MQ utils - to be used by perf tests
////////////////////////////////////////////////////////////////////////////////
...
...
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