Ruby/OpenSSL bug?

The following program hangs indefinitely, blocking the whole script. I would
expect it to gracefully return an error.

require 'webrick’
require ‘net/https’

s = WEBrick::HTTPServer.new(:Port => 5555)

s.mount_proc("/") do |req, resp|
resp.body = "Hi"
end

t = Thread.new do
s.start
end

h = Net::HTTP.new(‘localhost’, 5555)
h.use_ssl = true
h.head(’/’)

s.stop
t.join

Note calling #head on an HTTP object pointing at an SSL server does fine.
I’m running:

ruby 1.8.1 (2003-10-31) [i386-linux]

Please let me know if there’s any more information I can provide. It would
be great if this could be fixed before the release of 1.8.1.

Thanks,

Nathaniel

<:((><

In message 009801c3a8ba$031c5e00$c81e140a@abraham,

The following program hangs indefinitely, blocking the whole script. I would
expect it to gracefully return an error.

Handshake of SSL needs exchange of some messages, but
SSLSocket#connect disables switch of thread because it is
implemented with C.

I don’t understand whether it is safe to wrap SSL_connect
with TRAP_BEG and TRAP_END. I think that it’s better to do
it experimentally after release of Ruby-1.8.1 than now.

regards,

···

`“Nathaniel Talbott” nathaniel@NOSPAMtalbott.ws’ wrote:

gotoyuzo

In message 20031113.030225.1011599469.gotoyuzo@kotetsu.does.notwork.org,

···

`GOTOU Yuuzou gotoyuzo@notwork.org’ wrote:

In message 009801c3a8ba$031c5e00$c81e140a@abraham,
`“Nathaniel Talbott” nathaniel@NOSPAMtalbott.ws’ wrote:

The following program hangs indefinitely, blocking the whole script. I would
expect it to gracefully return an error.

Handshake of SSL needs exchange of some messages, but
SSLSocket#connect disables switch of thread because it is
implemented with C.

I don’t understand whether it is safe to wrap SSL_connect
with TRAP_BEG and TRAP_END. I think that it’s better to do
it experimentally after release of Ruby-1.8.1 than now.

Though I tried to test it, it didn’t work :wink:
However it enables to interrupt with Crtl-C.
Hmm, I try inspecting a little more.


gotoyuzo

Handshake of SSL needs exchange of some messages, but
SSLSocket#connect disables switch of thread because it is
implemented with C.

Bummer. :frowning:

I don’t guess there’s a non-blocking version of connect, eh?

I don’t understand whether it is safe to wrap SSL_connect
with TRAP_BEG and TRAP_END. I think that it’s better to do
it experimentally after release of Ruby-1.8.1 than now.

Will this allow other threads to run? My problem is that I have a Webrick
server that needs to check if another site is up, and I don’t want the whole
server blocking while it waits on the (possibly nonexistent) reply from the
site.

Thanks for looking in to this,

Nathaniel

<:((><

···

GOTOU Yuuzou [mailto:gotoyuzo@notwork.org] wrote: