Skip to content

Commit

Permalink
fix: Keep Tanker object alive in stop() until fully stopped
Browse files Browse the repository at this point in the history
This prevents tanker_destroy from being called during stop(),
which causes a cancel (and has triggered bugs in the past).
  • Loading branch information
tux3 committed May 3, 2021
1 parent 205eec6 commit 4c9df2e
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion tanker-bindings/src/main/kotlin/io/tanker/api/Tanker.kt
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,9 @@ class Tanker(tankerOptions: TankerOptions) {
*/
fun stop(): TankerFuture<Unit> {
val futurePtr = lib.tanker_stop(tanker)
return TankerFuture(futurePtr, Unit::class.java)
return TankerFuture<Unit>(futurePtr, Unit::class.java).andThen(TankerCallbackWithKeepAlive(keepAlive = this) {
// Keep the GC from calling tanker_destroy() through the finalizer until stop() is finished
})
}

/**
Expand Down

0 comments on commit 4c9df2e

Please sign in to comment.