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
fe3e8c5c
Commit
fe3e8c5c
authored
Apr 30, 2014
by
Stoian Ivanov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
linking fd to pipe identity via socket option
parent
e37c2062
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
57 additions
and
4 deletions
+57
-4
zmq.h
include/zmq.h
+1
-0
i_engine.hpp
src/i_engine.hpp
+6
-1
pipe.cpp
src/pipe.cpp
+1
-0
pipe.hpp
src/pipe.hpp
+3
-0
router.cpp
src/router.cpp
+27
-0
router.hpp
src/router.hpp
+1
-1
session_base.cpp
src/session_base.cpp
+2
-1
socket_base.cpp
src/socket_base.cpp
+10
-0
socket_base.hpp
src/socket_base.hpp
+4
-1
stream_engine.hpp
src/stream_engine.hpp
+2
-0
No files found.
include/zmq.h
View file @
fe3e8c5c
...
...
@@ -300,6 +300,7 @@ ZMQ_EXPORT char *zmq_msg_gets (zmq_msg_t *msg, char *property);
#define ZMQ_GSSAPI_PRINCIPAL 63
#define ZMQ_GSSAPI_SERVICE_PRINCIPAL 64
#define ZMQ_GSSAPI_PLAINTEXT 65
#define ZMQ_IDENTITY_FD 66
/* Message options */
#define ZMQ_MORE 1
...
...
src/i_engine.hpp
View file @
fe3e8c5c
...
...
@@ -20,6 +20,8 @@
#ifndef __ZMQ_I_ENGINE_HPP_INCLUDED__
#define __ZMQ_I_ENGINE_HPP_INCLUDED__
#include "fd.hpp"
namespace
zmq
{
...
...
@@ -47,7 +49,10 @@ namespace zmq
// are messages to send available.
virtual
void
restart_output
()
=
0
;
virtual
void
zap_msg_available
()
=
0
;
virtual
void
zap_msg_available
()
=
0
;
// provide a way to link from engine to file descriptor
virtual
fd_t
get_assoc_fd
()
{
return
retired_fd
;};
};
}
...
...
src/pipe.cpp
View file @
fe3e8c5c
...
...
@@ -65,6 +65,7 @@ int zmq::pipepair (class object_t *parents_ [2], class pipe_t* pipes_ [2],
zmq
::
pipe_t
::
pipe_t
(
object_t
*
parent_
,
upipe_t
*
inpipe_
,
upipe_t
*
outpipe_
,
int
inhwm_
,
int
outhwm_
,
bool
conflate_
)
:
object_t
(
parent_
),
assoc_fd
(
retired_fd
),
inpipe
(
inpipe_
),
outpipe
(
outpipe_
),
in_active
(
true
),
...
...
src/pipe.hpp
View file @
fe3e8c5c
...
...
@@ -27,6 +27,7 @@
#include "stdint.hpp"
#include "array.hpp"
#include "blob.hpp"
#include "fd.hpp"
namespace
zmq
{
...
...
@@ -117,6 +118,8 @@ namespace zmq
// set the high water marks.
void
set_hwms
(
int
inhwm_
,
int
outhwm_
);
// provide a way to link pipe to engine fd. Set on session initialization
fd_t
assoc_fd
;
//=retired_fd
private
:
// Type of the underlying lock-free pipe.
...
...
src/router.cpp
View file @
fe3e8c5c
...
...
@@ -133,6 +133,33 @@ int zmq::router_t::xsetsockopt (int option_, const void *optval_,
return
-
1
;
}
int
zmq
::
router_t
::
xgetsockopt
(
int
option_
,
const
void
*
optval_
,
size_t
*
optvallen_
)
{
switch
(
option_
)
{
case
ZMQ_IDENTITY_FD
:
if
(
optval_
==
NULL
&&
optvallen_
)
{
*
optvallen_
=
sizeof
(
fd_t
);
return
0
;
}
if
(
optval_
&&
optvallen_
&&
*
optvallen_
)
{
blob_t
identity
=
blob_t
((
unsigned
char
*
)
optval_
,
*
optvallen_
);
outpipes_t
::
iterator
it
=
outpipes
.
find
(
identity
);
if
(
it
==
outpipes
.
end
()
){
return
ENOTSOCK
;
}
*
((
fd_t
*
)
optval_
)
=
it
->
second
.
pipe
->
assoc_fd
;
*
optvallen_
=
sizeof
(
fd_t
);
return
0
;
}
break
;
default
:
break
;
}
errno
=
EINVAL
;
return
-
1
;
}
void
zmq
::
router_t
::
xpipe_terminated
(
pipe_t
*
pipe_
)
{
...
...
src/router.hpp
View file @
fe3e8c5c
...
...
@@ -47,6 +47,7 @@ namespace zmq
// Overrides of functions from socket_base_t.
void
xattach_pipe
(
zmq
::
pipe_t
*
pipe_
,
bool
subscribe_to_all_
);
int
xsetsockopt
(
int
option_
,
const
void
*
optval_
,
size_t
optvallen_
);
int
xgetsockopt
(
int
option_
,
const
void
*
optval_
,
size_t
*
optvallen_
);
int
xsend
(
zmq
::
msg_t
*
msg_
);
int
xrecv
(
zmq
::
msg_t
*
msg_
);
bool
xhas_in
();
...
...
@@ -54,7 +55,6 @@ namespace zmq
void
xread_activated
(
zmq
::
pipe_t
*
pipe_
);
void
xwrite_activated
(
zmq
::
pipe_t
*
pipe_
);
void
xpipe_terminated
(
zmq
::
pipe_t
*
pipe_
);
protected
:
// Rollback any message parts that were sent but not yet flushed.
...
...
src/session_base.cpp
View file @
fe3e8c5c
...
...
@@ -353,7 +353,8 @@ void zmq::session_base_t::process_attach (i_engine *engine_)
// Remember the local end of the pipe.
zmq_assert
(
!
pipe
);
pipe
=
pipes
[
0
];
// Store engine assoc_fd for lilnking pipe to fd
pipe
->
assoc_fd
=
engine_
->
get_assoc_fd
();
// Ask socket to plug into the remote end of the pipe.
send_bind
(
socket
,
pipes
[
1
]);
}
...
...
src/socket_base.cpp
View file @
fe3e8c5c
...
...
@@ -284,6 +284,11 @@ int zmq::socket_base_t::getsockopt (int option_, void *optval_,
errno
=
ETERM
;
return
-
1
;
}
// First, check whether specific socket type overloads the option.
int
rc
=
xgetsockopt
(
option_
,
optval_
,
optvallen_
);
if
(
rc
==
0
||
errno
!=
EINVAL
)
return
rc
;
if
(
option_
==
ZMQ_RCVMORE
)
{
if
(
*
optvallen_
<
sizeof
(
int
))
{
...
...
@@ -1037,6 +1042,11 @@ int zmq::socket_base_t::xsetsockopt (int, const void *, size_t)
errno
=
EINVAL
;
return
-
1
;
}
int
zmq
::
socket_base_t
::
xgetsockopt
(
int
,
const
void
*
,
size_t
*
)
{
errno
=
EINVAL
;
return
-
1
;
}
bool
zmq
::
socket_base_t
::
xhas_out
()
{
...
...
src/socket_base.hpp
View file @
fe3e8c5c
...
...
@@ -133,10 +133,13 @@ namespace zmq
// The default implementation assumes there are no specific socket
// options for the particular socket type. If not so, override this
// method.
// method
s
.
virtual
int
xsetsockopt
(
int
option_
,
const
void
*
optval_
,
size_t
optvallen_
);
virtual
int
xgetsockopt
(
int
option_
,
const
void
*
optval_
,
size_t
*
optvallen_
);
// The default implementation assumes that send is not supported.
virtual
bool
xhas_out
();
virtual
int
xsend
(
zmq
::
msg_t
*
msg_
);
...
...
src/stream_engine.hpp
View file @
fe3e8c5c
...
...
@@ -68,6 +68,8 @@ namespace zmq
void
in_event
();
void
out_event
();
// export s via i_engine so it is possible to link a pipe to fd
fd_t
get_assoc_fd
(){
return
s
;
};
private
:
// Unplug the engine from the session.
...
...
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