[
https://issues.apache.org/jira/browse/THRIFT-5125?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Jano Svitok updated THRIFT-5125:
--------------------------------
Component/s: (was: Swift - Compiler)
> 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
> Priority: Major
>
> 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
> 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 for TFramedTransport problems, to keep this
> manageable.
--
This message was sent by Atlassian Jira
(v8.3.4#803005)