mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
CVS: a bug with timeout for any command
This commit is contained in:
+7
@@ -19,6 +19,13 @@ public class CvsExecutionEnvironment {
|
||||
public boolean isAborted() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean isAlive() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public void resetAlive() {
|
||||
}
|
||||
};
|
||||
|
||||
private final CvsMessagesListener myListener;
|
||||
|
||||
+11
@@ -10,10 +10,20 @@ public class CvsListenerWithProgress extends CvsMessagesAdapter implements ICvsC
|
||||
private ProgressIndicator myProgressIndicator;
|
||||
private String myLastError;
|
||||
private boolean myIndirectCancel;
|
||||
private boolean myPing;
|
||||
|
||||
public CvsListenerWithProgress(ProgressIndicator progressIndicator) {
|
||||
myProgressIndicator = progressIndicator;
|
||||
myIndirectCancel = false;
|
||||
myPing = false;
|
||||
}
|
||||
|
||||
public boolean isAlive() {
|
||||
return myPing;
|
||||
}
|
||||
|
||||
public void resetAlive() {
|
||||
myPing = false;
|
||||
}
|
||||
|
||||
public static CvsListenerWithProgress createOnProgress() {
|
||||
@@ -38,6 +48,7 @@ public class CvsListenerWithProgress extends CvsMessagesAdapter implements ICvsC
|
||||
}
|
||||
|
||||
public boolean isAborted() {
|
||||
myPing = true;
|
||||
if (myLastError != null) throw new CvsProcessException(myLastError);
|
||||
if (myIndirectCancel) return true;
|
||||
final ProgressIndicator progressIndicator = getProgressIndicator();
|
||||
|
||||
+11
@@ -6,7 +6,18 @@ import org.netbeans.lib.cvsclient.ICvsCommandStopper;
|
||||
* author: lesya
|
||||
*/
|
||||
public class CvsCommandStopper implements ICvsCommandStopper{
|
||||
private volatile boolean myPing;
|
||||
|
||||
public boolean isAborted() {
|
||||
myPing = true;
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean isAlive() {
|
||||
return myPing;
|
||||
}
|
||||
|
||||
public void resetAlive() {
|
||||
myPing = false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,4 +18,6 @@ package org.netbeans.lib.cvsclient;
|
||||
public interface ICvsCommandStopper {
|
||||
|
||||
boolean isAborted();
|
||||
boolean isAlive();
|
||||
void resetAlive();
|
||||
}
|
||||
|
||||
@@ -174,7 +174,9 @@ public final class RequestProcessor implements IRequestProcessor {
|
||||
final Future<?> future = Executors.newSingleThreadExecutor().submit(new Runnable() {
|
||||
public void run() {
|
||||
try {
|
||||
checkCanceled();
|
||||
sendRequests(requests, connectionStreams, communicationProgressHandler);
|
||||
checkCanceled();
|
||||
|
||||
sendRequest(requests.getResponseExpectingRequest(), connectionStreams);
|
||||
connectionStreams.flushForReading();
|
||||
@@ -193,12 +195,19 @@ public final class RequestProcessor implements IRequestProcessor {
|
||||
}
|
||||
});
|
||||
|
||||
semaphore.waitFor((long) (1.2 * myTimeout));
|
||||
// todo: think more
|
||||
final long tOut = (myTimeout < 20000) ? 20000 : myTimeout;
|
||||
while (true) {
|
||||
semaphore.waitFor(tOut);
|
||||
if (future.isDone() || future.isCancelled()) break;
|
||||
if (! commandStopper.isAlive()) break;
|
||||
commandStopper.resetAlive();
|
||||
}
|
||||
|
||||
if (! ioExceptionRef.isNull()) throw new IOCommandException(ioExceptionRef.get());
|
||||
if (! commandExceptionRef.isNull()) throw commandExceptionRef.get();
|
||||
|
||||
if ((! future.isDone() && (! future.isCancelled()))) {
|
||||
if ((! future.isDone() && (! future.isCancelled()) && (! commandStopper.isAlive()))) {
|
||||
future.cancel(true);
|
||||
throw new CommandException(new CommandAbortedException(), "Command execution timed out");
|
||||
}
|
||||
@@ -275,6 +284,7 @@ public final class RequestProcessor implements IRequestProcessor {
|
||||
final StringBuffer responseBuffer = new StringBuffer(32);
|
||||
for (; ;) {
|
||||
final String responseString = readResponse(connectionStreams.getLoggedReader(), responseBuffer);
|
||||
checkCanceled();
|
||||
if (responseString.length() == 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user