mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-12 18:59:06 +01:00
Ensure each reliability layer is started and stopped.
This commit is contained in:
@@ -49,6 +49,7 @@ class ModemImpl implements Modem, WriteHandler, SerialPortEventListener {
|
||||
connected = new AtomicBoolean(false);
|
||||
line = new byte[MAX_LINE_LENGTH];
|
||||
reliabilityLayer = new ReliabilityLayer(this);
|
||||
reliabilityLayer.start();
|
||||
}
|
||||
|
||||
public void start() throws IOException {
|
||||
@@ -69,7 +70,6 @@ class ModemImpl implements Modem, WriteHandler, SerialPortEventListener {
|
||||
}
|
||||
if(!foundBaudRate)
|
||||
throw new IOException("Could not find a suitable baud rate");
|
||||
reliabilityLayer.start();
|
||||
port.addEventListener(this);
|
||||
port.purgePort(PURGE_RXCLEAR | PURGE_TXCLEAR);
|
||||
port.writeBytes("ATZ\r\n".getBytes("US-ASCII")); // Reset
|
||||
@@ -150,6 +150,7 @@ class ModemImpl implements Modem, WriteHandler, SerialPortEventListener {
|
||||
}
|
||||
reliabilityLayer.stop();
|
||||
reliabilityLayer = new ReliabilityLayer(this);
|
||||
reliabilityLayer.start();
|
||||
connected.set(false);
|
||||
offHook.release();
|
||||
}
|
||||
|
||||
@@ -70,6 +70,7 @@ class ReliabilityLayer implements ReadHandler, WriteHandler {
|
||||
}
|
||||
|
||||
void stop() {
|
||||
if(!running) throw new IllegalStateException();
|
||||
running = false;
|
||||
receiver.invalidate();
|
||||
writes.add(new byte[0]); // Poison pill
|
||||
|
||||
Reference in New Issue
Block a user