Skip to content

Commit

Permalink
[CONJ-320] handling socketTimeout with solution to avoid synchronisat…
Browse files Browse the repository at this point in the history
…ion between write and read
  • Loading branch information
rusher committed Aug 1, 2016
1 parent 8122601 commit 8e067d0
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 0 deletions.
Expand Up @@ -1023,4 +1023,9 @@ public ReadPacketFetcher getPacketFetcher() {
public void changeSocketTcpNoDelay(boolean setTcpNoDelay) throws SocketException {
socket.setTcpNoDelay(setTcpNoDelay);
}

public void changeSocketSoTimeout(int setSoTimeout) throws SocketException {
socket.setSoTimeout(setSoTimeout);
}

}
Expand Up @@ -64,6 +64,11 @@ public AsyncMultiRead(ComStmtPrepare comStmtPrepare, int nbResult, int sendCmdCo

@Override
public AsyncMultiReadResult call() throws Exception {
// avoid synchronisation of calls for write and read
// since technically, getResult can be called before the write is send.
// Other solution would have been to synchronised write and read, but would have been less performant,
// just to have this timeout according to set value
if (protocol.getOptions().socketTimeout != 0) protocol.changeSocketSoTimeout(0);

if (readPrepareStmtResult) {
try {
Expand All @@ -85,6 +90,7 @@ public AsyncMultiReadResult call() throws Exception {
}
}
}
if (protocol.getOptions().socketTimeout != 0) protocol.changeSocketSoTimeout(protocol.getOptions().socketTimeout);

return asyncMultiReadResult;
}
Expand Down
Expand Up @@ -263,4 +263,5 @@ void prologProxy(ServerPrepareResult serverPrepareResult, ExecutionResult execut

void changeSocketTcpNoDelay(boolean setTcpNoDelay) throws SocketException;

void changeSocketSoTimeout(int setSoTimeout) throws SocketException;
}

0 comments on commit 8e067d0

Please sign in to comment.