less noisy logcat. catch illegal state exception as result of race condition
This commit is contained in:
parent
b2e1f9b3d8
commit
4168bc4666
|
@ -191,7 +191,6 @@ public class WebRTCDataChannelTransport implements Transport {
|
||||||
new OnMessageObserver() {
|
new OnMessageObserver() {
|
||||||
@Override
|
@Override
|
||||||
public void onMessage(final DataChannel.Buffer buffer) {
|
public void onMessage(final DataChannel.Buffer buffer) {
|
||||||
Log.d(Config.LOGTAG, "onMessage() (the other one)");
|
|
||||||
try {
|
try {
|
||||||
WebRTCDataChannelTransport.this.writableByteChannel.write(buffer.data);
|
WebRTCDataChannelTransport.this.writableByteChannel.write(buffer.data);
|
||||||
} catch (final IOException e) {
|
} catch (final IOException e) {
|
||||||
|
@ -584,8 +583,7 @@ public class WebRTCDataChannelTransport implements Transport {
|
||||||
Log.d(Config.LOGTAG, "DataChannelWriter reached EOF");
|
Log.d(Config.LOGTAG, "DataChannelWriter reached EOF");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
dataChannel.send(
|
send(ByteBuffer.wrap(buffer, 0, count));
|
||||||
new DataChannel.Buffer(ByteBuffer.wrap(buffer, 0, count), true));
|
|
||||||
}
|
}
|
||||||
} catch (final InterruptedException | InterruptedIOException e) {
|
} catch (final InterruptedException | InterruptedIOException e) {
|
||||||
if (isSending.get()) {
|
if (isSending.get()) {
|
||||||
|
@ -598,6 +596,16 @@ public class WebRTCDataChannelTransport implements Transport {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void send(final ByteBuffer byteBuffer) throws IOException {
|
||||||
|
try {
|
||||||
|
dataChannel.send(new DataChannel.Buffer(byteBuffer, true));
|
||||||
|
} catch (final IllegalStateException e) {
|
||||||
|
// dataChannel can be 'disposed' if we waited too long between `isSending` check and
|
||||||
|
// actually trying to send
|
||||||
|
throw new IOException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void close() {
|
public void close() {
|
||||||
this.isSending.set(false);
|
this.isSending.set(false);
|
||||||
terminate(this.dataChannel);
|
terminate(this.dataChannel);
|
||||||
|
|
Loading…
Reference in a new issue