Jens-G commented on code in PR #2670:
URL: https://github.com/apache/thrift/pull/2670#discussion_r980475084


##########
lib/swift/Sources/TSocketServer.swift:
##########
@@ -96,34 +96,29 @@ open class TSocketServer<InProtocol: TProtocol, 
OutProtocol: TProtocol, Processo
 
     // throw away our socket
     CFSocketInvalidate(sock)
-
-    // register for notifications of accepted incoming connections
-    _ = NotificationCenter.default.addObserver(forName: 
.NSFileHandleConnectionAccepted,
-                                               object: nil, queue: nil) {
-                                                [weak self] notification in
-                                                guard let strongSelf = self 
else { return }
-                                                guard let clientSocket = 
notification.userInfo?[NSFileHandleNotificationFileHandleItem] as? FileHandle 
else { return }
-                                                
strongSelf.connectionAccepted(clientSocket)
-    }
-
-    // tell socket to listen
-    socketFileHandle.acceptConnectionInBackgroundAndNotify()
-
+    
     print("TSocketServer: Listening on TCP port \(port)")
+    
+    // tell socket to listen
+    acceptConnectionInBackgroundAndNotify(handle: socketFileHandle)
   }
-
-  deinit {
-    NotificationCenter.default.removeObserver(self)
+  
+  open func acceptConnectionInBackgroundAndNotify(handle: FileHandle) {
+    DispatchQueue(label: "ConnectionAcceptQueue").async {
+      let acceptedFD = accept(handle.fileDescriptor, nil, nil)
+      DispatchQueue.main.async {

Review Comment:
   The `byte` type was **always** signed, like all Thrift integer types. So we 
renamed the type specifier a while ago from byte to `i8` mostly to remove that 
constant source of confusion - a byte is considered unsigned in many languages. 
Nevertheless, [for compatibility 
reasons](https://www.mail-archive.com/[email protected]/msg50144.html) you 
still can use `byte` in the IDL. 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to