Commit 3ffb861
authored
fix(vpn): retain stopJob and reset isStopping synchronously (#44)
Plan 014. Previously stopVpn() used a local CoroutineScope whose Job was
unreachable from the service fields; a low-memory process pause between
state=DISCONNECTED and stopSelf() could GC the cleanup coroutine mid-
teardown, leaving Go core / TUN fd / WakeLock / NetworkCallback live.
isStopping also stayed true until onDestroy(), blocking a fresh
connect() during that gap. Fix: retain stopJob on the service so
onDestroy() can join it, reset isStopping in a finally block inside
the launch lambda so it goes false when teardown actually finishes,
and add a DISCONNECTING guard to VpnManager.connect() so the UI can't
race the disconnect dispatch.1 parent 3c38d4f commit 3ffb861
2 files changed
Lines changed: 17 additions & 7 deletions
Lines changed: 14 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
65 | 65 | | |
66 | 66 | | |
67 | 67 | | |
| 68 | + | |
68 | 69 | | |
69 | 70 | | |
70 | 71 | | |
| |||
465 | 466 | | |
466 | 467 | | |
467 | 468 | | |
468 | | - | |
469 | | - | |
470 | | - | |
471 | | - | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
472 | 473 | | |
473 | 474 | | |
474 | 475 | | |
| |||
550 | 551 | | |
551 | 552 | | |
552 | 553 | | |
| 554 | + | |
| 555 | + | |
| 556 | + | |
553 | 557 | | |
554 | | - | |
555 | | - | |
556 | 558 | | |
557 | 559 | | |
558 | 560 | | |
| |||
573 | 575 | | |
574 | 576 | | |
575 | 577 | | |
| 578 | + | |
| 579 | + | |
| 580 | + | |
| 581 | + | |
| 582 | + | |
| 583 | + | |
576 | 584 | | |
577 | 585 | | |
578 | 586 | | |
| |||
Lines changed: 3 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
314 | 314 | | |
315 | 315 | | |
316 | 316 | | |
317 | | - | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
318 | 320 | | |
319 | 321 | | |
320 | 322 | | |
| |||
0 commit comments