Make sure, the external browser lock gets released
This commit is contained in:
parent
07e0eb005b
commit
9ceec96195
|
@ -17,6 +17,7 @@ import org.slf4j.LoggerFactory;
|
||||||
import ctbrec.OS;
|
import ctbrec.OS;
|
||||||
import ctbrec.io.StreamRedirectThread;
|
import ctbrec.io.StreamRedirectThread;
|
||||||
|
|
||||||
|
// TODO implement proxy support
|
||||||
public class ExternalBrowser implements AutoCloseable {
|
public class ExternalBrowser implements AutoCloseable {
|
||||||
private static final transient Logger LOG = LoggerFactory.getLogger(ExternalBrowser.class);
|
private static final transient Logger LOG = LoggerFactory.getLogger(ExternalBrowser.class);
|
||||||
private static final ExternalBrowser INSTANCE = new ExternalBrowser();
|
private static final ExternalBrowser INSTANCE = new ExternalBrowser();
|
||||||
|
@ -35,7 +36,9 @@ public class ExternalBrowser implements AutoCloseable {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void run(String jsonConfig, Consumer<String> messageListener) throws InterruptedException, IOException {
|
public void run(String jsonConfig, Consumer<String> messageListener) throws InterruptedException, IOException {
|
||||||
|
LOG.debug("Running browser with config {}", jsonConfig);
|
||||||
lock.lock();
|
lock.lock();
|
||||||
|
try {
|
||||||
stopped = false;
|
stopped = false;
|
||||||
this.messageListener = messageListener;
|
this.messageListener = messageListener;
|
||||||
|
|
||||||
|
@ -56,9 +59,12 @@ public class ExternalBrowser implements AutoCloseable {
|
||||||
int exitValue = p.exitValue();
|
int exitValue = p.exitValue();
|
||||||
p = null;
|
p = null;
|
||||||
LOG.debug("Browser Process terminated with {}", exitValue);
|
LOG.debug("Browser Process terminated with {}", exitValue);
|
||||||
|
} finally {
|
||||||
|
lock.unlock();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void connectToRemoteControlSocket() {
|
private void connectToRemoteControlSocket() throws IOException {
|
||||||
for (int i = 0; i < 20; i++) {
|
for (int i = 0; i < 20; i++) {
|
||||||
try {
|
try {
|
||||||
socket = new Socket("localhost", 3202);
|
socket = new Socket("localhost", 3202);
|
||||||
|
@ -70,7 +76,7 @@ public class ExternalBrowser implements AutoCloseable {
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
if(i == 19) {
|
if(i == 19) {
|
||||||
LOG.error("Connection to remote control socket failed", e);
|
LOG.error("Connection to remote control socket failed", e);
|
||||||
return;
|
throw e;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -134,8 +140,4 @@ public class ExternalBrowser implements AutoCloseable {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void release() {
|
|
||||||
lock.unlock();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,7 +43,6 @@ public class BongaCamsElectronLoginDialog {
|
||||||
throw new IOException("Couldn't wait for login dialog", e);
|
throw new IOException("Couldn't wait for login dialog", e);
|
||||||
} finally {
|
} finally {
|
||||||
browser.close();
|
browser.close();
|
||||||
browser.release();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -43,7 +43,6 @@ public class Cam4ElectronLoginDialog {
|
||||||
throw new IOException("Couldn't wait for login dialog", e);
|
throw new IOException("Couldn't wait for login dialog", e);
|
||||||
} finally {
|
} finally {
|
||||||
browser.close();
|
browser.close();
|
||||||
browser.release();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -41,7 +41,6 @@ public class LiveJasminElectronLoginDialog {
|
||||||
LOG.debug("Error while starting the browser or communication to it", e);
|
LOG.debug("Error while starting the browser or communication to it", e);
|
||||||
} finally {
|
} finally {
|
||||||
browser.close();
|
browser.close();
|
||||||
browser.release();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue