tisdall commented on PR #2740:
URL: https://github.com/apache/thrift/pull/2740#issuecomment-1681088991

   @Jens-G Not sure how to properly file a bug, but this PR seems to have 
broken some code when I upgraded to 0.18.1
   
   The issue is that I'm using a unix socket and not a socket capable of IPV6.  
Short demo example:
   ```python
   from thrift.transport.TSocket import TServerSocket
   server_socket = TServerSocket(unix_socket='/tmp/test.sock')
   server_socket.listen()
   ```
   
   Output:
   ```
   Traceback (most recent call last):
     File "test.py", line 4, in <module>
       server_socket.listen()
     File "lib/python3.9/site-packages/thrift/transport/TSocket.py", line 232, 
in listen
       self.handle.setsockopt(socket.IPPROTO_IPV6, socket.IPV6_V6ONLY, 0)
   OSError: [Errno 102] Operation not supported on socket
   ```
   
   Same issue by using the python interpreter:
   ```
   Python 3.9.13 (main, Jul 27 2022, 08:01:19) 
   [Clang 13.1.6 (clang-1316.0.21.2.5)] on darwin
   Type "help", "copyright", "credits" or "license" for more information.
   >>> import socket
   >>> s = socket.socket(socket.AF_INET6, socket.SOCK_STREAM, 0)
   >>> s.setsockopt(socket.IPPROTO_IPV6, socket.IPV6_V6ONLY, 0)  # works fine 
with AF_INET6!
   >>>
   >>> s = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM, 0)
   >>> s.setsockopt(socket.IPPROTO_IPV6, socket.IPV6_V6ONLY, 0)
   Traceback (most recent call last):
     File "<stdin>", line 1, in <module>
   OSError: [Errno 102] Operation not supported on socket
   ```
   
   Perhaps this should be fixed to be the following?
   ```python
           self.handle = socket.socket(res[0], res[1])
           if not self._unix_socket:
               self.handle.setsockopt(socket.IPPROTO_IPV6, socket.IPV6_V6ONLY, 
0)
           self.handle.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
   ```


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