mirror of
https://github.com/yggdrasil-network/yggdrasil-android.git
synced 2025-04-27 21:55:08 +03:00
Fixed the writer thread. (#42)
* Fixed the writer thread. * Version increment. * Added todo and info.
This commit is contained in:
parent
05de180066
commit
ce50b01781
2 changed files with 13 additions and 2 deletions
|
@ -11,8 +11,8 @@ android {
|
||||||
applicationId "eu.neilalexander.yggdrasil"
|
applicationId "eu.neilalexander.yggdrasil"
|
||||||
minSdkVersion 21
|
minSdkVersion 21
|
||||||
targetSdkVersion 29
|
targetSdkVersion 29
|
||||||
versionCode 12
|
versionCode 13
|
||||||
versionName "0.1-012"
|
versionName "0.1-013"
|
||||||
|
|
||||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||||
}
|
}
|
||||||
|
|
|
@ -282,9 +282,11 @@ open class PacketTunnelProvider: VpnService() {
|
||||||
val writerStream = writerStream
|
val writerStream = writerStream
|
||||||
val writerThread = writerThread
|
val writerThread = writerThread
|
||||||
if (writerThread == null || writerStream == null) {
|
if (writerThread == null || writerStream == null) {
|
||||||
|
Log.i(TAG, "Write thread or stream is null")
|
||||||
break@writes
|
break@writes
|
||||||
}
|
}
|
||||||
if (Thread.currentThread().isInterrupted || !writerStream.fd.valid()) {
|
if (Thread.currentThread().isInterrupted || !writerStream.fd.valid()) {
|
||||||
|
Log.i(TAG, "Write thread interrupted or file descriptor is invalid")
|
||||||
break@writes
|
break@writes
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
|
@ -293,6 +295,12 @@ open class PacketTunnelProvider: VpnService() {
|
||||||
writerStream.write(buf, 0, len.toInt())
|
writerStream.write(buf, 0, len.toInt())
|
||||||
}
|
}
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
|
Log.i(TAG, "Error in write: $e")
|
||||||
|
if (e.toString().contains("ENOBUFS")) {
|
||||||
|
//TODO Check this by some error code
|
||||||
|
//More info about this: https://github.com/AdguardTeam/AdguardForAndroid/issues/724
|
||||||
|
continue
|
||||||
|
}
|
||||||
break@writes
|
break@writes
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -308,15 +316,18 @@ open class PacketTunnelProvider: VpnService() {
|
||||||
val readerStream = readerStream
|
val readerStream = readerStream
|
||||||
val readerThread = readerThread
|
val readerThread = readerThread
|
||||||
if (readerThread == null || readerStream == null) {
|
if (readerThread == null || readerStream == null) {
|
||||||
|
Log.i(TAG, "Read thread or stream is null")
|
||||||
break@reads
|
break@reads
|
||||||
}
|
}
|
||||||
if (Thread.currentThread().isInterrupted ||!readerStream.fd.valid()) {
|
if (Thread.currentThread().isInterrupted ||!readerStream.fd.valid()) {
|
||||||
|
Log.i(TAG, "Read thread interrupted or file descriptor is invalid")
|
||||||
break@reads
|
break@reads
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
val n = readerStream.read(b)
|
val n = readerStream.read(b)
|
||||||
yggdrasil.sendBuffer(b, n.toLong())
|
yggdrasil.sendBuffer(b, n.toLong())
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
|
Log.i(TAG, "Error in sendBuffer: $e")
|
||||||
break@reads
|
break@reads
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue