-
Notifications
You must be signed in to change notification settings - Fork 487
Description
MuxPool request method
https://github.com/jpos/jPOS/blob/master/jpos/src/main/java/org/jpos/q2/iso/MUXPool.java#L72-L82
If timeout is 0. (I don't want to set a mux timeout, let it take as much time as it wants).
long maxWait = System.currentTimeMillis() + timeout;
followed by
timeout = maxWait - System.currentTimeMillis();
timeout will return a negative timeout (or on fast systems the System.currentTimeMillis() may not change due to OS timer precision and result in timeout of 0). Currently a null is being returned (see snippet below)
if (mux != null) {
timeout = maxWait - System.currentTimeMillis();// maxwait is the previous call to System.currentmilli
if (timeout >= 0)
return mux.request (m, timeout);
}
return null;
My thoughts on this are:
If a timeout passed to the muxpool.request is 0, means we don't care how much time is taken in the muxpool and the 0 timeout must be passed to the underlying mux.
Additionally, when timeout of 0 is passed to the muxpool the call :
MUX mux = getMUX(m,maxWait);
The snippet below will result in the mux selection being called only once.
} while (System.currentTimeMillis() < maxWait); // maxwait is the system.currentmill and while loop will terminate after looping once as System.currentTimeMillis() will always be greater than maxWait.
So, a decision needs to be made on supporting a timeout of 0 and how long do we want to loop in getting the mux if none are available when timeout is 0.