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
5c093112
Commit
5c093112
authored
Feb 21, 2011
by
Martin Sustrik
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Computation of buffer size for PGM fixed.
Signed-off-by:
Martin Sustrik
<
sustrik@250bpm.com
>
parent
12486fec
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
32 additions
and
12 deletions
+32
-12
pgm_socket.cpp
src/pgm_socket.cpp
+29
-12
pgm_socket.hpp
src/pgm_socket.hpp
+3
-0
No files found.
src/pgm_socket.cpp
View file @
5c093112
...
...
@@ -151,8 +151,9 @@ int zmq::pgm_socket_t::init (bool udp_encapsulation_, const char *network_)
// All options are of data type int
const
int
encapsulation_port
=
port_number
;
if
(
!
pgm_setsockopt
(
sock
,
IPPROTO_PGM
,
PGM_UDP_ENCAP_UCAST_PORT
,
&
encapsulation_port
,
sizeof
(
encapsulation_port
))
||
!
pgm_setsockopt
(
sock
,
IPPROTO_PGM
,
PGM_UDP_ENCAP_MCAST_PORT
,
&
encapsulation_port
,
sizeof
(
encapsulation_port
)))
goto
err_abort
;
if
(
!
pgm_setsockopt
(
sock
,
IPPROTO_PGM
,
PGM_UDP_ENCAP_MCAST_PORT
,
&
encapsulation_port
,
sizeof
(
encapsulation_port
)))
goto
err_abort
;
}
...
...
@@ -200,11 +201,7 @@ int zmq::pgm_socket_t::init (bool udp_encapsulation_, const char *network_)
if
(
receiver
)
{
const
int
recv_only
=
1
,
rxw_max_tpdu
=
(
int
)
pgm_max_tpdu
,
rxw_sqns
=
(
options
.
recovery_ivl_msec
>=
0
?
options
.
recovery_ivl_msec
*
options
.
rate
/
(
1000
*
rxw_max_tpdu
)
:
options
.
recovery_ivl
*
options
.
rate
/
rxw_max_tpdu
),
rxw_sqns
=
compute_sqns
(
rxw_max_tpdu
),
peer_expiry
=
pgm_secs
(
300
),
spmr_expiry
=
pgm_msecs
(
25
),
nak_bo_ivl
=
pgm_msecs
(
50
),
...
...
@@ -235,11 +232,7 @@ int zmq::pgm_socket_t::init (bool udp_encapsulation_, const char *network_)
}
else
{
const
int
send_only
=
1
,
txw_max_tpdu
=
(
int
)
pgm_max_tpdu
,
txw_sqns
=
(
options
.
recovery_ivl_msec
>=
0
?
options
.
recovery_ivl_msec
*
options
.
rate
/
(
1000
*
txw_max_tpdu
)
:
options
.
recovery_ivl
*
options
.
rate
/
txw_max_tpdu
),
txw_sqns
=
compute_sqns
(
txw_max_tpdu
),
ambient_spm
=
pgm_secs
(
30
),
heartbeat_spm
[]
=
{
pgm_msecs
(
100
),
pgm_msecs
(
100
),
...
...
@@ -680,5 +673,29 @@ void zmq::pgm_socket_t::process_upstream ()
errno
=
EAGAIN
;
}
int
zmq
::
pgm_socket_t
::
compute_sqns
(
int
tpdu_
)
{
// Convert rate into B/ms.
uint64_t
rate
=
((
uint64_t
)
options
.
rate
)
/
8
;
// Get recovery interval in milliseconds.
uint64_t
interval
=
options
.
recovery_ivl_msec
>=
0
?
options
.
recovery_ivl_msec
:
options
.
recovery_ivl
*
1000
;
// Compute the size of the buffer in bytes.
uint64_t
size
=
interval
*
rate
;
// Translate the size into number of packets.
uint64_t
sqns
=
size
/
tpdu_
;
zmq_assert
(
sqns
>=
0
);
// Buffer should be able to contain at least one packet.
if
(
sqns
==
0
)
sqns
=
1
;
return
sqns
;
}
#endif
src/pgm_socket.hpp
View file @
5c093112
...
...
@@ -80,6 +80,9 @@ namespace zmq
void
process_upstream
();
private
:
// Compute size of the buffer based on rate and recovery interval.
int
compute_sqns
(
int
tpdu_
);
// OpenPGM transport.
pgm_sock_t
*
sock
;
...
...
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