thrift-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jano Svitok (Jira)" <j...@apache.org>
Subject [jira] [Updated] (THRIFT-5125) Swift server does not work using present code.
Date Mon, 02 Mar 2020 14:07:00 GMT

     [ https://issues.apache.org/jira/browse/THRIFT-5125?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Jano Svitok updated THRIFT-5125:
--------------------------------
    Description: 
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

Note: 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.

  was:
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

I will create pull request after I clean up my patches.


> 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 - Compiler, 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
> Note: 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.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Mime
View raw message