فهرست منبع

Fix race condition

Chris Vanderschuere 7 سال پیش
والد
کامیت
4489716b93
2فایلهای تغییر یافته به همراه4 افزوده شده و 5 حذف شده
  1. 1 1
      Sources/SwiftGRPC/Core/Call.swift
  2. 3 4
      Tests/SwiftGRPCTests/GRPCTests.swift

+ 1 - 1
Sources/SwiftGRPC/Core/Call.swift

@@ -108,7 +108,7 @@ public struct CallResult: CustomStringConvertible {
       initialMetadata = op.receivedInitialMetadata()
       trailingMetadata = op.receivedTrailingMetadata()
     } else {
-      statusCode = .ok
+      statusCode = .unknown
       statusMessage = nil
       resultData = nil
       initialMetadata = nil

+ 3 - 4
Tests/SwiftGRPCTests/GRPCTests.swift

@@ -220,8 +220,6 @@ func callServerStream(channel: Channel) throws {
     sem.signal() // signal call is finished
   }
 
-  call.messageQueueEmpty.wait() // wait for start to finish
-
   for _ in 0..<steps {
     let messageSem = DispatchSemaphore(value: 0)
     try call.receiveMessage(completion: { (data) in
@@ -234,6 +232,7 @@ func callServerStream(channel: Channel) throws {
 
     _ = messageSem.wait()
   }
+
   _ = sem.wait()
 }
 
@@ -260,8 +259,6 @@ func callBiDiStream(channel: Channel) throws {
     sem.signal() // signal call is finished
   }
 
-  call.messageQueueEmpty.wait() // wait for start to finish
-
   // Send pings
   for _ in 0..<steps {
     let pingSem = DispatchSemaphore(value: 0)
@@ -285,6 +282,8 @@ func callBiDiStream(channel: Channel) throws {
     })
     _ = pongSem.wait()
   }
+
+  _ = sem.wait()
 }
 
 func runServer(server: Server) throws {