Skip to content

Commit

Permalink
Use complete instead of cancel
Browse files Browse the repository at this point in the history
  • Loading branch information
05nelsonm committed Apr 8, 2024
1 parent d195b47 commit 500d299
Showing 1 changed file with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -252,20 +252,20 @@ public actual interface TorCtrl : Destroyable, TorEvent.Processor, TorCmd.Privil
val _chunk = chunk.asDynamic()
for (i in command.indices) { _chunk[i] = command[i] }

val wLatch = Job()
var dLatch: Job? = null
val wLatch: CompletableJob = Job(currentCoroutineContext()[Job])
var dLatch: CompletableJob? = null

try {
val immediate = socket.write(chunk, callback = {
wLatch.cancel()
wLatch.complete()

// fill
for (i in command.indices) { _chunk[i] = 0 }
})

if (!immediate) {
dLatch = Job()
socket.once("drain") { dLatch.cancel() }
dLatch = Job(wLatch)
socket.once("drain") { dLatch.complete() }
}
} catch (t: Throwable) {
wLatch.cancel()
Expand Down

0 comments on commit 500d299

Please sign in to comment.