Skip to content

Fixed an error preventing Thrift::NonblockingServer from working with SSL#3307

Open
kpumuk wants to merge 1 commit intoapache:masterfrom
kpumuk:nonblocking-ssl
Open

Fixed an error preventing Thrift::NonblockingServer from working with SSL#3307
kpumuk wants to merge 1 commit intoapache:masterfrom
kpumuk:nonblocking-ssl

Conversation

@kpumuk
Copy link
Contributor

@kpumuk kpumuk commented Feb 13, 2026

Currently Thrift::NonblockingServer does not work when configured with SSL sockets:

$ THRIFT_TLS=true bundle exec rake benchmark /usr/local/bin/ruby benchmark/benchmark.rb
Starting server...
#<Thread:0x0000ffff817cb718 benchmark/server.rb:87 run> terminated with exception (report_on_exception is true):
/thrift/src/lib/rb/lib/thrift/server/nonblocking_server.rb:48:in 'Kernel#select': can't convert Thrift::SSLServerSocket to IO (Thrift::SSLServerSocket#to_io gives OpenSSL::SSL::SSLServer) (TypeError)

            rd, = select([@server_transport], nil, nil, 0.1)
                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        from /thrift/src/lib/rb/lib/thrift/server/nonblocking_server.rb:48:in 'block in Thrift::NonblockingServer#serve'
        from /thrift/src/lib/rb/lib/thrift/server/nonblocking_server.rb:45:in 'Kernel#loop'
        from /thrift/src/lib/rb/lib/thrift/server/nonblocking_server.rb:45:in 'Thrift::NonblockingServer#serve'
        from benchmark/server.rb:88:in 'block in Server.start_server'

This is happening because #to_io on the SSL socket returns the wrapped handler instead of the underlying socket.

After the change we get a clear output:

$ THRIFT_TLS=true bundle exec rake benchmark
/usr/local/bin/ruby benchmark/benchmark.rb
Starting server...
Spawning benchmark processes...
Collecting output...
Translating output...
Analyzing output...

Server class:        Thrift::NonblockingServer
Server interpreter:  ruby 
Client interpreter:  ruby
Protocol type:       binary
Socket class:        Thrift::SSLSocket 
Number of processes: 40
Clients per process: 5
Calls per client:    50
Using fastthread:    no

Connection failures:                0 
Connection errors:                  0
Average time per call:              0.0033 seconds
Average time per client (50 calls): 0.2159 seconds
Total time for all calls:           32.5091 seconds
Real time for benchmarking:         2.7874 seconds
Shortest call time:                 0.0001 seconds
Longest call time:                  0.0213 seconds
Shortest client time (50 calls):    0.0560 seconds
Longest client time (50 calls):     0.3463 seconds
  • Did you create an Apache Jira ticket? (Request account here, not required for trivial changes)
  • If a ticket exists: Does your pull request title follow the pattern "THRIFT-NNNN: describe my issue"?
  • Did you squash your changes to a single commit? (not required, but preferred)
  • Did you do your best to avoid breaking changes? If one was needed, did you label the Jira ticket with "Breaking-Change"?
  • If your change does not involve any code, include [skip ci] anywhere in the commit message to free up build resources.

@mergeable mergeable bot added the ruby label Feb 13, 2026
@kpumuk kpumuk changed the title Fixed en error preventing Thrift::NonblockingServer from working with SSL Fixed an error preventing Thrift::NonblockingServer from working with SSL Feb 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant