@@ -282,9 +282,11 @@ open class PacketTunnelProvider: VpnService() {
282282 val writerStream = writerStream
283283 val writerThread = writerThread
284284 if (writerThread == null || writerStream == null ) {
285+ Log .i(TAG , " Write thread or stream is null" )
285286 break @writes
286287 }
287288 if (Thread .currentThread().isInterrupted || ! writerStream.fd.valid()) {
289+ Log .i(TAG , " Write thread interrupted or file descriptor is invalid" )
288290 break @writes
289291 }
290292 try {
@@ -293,6 +295,12 @@ open class PacketTunnelProvider: VpnService() {
293295 writerStream.write(buf, 0 , len.toInt())
294296 }
295297 } catch (e: Exception ) {
298+ Log .i(TAG , " Error in write: $e " )
299+ if (e.toString().contains(" ENOBUFS" )) {
300+ // TODO Check this by some error code
301+ // More info about this: https://github.com/AdguardTeam/AdguardForAndroid/issues/724
302+ continue
303+ }
296304 break @writes
297305 }
298306 }
@@ -308,15 +316,18 @@ open class PacketTunnelProvider: VpnService() {
308316 val readerStream = readerStream
309317 val readerThread = readerThread
310318 if (readerThread == null || readerStream == null ) {
319+ Log .i(TAG , " Read thread or stream is null" )
311320 break @reads
312321 }
313322 if (Thread .currentThread().isInterrupted ||! readerStream.fd.valid()) {
323+ Log .i(TAG , " Read thread interrupted or file descriptor is invalid" )
314324 break @reads
315325 }
316326 try {
317327 val n = readerStream.read(b)
318328 yggdrasil.sendBuffer(b, n.toLong())
319329 } catch (e: Exception ) {
330+ Log .i(TAG , " Error in sendBuffer: $e " )
320331 break @reads
321332 }
322333 }
0 commit comments