Skip to content

Commit

Permalink
fix leaks
Browse files Browse the repository at this point in the history
  • Loading branch information
whyoleg committed Mar 12, 2024
1 parent 5e1faf7 commit 238909a
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,20 @@ internal class RequesterOperationExecutor(
requestsScope.ensureActive()
}

return requestsScope.launch {
@OptIn(ExperimentalCoroutinesApi::class)
return requestsScope.launch(start = CoroutineStart.ATOMIC) {
try {
ensureActive()
} catch (cause: Throwable) {
payload.close()
operation.receiveProcessingError(cause)
throw cause
}
val outbound = try {
operationFactory.createRequest(operation.type, OperationFrameHandler(operation))
} catch (cause: Throwable) {
operation.receiveProcessingError(cause)
payload.close()

operation.receiveProcessingError(cause)
throw cause
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,14 @@ private class WrappedResponderOperation(
null -> {
// TODO: need to somehow enforce this better
checkNotNull(payload) { "Payload should be present for request" }
requestJob = requestsScope.launch {
@OptIn(ExperimentalCoroutinesApi::class)
requestJob = requestsScope.launch(start = CoroutineStart.ATOMIC) {
try {
ensureActive()
} catch (cause: Throwable) {
payload.close()
throw cause
}
try {
operation.execute(outbound, payload, complete)
} catch (cause: Throwable) {
Expand Down

0 comments on commit 238909a

Please sign in to comment.