Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
O
Openfire
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
Openfire
Commits
c1b3f28f
Commit
c1b3f28f
authored
Jan 06, 2016
by
Guus der Kinderen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
OF-1028: Rollover should occur at 2^32
This commit fixes an overflow issue.
parent
c3ed050a
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
3 deletions
+4
-3
StreamManager.java
...jivesoftware/openfire/streammanagement/StreamManager.java
+4
-3
No files found.
src/java/org/jivesoftware/openfire/streammanagement/StreamManager.java
View file @
c1b3f28f
package
org
.
jivesoftware
.
openfire
.
streammanagement
;
package
org
.
jivesoftware
.
openfire
.
streammanagement
;
import
java.math.BigInteger
;
import
java.net.UnknownHostException
;
import
java.net.UnknownHostException
;
import
java.util.*
;
import
java.util.*
;
...
@@ -74,7 +75,7 @@ public class StreamManager {
...
@@ -74,7 +75,7 @@ public class StreamManager {
*/
*/
private
long
clientProcessedStanzas
=
0
;
private
long
clientProcessedStanzas
=
0
;
static
private
long
mask
=
0xFFFFFFFF
;
/* 2**32 - 1; this is used to emulate rollover */
static
private
long
mask
=
new
BigInteger
(
"2"
).
pow
(
32
).
longValue
()
-
1
;
// This is used to emulate rollover.
/**
/**
* Collection of stanzas/packets sent to client that haven't been acknowledged.
* Collection of stanzas/packets sent to client that haven't been acknowledged.
...
@@ -205,8 +206,8 @@ public class StreamManager {
...
@@ -205,8 +206,8 @@ public class StreamManager {
}
}
// Ensure that unacknowledged stanzas are purged after the client rolled over 'h' which occurs at h= (2^32)-1
// Ensure that unacknowledged stanzas are purged after the client rolled over 'h' which occurs at h= (2^32)-1
final
boolean
clientHadRollOver
=
h
<
10000
&&
unacknowledgedServerStanzas
.
getLast
().
x
>
mask
-
10000
;
final
boolean
clientHadRollOver
=
h
<
10000
&&
!
unacknowledgedServerStanzas
.
isEmpty
()
&&
unacknowledgedServerStanzas
.
getLast
().
x
>
mask
-
10000
;
if
(
clientHadRollOver
)
if
(
clientHadRollOver
)
{
{
Log
.
info
(
"Client rolled over 'h'. Purging high-numbered unacklowledged stanzas."
);
Log
.
info
(
"Client rolled over 'h'. Purging high-numbered unacklowledged stanzas."
);
while
(
!
unacknowledgedServerStanzas
.
isEmpty
()
&&
unacknowledgedServerStanzas
.
getLast
().
x
>
mask
-
10000
)
while
(
!
unacknowledgedServerStanzas
.
isEmpty
()
&&
unacknowledgedServerStanzas
.
getLast
().
x
>
mask
-
10000
)
...
...
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