[#2706] Allow pid up to 4194304

Motivation:

The PID_MAX_LIMIT on 64bit linux systems is 4194304 and on osx it is 99998. At the moment we use 65535 as an upper-limit which is too small.

Modifications:

Use 4194304 as max possible value

Result:

No more false-positives when try to detect current pid.
This commit is contained in:
Norman Maurer 2014-07-28 10:12:49 -07:00
parent 88c8a4f393
commit d82cc29d0c

View File

@ -49,8 +49,10 @@ final class DefaultChannelId implements ChannelId {
private static final Pattern MACHINE_ID_PATTERN = Pattern.compile("^(?:[0-9a-fA-F][:-]?){6,8}$");
private static final int MACHINE_ID_LEN = 8;
private static final byte[] MACHINE_ID;
private static final int PROCESS_ID_LEN = 2;
private static final int MAX_PROCESS_ID = 65535;
private static final int PROCESS_ID_LEN = 4;
// Maximal value for 64bit systems is 2^22. See man 5 proc.
// See https://github.com/netty/netty/issues/2706
private static final int MAX_PROCESS_ID = 4194304;
private static final int PROCESS_ID;
private static final int SEQUENCE_LEN = 4;
private static final int TIMESTAMP_LEN = 8;
@ -362,7 +364,7 @@ final class DefaultChannelId implements ChannelId {
i += MACHINE_ID_LEN;
// processId
i = writeShort(i, PROCESS_ID);
i = writeInt(i, PROCESS_ID);
// sequence
i = writeInt(i, nextSequence.getAndIncrement());
@ -378,12 +380,6 @@ final class DefaultChannelId implements ChannelId {
assert i == data.length;
}
private int writeShort(int i, int value) {
data[i ++] = (byte) (value >>> 8);
data[i ++] = (byte) value;
return i;
}
private int writeInt(int i, int value) {
data[i ++] = (byte) (value >>> 24);
data[i ++] = (byte) (value >>> 16);