Sha256: 4d136dec99d50f7403cab23bdb8e3e7a830cdf22c6328ababdbb01a3e2902264

Contents?: true

Size: 807 Bytes

Versions: 7

Compression:

Stored size: 807 Bytes

Contents

#!/usr/bin/env ruby

PGHOST   = 'localhost'
PGDB     = 'test'
#SOCKHOST = 'github.com'
SOCKHOST = 'it-trac.laika.com'

# Load pg first, so the libssl.so that libpq is linked against is loaded.
require 'pg'
$stderr.puts "connecting to postgres://#{PGHOST}/#{PGDB}"
conn = PGconn.connect( PGHOST, :dbname => PGDB )

# Now load OpenSSL, which might be linked against a different libssl.
require 'socket'
require 'openssl'
$stderr.puts "Connecting to #{SOCKHOST}"
sock = TCPSocket.open( SOCKHOST, 443 )
ctx = OpenSSL::SSL::SSLContext.new
sock = OpenSSL::SSL::SSLSocket.new( sock, ctx )
sock.sync_close = true

# The moment of truth...
$stderr.puts "Attempting to connect..."
begin
	sock.connect
rescue Errno
	$stderr.puts "Got an error connecting, but no segfault."
else
	$stderr.puts "Nope, no segfault!"
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
pg-0.12.2-x86-mingw32 misc/openssl-pg-segfault.rb
pg-0.12.2 misc/openssl-pg-segfault.rb
pg-0.12.1 misc/openssl-pg-segfault.rb
pg-0.12.0-x86-mingw32 misc/openssl-pg-segfault.rb
pg-0.12.0 misc/openssl-pg-segfault.rb
pg-0.12.0.pre263 misc/openssl-pg-segfault.rb
pg-0.12.0pre258 misc/openssl-pg-segfault.rb