[ https://issues.apache.org/jira/browse/THRIFT-5125?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Jens Geyer resolved THRIFT-5125. -------------------------------- Fix Version/s: 0.14.0 Assignee: Jano Svitok Resolution: Fixed > Swift server does not work using present code. > ---------------------------------------------- > > Key: THRIFT-5125 > URL: https://issues.apache.org/jira/browse/THRIFT-5125 > Project: Thrift > Issue Type: Bug > Components: Swift - Library > Affects Versions: 0.14.0 > Reporter: Jano Svitok > Assignee: Jano Svitok > Priority: Major > Fix For: 0.14.0 > > Time Spent: 0.5h > Remaining Estimate: 0h > > TL;DR: Swift server does not work using present code. > > I'm writing thrift server in swift running on iOS. For reference, I'm using > SocketServer, MultiplexedProcessor with BinaryProtocol over FramedTransport. > Client is in Java, and we already have Java server running on Android. > Note that I'm new to swift, iOS and Apple world, so I may not understand > everything. > > During development I've found these issues: > > # _TSocketServer.init()_: Conversion of port: Int to sin_port: in_port_t > (that is UInt16) fails with "... _is not representable as_...". > UInt16(truncatingIfNeeded: ).bigEndian is needed instead of port.bigEndian > # > [https://github.com/apache/thrift/blob/master/lib/swift/Sources/TSocketServer.swift#L85] > tries to deallocate _address,_ due to _nil_ deallocator, equivalent to > _kCFAllocatorDefault_. Proper deallocator seems to be _kCFAllocatorNone_. > # According to > [https://developer.apple.com/documentation/foundation/nsfilehandle/1413309-acceptconnectioninbackgroundandn?language=objc] > (see last paragraph), > _socketFileHandle.acceptConnectionInBackgroundAndNotify()_ should be called > again at the end of _TSocketServer.connectionAccepted()_. Old cocoa code does > it. > # _TSocketServer.connectionAccepted()_ tries to read from the listening > socket instead of client socket, resulting in "Socket not connected" error. > Client socket handle is in > _notification.userInfo[NSFileHandleNotificationFileHandleItem]_ > # TSocketServer.handleClientConnection handles only one message. Loop is > missing around _try processor.process()_. I.e. _while true \{ try > processor.process }_ > # It is not possible to pass _TFramedTransport_ to _TSocketServer_ > # _TSocketServer.serviceHandle_ is not used anymore > # FileHandle.acceptConnectionInBackgroundAndNotify() is not implemented in > Linux swift 4.2. Upgrade to 5.1 is required for this to work on Linux. See > [https://github.com/apple/swift-corelibs-foundation/commit/fc96d7fd139bc894689b5cc13a22d9c52424caf8] > Cross tests can't work with 4.2. > PR with fixes: [https://github.com/apache/thrift/pull/2038] > Notes: > * Before merging this I suggest merging PR 2036 > * I did not create tests for connection changes. I could not get client and > server work in the same process/thread. I will try to write simple test to > check the code in cross tests but that may take some time. > * I've tried to create test for socketserver, but could not implement client > connect problem with Int to UInt16 is most probably present in client code as > well (TSocketTransport) > * I've created separate issue THRIFT-5128 for TFramedTransport problems, to > keep this one manageable. -- This message was sent by Atlassian Jira (v8.3.4#803005)