int getNextRid()

Source

int getNextRid() {
  do {
    if (lastRid < 0x7FFFFFFF) {
      ++lastRid;
    } else {
      lastRid = 1;
    }
  } while (_requests.containsKey(lastRid));
  return lastRid;
}