Skip to content

Commit

Permalink
Wrap value to 2**53 if 0
Browse files Browse the repository at this point in the history
  • Loading branch information
SunFulong authored Apr 13, 2024
1 parent c12ce18 commit f084051
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions autobahn/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ def __next__(self):


# 8 byte mask with 53 LSBs set (WAMP requires IDs from [1, 2**53]
_WAMP_ID_MASK = 2 ** 53 - 1
_WAMP_ID_MASK = struct.unpack("@Q", b"\x00\x1f\xff\xff\xff\xff\xff\xff")[0]


def rid():
Expand All @@ -298,7 +298,7 @@ def rid():
:returns: A random integer ID.
:rtype: int
"""
return (struct.unpack("@Q", os.urandom(8))[0] & _WAMP_ID_MASK) + 1
return struct.unpack("@Q", os.urandom(8))[0] & _WAMP_ID_MASK or 2 ** 53


# noinspection PyShadowingBuiltins
Expand Down

0 comments on commit f084051

Please sign in to comment.