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
73b765e4
Commit
73b765e4
authored
Dec 13, 2009
by
Martin Sustrik
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
PGM transport fixed
parent
d5670f34
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
29 additions
and
17 deletions
+29
-17
encoder.hpp
src/encoder.hpp
+16
-10
pgm_receiver.cpp
src/pgm_receiver.cpp
+3
-2
pgm_sender.cpp
src/pgm_sender.cpp
+4
-2
pgm_socket.cpp
src/pgm_socket.cpp
+0
-0
pgm_socket.hpp
src/pgm_socket.hpp
+3
-2
zmq_engine.cpp
src/zmq_engine.cpp
+3
-1
No files found.
src/encoder.hpp
View file @
73b765e4
...
...
@@ -50,12 +50,18 @@ namespace zmq
free
(
buf
);
}
// The function returns a batch of binary data. If offset is not NULL,
// it is filled by offset of the first message in the batch. If there's
// no beginning of a message in the batch, offset is set to -1.
inline
void
get_buffer
(
unsigned
char
**
data_
,
size_t
*
size_
,
// The function returns a batch of binary data. The data
// are filled to a supplied buffer. If no buffer is supplied (data_
// points to NULL) decoder object will provide buffer of its own.
// If offset is not NULL, it is filled by offset of the first message
// in the batch.If there's no beginning of a message in the batch,
// offset is set to -1.
inline
void
get_data
(
unsigned
char
**
data_
,
size_t
*
size_
,
int
*
offset_
=
NULL
)
{
unsigned
char
*
buffer
=
!*
data_
?
buf
:
*
data_
;
size_t
buffersize
=
!*
data_
?
bufsize
:
*
size_
;
size_t
pos
=
0
;
if
(
offset_
)
*
offset_
=
-
1
;
...
...
@@ -67,7 +73,7 @@ namespace zmq
// in the buffer.
if
(
!
to_write
)
{
if
(
!
(
static_cast
<
T
*>
(
this
)
->*
next
)
())
{
*
data_
=
buf
;
*
data_
=
buf
fer
;
*
size_
=
pos
;
return
;
}
...
...
@@ -91,7 +97,7 @@ namespace zmq
// As a consequence, large messages being sent won't block
// other engines running in the same I/O thread for excessive
// amounts of time.
if
(
!
pos
&&
to_write
>=
buf
size
)
{
if
(
!
pos
&&
!*
data_
&&
to_write
>=
buffer
size
)
{
*
data_
=
write_pos
;
*
size_
=
to_write
;
write_pos
=
NULL
;
...
...
@@ -100,13 +106,13 @@ namespace zmq
}
// Copy data to the buffer. If the buffer is full, return.
size_t
to_copy
=
std
::
min
(
to_write
,
bufsize
-
pos
);
memcpy
(
buf
+
pos
,
write_pos
,
to_copy
);
size_t
to_copy
=
std
::
min
(
to_write
,
buf
fer
size
-
pos
);
memcpy
(
buf
fer
+
pos
,
write_pos
,
to_copy
);
pos
+=
to_copy
;
write_pos
+=
to_copy
;
to_write
-=
to_copy
;
if
(
pos
==
bufsize
)
{
*
data_
=
buf
;
if
(
pos
==
buf
fer
size
)
{
*
data_
=
buf
fer
;
*
size_
=
pos
;
return
;
}
...
...
src/pgm_receiver.cpp
View file @
73b765e4
...
...
@@ -194,7 +194,7 @@ void zmq::pgm_receiver_t::in_event ()
it
->
second
.
joined
=
true
;
// Create and connect decoder for joined peer.
it
->
second
.
decoder
=
new
zmq_decoder_t
;
it
->
second
.
decoder
=
new
zmq_decoder_t
(
0
)
;
it
->
second
.
decoder
->
set_inout
(
inout
);
#ifdef ZMQ_HAVE_OPENPGM1
...
...
@@ -209,7 +209,8 @@ void zmq::pgm_receiver_t::in_event ()
if
(
nbytes
>
0
)
{
// Push all the data to the decoder.
it
->
second
.
decoder
->
write
(
raw_data
,
nbytes
);
// TODO: process_buffer may not process entire buffer!
it
->
second
.
decoder
->
process_buffer
(
raw_data
,
nbytes
);
}
}
while
(
nbytes
>
0
);
...
...
src/pgm_sender.cpp
View file @
73b765e4
...
...
@@ -49,6 +49,7 @@
zmq
::
pgm_sender_t
::
pgm_sender_t
(
io_thread_t
*
parent_
,
const
options_t
&
options_
,
const
char
*
session_name_
)
:
io_object_t
(
parent_
),
encoder
(
0
),
pgm_socket
(
false
,
options_
),
options
(
options_
),
session_name
(
session_name_
),
...
...
@@ -162,8 +163,9 @@ void zmq::pgm_sender_t::out_event ()
// First two bytes /sizeof (uint16_t)/ are used to store message
// offset in following steps.
write_size
=
encoder
.
read
(
out_buffer
+
sizeof
(
uint16_t
),
out_buffer_size
-
sizeof
(
uint16_t
),
&
first_message_offset
);
unsigned
char
*
bf
=
out_buffer
+
sizeof
(
uint16_t
);
write_size
=
out_buffer_size
-
sizeof
(
uint16_t
);
encoder
.
get_data
(
&
bf
,
&
write_size
,
&
first_message_offset
);
write_pos
=
0
;
// If there are no data to write stop polling for output.
...
...
src/pgm_socket.cpp
View file @
73b765e4
This diff is collapsed.
Click to expand it.
src/pgm_socket.hpp
View file @
73b765e4
...
...
@@ -62,7 +62,8 @@ namespace zmq
// Get sender and receiver fds and store it to user allocated
// memory. Receive fd is used to process NAKs from peers.
int
get_sender_fds
(
int
*
send_fd_
,
int
*
receive_fd_
,
int
*
rdata_notify_fd_
=
NULL
);
int
get_sender_fds
(
int
*
send_fd_
,
int
*
receive_fd_
,
int
*
rdata_notify_fd_
=
NULL
);
// Send data as one APDU, transmit window owned memory.
size_t
send
(
unsigned
char
*
data_
,
size_t
data_len_
);
...
...
@@ -83,7 +84,7 @@ namespace zmq
protected
:
// OpenPGM transport
pgm_transport_t
*
g_
transport
;
pgm_transport_t
*
transport
;
private
:
...
...
src/zmq_engine.cpp
View file @
73b765e4
...
...
@@ -106,7 +106,9 @@ void zmq::zmq_engine_t::out_event ()
{
// If write buffer is empty, try to read new data from the encoder.
if
(
!
outsize
)
{
encoder
.
get_buffer
(
&
outpos
,
&
outsize
);
outpos
=
NULL
;
encoder
.
get_data
(
&
outpos
,
&
outsize
);
// If there is no data to send, stop polling for output.
if
(
outsize
==
0
)
{
...
...
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