[beep4j-user] seqno incrementing past 4 gigabytes
Status: Alpha
Brought to you by:
rasss
From: Thomson, M. <Mar...@an...> - 2008-05-20 04:58:23
|
There are two places in beep4j where the rollover of the seqno field isn't correctly handled. Of course, given that you need to send 4 gigabytes of data over a single channel to reach this point, it's probably a little theoretical... First is in SlidingWindow.remaining(), which currently uses: return getEnd() - position; This doesn't work if the end has just rolled around to zero, but the positioning hasn't. This should look like: if (position < start) { return (int) ((start + windowSize) % modulo - position); } else { return (int) (start - position + windowSize); } The other place is in the incrementing of the seqno in DefaultChannelController. This doesn't roll over at all, so when 4Gb comes around, things will probably break. I've added a method getNextSeqno that does the incrementing and rollover... private long getNextSeqno(int messageSize) { long nextSeqno = this.seqno; this.seqno = (this.seqno + messageSize) % (1L << 32); return nextSeqno; } Ta, Martin ------------------------------------------------------------------------------------------------ This message is for the designated recipient only and may contain privileged, proprietary, or otherwise private information. If you have received it in error, please notify the sender immediately and delete the original. Any unauthorized use of this email is prohibited. ------------------------------------------------------------------------------------------------ [mf2] |