Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 1d748570 authored by Abel Lucas's avatar Abel Lucas Committed by Automerger Merge Worker
Browse files

Merge "PandoraServer: Properly cancel the job" am: e65f667e

parents 3dbf4777 e65f667e
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -167,6 +167,7 @@ fun <T, U> grpcBidirectionalStream(
): StreamObserver<T> {

  val inputChannel = Channel<T>()
  val serverCallStreamObserver = responseObserver as ServerCallStreamObserver<T>

  val job =
    scope.launch {
@@ -184,6 +185,8 @@ fun <T, U> grpcBidirectionalStream(
        .launchIn(this)
    }

  serverCallStreamObserver.setOnCancelHandler { job.cancel() }

  return object : StreamObserver<T> {
    override fun onNext(req: T) {
      // Note: this should be made a blocking call, and the handler should run in a separate thread