eventmachine 0.9.0 → 0.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/DEFERRABLES +3 -3
- data/PURE_RUBY +77 -0
- data/ext/cmain.cpp +41 -2
- data/ext/ed.cpp +67 -3
- data/ext/ed.h +4 -1
- data/ext/em.cpp +33 -10
- data/ext/em.h +6 -14
- data/ext/eventmachine.h +4 -1
- data/ext/pipe.cpp +21 -3
- data/ext/rubymain.cpp +38 -1
- data/ext/ssl.cpp +9 -3
- data/lib/em/streamer.rb +1 -3
- data/lib/eventmachine.rb +190 -38
- data/lib/eventmachine_version.rb +2 -2
- data/lib/pr_eventmachine.rb +309 -28
- data/lib/protocols/httpcli2.rb +784 -0
- data/lib/protocols/saslauth.rb +121 -0
- data/lib/protocols/smtpclient.rb +41 -10
- data/lib/protocols/smtpserver.rb +30 -1
- data/tests/test_basic.rb +33 -2
- data/tests/test_epoll.rb +9 -3
- data/tests/test_errors.rb +72 -0
- data/tests/test_httpclient2.rb +132 -0
- data/tests/test_pure.rb +127 -0
- data/tests/test_timers.rb +30 -1
- metadata +37 -32
- data/ext/eee +0 -173
- data/lib/svn-commit.tmp +0 -4
@@ -0,0 +1,132 @@
|
|
1
|
+
# $Id: test_httpclient.rb 518 2007-08-30 10:17:02Z blackhedd $
|
2
|
+
#
|
3
|
+
# Author:: Francis Cianfrocca (gmail: blackhedd)
|
4
|
+
# Homepage:: http://rubyeventmachine.com
|
5
|
+
# Date:: 8 April 2006
|
6
|
+
#
|
7
|
+
# See EventMachine and EventMachine::Connection for documentation and
|
8
|
+
# usage examples.
|
9
|
+
#
|
10
|
+
#----------------------------------------------------------------------------
|
11
|
+
#
|
12
|
+
# Copyright (C) 2006-07 by Francis Cianfrocca. All Rights Reserved.
|
13
|
+
# Gmail: blackhedd
|
14
|
+
#
|
15
|
+
# This program is free software; you can redistribute it and/or modify
|
16
|
+
# it under the terms of either: 1) the GNU General Public License
|
17
|
+
# as published by the Free Software Foundation; either version 2 of the
|
18
|
+
# License, or (at your option) any later version; or 2) Ruby's License.
|
19
|
+
#
|
20
|
+
# See the file COPYING for complete licensing information.
|
21
|
+
#
|
22
|
+
#---------------------------------------------------------------------------
|
23
|
+
#
|
24
|
+
#
|
25
|
+
#
|
26
|
+
|
27
|
+
$:.unshift "../lib"
|
28
|
+
require 'eventmachine'
|
29
|
+
|
30
|
+
class TestHttpClient2 < Test::Unit::TestCase
|
31
|
+
Localhost = "127.0.0.1"
|
32
|
+
Localport = 9801
|
33
|
+
|
34
|
+
def setup
|
35
|
+
end
|
36
|
+
|
37
|
+
def teardown
|
38
|
+
end
|
39
|
+
|
40
|
+
|
41
|
+
class TestServer < EM::Connection
|
42
|
+
end
|
43
|
+
|
44
|
+
# #connect returns an object which has made a connection to an HTTP server
|
45
|
+
# and exposes methods for making HTTP requests on that connection.
|
46
|
+
# #connect can take either a pair of parameters (a host and a port),
|
47
|
+
# or a single parameter which is a Hash.
|
48
|
+
#
|
49
|
+
def test_connect
|
50
|
+
EM.run {
|
51
|
+
EM.start_server Localhost, Localport, TestServer
|
52
|
+
http1 = EM::P::HttpClient2.connect Localhost, Localport
|
53
|
+
http2 = EM::P::HttpClient2.connect( :host=>Localhost, :port=>Localport )
|
54
|
+
EM.stop
|
55
|
+
}
|
56
|
+
end
|
57
|
+
|
58
|
+
|
59
|
+
def test_bad_port
|
60
|
+
EM.run {
|
61
|
+
EM.start_server Localhost, Localport, TestServer
|
62
|
+
assert_raise( ArgumentError ) {
|
63
|
+
EM::P::HttpClient2.connect Localhost, "xxx"
|
64
|
+
}
|
65
|
+
EM.stop
|
66
|
+
}
|
67
|
+
end
|
68
|
+
|
69
|
+
def test_bad_server
|
70
|
+
EM.run {
|
71
|
+
http = EM::P::HttpClient2.connect Localhost, 9999
|
72
|
+
d = http.get "/"
|
73
|
+
d.errback {p d.internal_error; EM.stop }
|
74
|
+
}
|
75
|
+
end
|
76
|
+
|
77
|
+
def test_get
|
78
|
+
EM.run {
|
79
|
+
http = EM::P::HttpClient2.connect "www.bayshorenetworks.com", 80
|
80
|
+
d = http.get "/"
|
81
|
+
d.callback {
|
82
|
+
p d.content
|
83
|
+
EM.stop
|
84
|
+
}
|
85
|
+
}
|
86
|
+
end
|
87
|
+
|
88
|
+
# Not a pipelined request because we wait for one response before we request the next.
|
89
|
+
def test_get_multiple
|
90
|
+
EM.run {
|
91
|
+
http = EM::P::HttpClient2.connect "www.bayshorenetworks.com", 80
|
92
|
+
d = http.get "/"
|
93
|
+
d.callback {
|
94
|
+
e = http.get "/"
|
95
|
+
e.callback {
|
96
|
+
p e.content
|
97
|
+
EM.stop
|
98
|
+
}
|
99
|
+
}
|
100
|
+
}
|
101
|
+
end
|
102
|
+
|
103
|
+
def test_get_pipeline
|
104
|
+
EM.run {
|
105
|
+
http = EM::P::HttpClient2.connect "www.microsoft.com", 80
|
106
|
+
d = http.get("/")
|
107
|
+
d.callback {
|
108
|
+
p d.headers
|
109
|
+
}
|
110
|
+
e = http.get("/")
|
111
|
+
e.callback {
|
112
|
+
p e.headers
|
113
|
+
}
|
114
|
+
EM::Timer.new(1) {EM.stop}
|
115
|
+
}
|
116
|
+
end
|
117
|
+
|
118
|
+
|
119
|
+
def test_authheader
|
120
|
+
EM.run {
|
121
|
+
EM.start_server Localhost, Localport, TestServer
|
122
|
+
http = EM::P::HttpClient2.connect Localhost, 18842
|
123
|
+
d = http.get :url=>"/", :authorization=>"Basic xxx"
|
124
|
+
d.callback {EM.stop}
|
125
|
+
d.errback {EM.stop}
|
126
|
+
}
|
127
|
+
end
|
128
|
+
|
129
|
+
|
130
|
+
end
|
131
|
+
|
132
|
+
|
data/tests/test_pure.rb
ADDED
@@ -0,0 +1,127 @@
|
|
1
|
+
# $Id: test_pure.rb 604 2007-12-06 12:31:39Z blackhedd $
|
2
|
+
#
|
3
|
+
# Author:: Francis Cianfrocca (gmail: blackhedd)
|
4
|
+
# Homepage:: http://rubyeventmachine.com
|
5
|
+
# Date:: 8 April 2006
|
6
|
+
#
|
7
|
+
# See EventMachine and EventMachine::Connection for documentation and
|
8
|
+
# usage examples.
|
9
|
+
#
|
10
|
+
#----------------------------------------------------------------------------
|
11
|
+
#
|
12
|
+
# Copyright (C) 2006-07 by Francis Cianfrocca. All Rights Reserved.
|
13
|
+
# Gmail: blackhedd
|
14
|
+
#
|
15
|
+
# This program is free software; you can redistribute it and/or modify
|
16
|
+
# it under the terms of either: 1) the GNU General Public License
|
17
|
+
# as published by the Free Software Foundation; either version 2 of the
|
18
|
+
# License, or (at your option) any later version; or 2) Ruby's License.
|
19
|
+
#
|
20
|
+
# See the file COPYING for complete licensing information.
|
21
|
+
#
|
22
|
+
#---------------------------------------------------------------------------
|
23
|
+
#
|
24
|
+
#
|
25
|
+
#
|
26
|
+
|
27
|
+
$:.unshift "../lib"
|
28
|
+
require 'eventmachine'
|
29
|
+
|
30
|
+
class TestPure < Test::Unit::TestCase
|
31
|
+
|
32
|
+
|
33
|
+
Host,Port = "0.0.0.0", 9060
|
34
|
+
|
35
|
+
|
36
|
+
# These tests are intended to exercise problems that come up in the
|
37
|
+
# pure-Ruby implementation. However, we DON'T constrain them such that
|
38
|
+
# they only run in pure-Ruby. These tests need to work identically in
|
39
|
+
# any implementation.
|
40
|
+
|
41
|
+
def setup
|
42
|
+
end
|
43
|
+
|
44
|
+
def teardown
|
45
|
+
end
|
46
|
+
|
47
|
+
#-------------------------------------
|
48
|
+
|
49
|
+
# The EM reactor needs to run down open connections and release other resources
|
50
|
+
# when it stops running. Make sure this happens even if user code throws a Ruby
|
51
|
+
# exception.
|
52
|
+
# One way to see this is to run identical tests that open a TCP server and throw
|
53
|
+
# an exception. (We do this twice because an exception aborts a test. We make the
|
54
|
+
# two tests identical except for the method name because we can't predict the order
|
55
|
+
# in which the test harness will run them.)
|
56
|
+
# If exception handling is incorrect, the second test will fail with a no-bind error
|
57
|
+
# because the TCP server opened in the first test will not have been closed.
|
58
|
+
#
|
59
|
+
def run_exception
|
60
|
+
EM.run {
|
61
|
+
EM.start_server Host, Port
|
62
|
+
raise "an exception"
|
63
|
+
}
|
64
|
+
end
|
65
|
+
def test_exception_1
|
66
|
+
assert_raise( RuntimeError ) { run_exception }
|
67
|
+
end
|
68
|
+
def test_exception_2
|
69
|
+
assert_raise( RuntimeError ) { run_exception }
|
70
|
+
end
|
71
|
+
|
72
|
+
|
73
|
+
|
74
|
+
# Under some circumstances, the pure Ruby library would emit an Errno::ECONNREFUSED
|
75
|
+
# exception on certain kinds of TCP connect-errors.
|
76
|
+
# It's always been something of an open question whether EM should throw an exception
|
77
|
+
# in these cases but the defined answer has always been to catch it the unbind method.
|
78
|
+
# With a connect failure, the latter will always fire, but connection_completed will
|
79
|
+
# never fire. So even though the point is arguable, it's incorrect for the pure Ruby
|
80
|
+
# version to throw an exception.
|
81
|
+
module TestConnrefused
|
82
|
+
def unbind
|
83
|
+
EM.stop
|
84
|
+
end
|
85
|
+
def connection_completed
|
86
|
+
raise "should never get here"
|
87
|
+
end
|
88
|
+
end
|
89
|
+
def test_connrefused
|
90
|
+
EM.run {
|
91
|
+
EM.connect "0.0.0.0", 60001, TestConnrefused
|
92
|
+
}
|
93
|
+
end
|
94
|
+
|
95
|
+
|
96
|
+
# Make sure connection_completed gets called as expected with TCP clients. This is the
|
97
|
+
# opposite of test_connrefused.
|
98
|
+
# If the test fails, it will hang because EM.stop never gets called.
|
99
|
+
#
|
100
|
+
module TestConnaccepted
|
101
|
+
def connection_completed
|
102
|
+
EM.stop
|
103
|
+
end
|
104
|
+
end
|
105
|
+
def test_connaccepted
|
106
|
+
timeout = false
|
107
|
+
EM.run {
|
108
|
+
EM.start_server "0.0.0.0", 60002
|
109
|
+
EM.connect "0.0.0.0", 60002, TestConnaccepted
|
110
|
+
EM::Timer.new(1) {timeout = true; EM.stop}
|
111
|
+
}
|
112
|
+
assert_equal( false, timeout )
|
113
|
+
end
|
114
|
+
|
115
|
+
|
116
|
+
|
117
|
+
def test_reactor_running
|
118
|
+
a = false
|
119
|
+
EM.run {
|
120
|
+
a = EM.reactor_running?
|
121
|
+
EM.next_tick {EM.stop}
|
122
|
+
}
|
123
|
+
assert a
|
124
|
+
end
|
125
|
+
|
126
|
+
|
127
|
+
end
|
data/tests/test_timers.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# $Id: test_timers.rb
|
1
|
+
# $Id: test_timers.rb 597 2007-12-05 12:48:36Z blackhedd $
|
2
2
|
#
|
3
3
|
# Author:: Francis Cianfrocca (gmail: blackhedd)
|
4
4
|
# Homepage:: http://rubyeventmachine.com
|
@@ -105,5 +105,34 @@ class TestTimers < Test::Unit::TestCase
|
|
105
105
|
assert( x == 4 )
|
106
106
|
end
|
107
107
|
|
108
|
+
|
109
|
+
# This test is only applicable to compiled versions of the reactor.
|
110
|
+
# Pure ruby versions have no built-in limit on the number of outstanding timers.
|
111
|
+
#
|
112
|
+
def test_timer_change_max_outstanding
|
113
|
+
ten_thousand_timers = proc {
|
114
|
+
10000.times {
|
115
|
+
EM.add_timer(5) {}
|
116
|
+
}
|
117
|
+
}
|
118
|
+
EM.run {
|
119
|
+
if EM.library_type == :pure_ruby
|
120
|
+
ten_thousand_timers.call
|
121
|
+
else
|
122
|
+
assert_raise( RuntimeError ) {
|
123
|
+
ten_thousand_timers.call
|
124
|
+
}
|
125
|
+
end
|
126
|
+
EM.stop
|
127
|
+
}
|
128
|
+
|
129
|
+
EM.set_max_timers( 10001 )
|
130
|
+
|
131
|
+
EM.run {
|
132
|
+
ten_thousand_timers.call
|
133
|
+
EM.stop
|
134
|
+
}
|
135
|
+
end
|
136
|
+
|
108
137
|
end
|
109
138
|
|
metadata
CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.9.0
|
|
3
3
|
specification_version: 1
|
4
4
|
name: eventmachine
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 0.
|
7
|
-
date: 2007-09
|
6
|
+
version: 0.10.0
|
7
|
+
date: 2007-12-09 00:00:00 -05:00
|
8
8
|
summary: Ruby/EventMachine library
|
9
9
|
require_paths:
|
10
10
|
- lib
|
@@ -30,48 +30,52 @@ authors:
|
|
30
30
|
- Francis Cianfrocca
|
31
31
|
files:
|
32
32
|
- tests/test_httpclient.rb
|
33
|
+
- tests/test_exc.rb
|
34
|
+
- tests/test_running.rb
|
35
|
+
- tests/test_ltp2.rb
|
33
36
|
- tests/test_basic.rb
|
34
|
-
- tests/
|
37
|
+
- tests/test_smtpclient.rb
|
38
|
+
- tests/test_send_file.rb
|
39
|
+
- tests/test_next_tick.rb
|
35
40
|
- tests/test_eventables.rb
|
36
|
-
- tests/
|
37
|
-
- tests/
|
41
|
+
- tests/test_spawn.rb
|
42
|
+
- tests/test_servers.rb
|
38
43
|
- tests/test_hc.rb
|
44
|
+
- tests/test_kb.rb
|
39
45
|
- tests/test_futures.rb
|
40
|
-
- tests/
|
46
|
+
- tests/test_ltp.rb
|
47
|
+
- tests/test_httpclient2.rb
|
48
|
+
- tests/testem.rb
|
41
49
|
- tests/test_timers.rb
|
42
|
-
- tests/
|
43
|
-
- tests/test_next_tick.rb
|
44
|
-
- tests/test_servers.rb
|
45
|
-
- tests/test_send_file.rb
|
46
|
-
- tests/test_kb.rb
|
47
|
-
- tests/test_ltp2.rb
|
48
|
-
- tests/test_running.rb
|
49
|
-
- tests/test_spawn.rb
|
50
|
-
- tests/test_smtpclient.rb
|
50
|
+
- tests/test_ud.rb
|
51
51
|
- tests/test_smtpserver.rb
|
52
|
+
- tests/test_pure.rb
|
53
|
+
- tests/test_epoll.rb
|
54
|
+
- tests/test_errors.rb
|
52
55
|
- lib/em
|
53
56
|
- lib/protocols
|
54
57
|
- lib/evma
|
58
|
+
- lib/jeventmachine.rb
|
55
59
|
- lib/eventmachine.rb
|
56
60
|
- lib/pr_eventmachine.rb
|
57
61
|
- lib/evma.rb
|
58
62
|
- lib/eventmachine_version.rb
|
59
|
-
- lib/
|
60
|
-
- lib/svn-commit.tmp
|
63
|
+
- lib/em/streamer.rb
|
61
64
|
- lib/em/eventable.rb
|
62
|
-
- lib/em/
|
65
|
+
- lib/em/messages.rb
|
63
66
|
- lib/em/future.rb
|
67
|
+
- lib/em/deferrable.rb
|
64
68
|
- lib/em/spawnable.rb
|
65
|
-
- lib/em/messages.rb
|
66
|
-
- lib/em/streamer.rb
|
67
|
-
- lib/protocols/httpclient.rb
|
68
|
-
- lib/protocols/tcptest.rb
|
69
69
|
- lib/protocols/line_and_text.rb
|
70
|
-
- lib/protocols/
|
71
|
-
- lib/protocols/buftok.rb
|
72
|
-
- lib/protocols/stomp.rb
|
70
|
+
- lib/protocols/httpclient.rb
|
73
71
|
- lib/protocols/linetext2.rb
|
74
72
|
- lib/protocols/smtpclient.rb
|
73
|
+
- lib/protocols/stomp.rb
|
74
|
+
- lib/protocols/header_and_content.rb
|
75
|
+
- lib/protocols/saslauth.rb
|
76
|
+
- lib/protocols/tcptest.rb
|
77
|
+
- lib/protocols/httpcli2.rb
|
78
|
+
- lib/protocols/buftok.rb
|
75
79
|
- lib/protocols/smtpserver.rb
|
76
80
|
- lib/evma/reactor.rb
|
77
81
|
- lib/evma/protocol.rb
|
@@ -88,24 +92,23 @@ files:
|
|
88
92
|
- ext/files.h
|
89
93
|
- ext/binder.h
|
90
94
|
- ext/sigs.h
|
91
|
-
- ext/project.h
|
92
95
|
- ext/eventmachine.h
|
96
|
+
- ext/epoll.cpp
|
97
|
+
- ext/project.h
|
93
98
|
- ext/page.cpp
|
99
|
+
- ext/eventmachine_cpp.h
|
94
100
|
- ext/emwin.cpp
|
101
|
+
- ext/epoll.h
|
95
102
|
- ext/page.h
|
96
103
|
- ext/emwin.h
|
97
104
|
- ext/rubymain.cpp
|
98
105
|
- ext/extconf.rb
|
99
106
|
- ext/cmain.cpp
|
100
107
|
- ext/ed.cpp
|
101
|
-
- ext/ed.h
|
102
|
-
- ext/eee
|
103
|
-
- ext/pipe.cpp
|
104
|
-
- ext/epoll.cpp
|
105
|
-
- ext/epoll.h
|
106
108
|
- ext/cplusplus.cpp
|
107
109
|
- ext/kb.cpp
|
108
|
-
- ext/
|
110
|
+
- ext/ed.h
|
111
|
+
- ext/pipe.cpp
|
109
112
|
- README
|
110
113
|
- RELEASE_NOTES
|
111
114
|
- COPYING
|
@@ -115,6 +118,7 @@ files:
|
|
115
118
|
- TODO
|
116
119
|
- KEYBOARD
|
117
120
|
- LIGHTWEIGHT_CONCURRENCY
|
121
|
+
- PURE_RUBY
|
118
122
|
- SMTP
|
119
123
|
- SPAWNED_PROCESSES
|
120
124
|
- DEFERRABLES
|
@@ -136,6 +140,7 @@ extra_rdoc_files:
|
|
136
140
|
- TODO
|
137
141
|
- KEYBOARD
|
138
142
|
- LIGHTWEIGHT_CONCURRENCY
|
143
|
+
- PURE_RUBY
|
139
144
|
- SMTP
|
140
145
|
- SPAWNED_PROCESSES
|
141
146
|
- DEFERRABLES
|
data/ext/eee
DELETED
@@ -1,173 +0,0 @@
|
|
1
|
-
# $Id: extconf.rb 501 2007-08-18 18:32:16Z blackhedd $
|
2
|
-
#
|
3
|
-
#----------------------------------------------------------------------------
|
4
|
-
#
|
5
|
-
# Copyright (C) 2006-07 by Francis Cianfrocca. All Rights Reserved.
|
6
|
-
# Gmail: blackhedd
|
7
|
-
#
|
8
|
-
# This program is free software; you can redistribute it and/or modify
|
9
|
-
# it under the terms of either: 1) the GNU General Public License
|
10
|
-
# as published by the Free Software Foundation; either version 2 of the
|
11
|
-
# License, or (at your option) any later version; or 2) Ruby's License.
|
12
|
-
#
|
13
|
-
# See the file COPYING for complete licensing information.
|
14
|
-
#
|
15
|
-
#---------------------------------------------------------------------------
|
16
|
-
#
|
17
|
-
# extconf.rb for Ruby/EventMachine
|
18
|
-
# We have to munge LDSHARED because this code needs a C++ link.
|
19
|
-
#
|
20
|
-
|
21
|
-
require 'mkmf'
|
22
|
-
|
23
|
-
flags = []
|
24
|
-
|
25
|
-
case RUBY_PLATFORM.split('-',2)[1]
|
26
|
-
when 'mswin32', 'mingw32', 'bccwin32'
|
27
|
-
unless have_header('windows.h') and
|
28
|
-
have_header('winsock.h') and
|
29
|
-
have_library('kernel32') and
|
30
|
-
have_library('rpcrt4') and
|
31
|
-
have_library('gdi32')
|
32
|
-
exit
|
33
|
-
end
|
34
|
-
|
35
|
-
flags << "-D OS_WIN32"
|
36
|
-
flags << '-D BUILD_FOR_RUBY'
|
37
|
-
flags << "-EHs"
|
38
|
-
flags << "-GR"
|
39
|
-
|
40
|
-
dir_config('ssl')
|
41
|
-
if have_library('ssleay32') and
|
42
|
-
have_library('libeay32') and
|
43
|
-
have_header('openssl/ssl.h') and
|
44
|
-
have_header('openssl/err.h')
|
45
|
-
flags << '-D WITH_SSL'
|
46
|
-
else
|
47
|
-
flags << '-D WITHOUT_SSL'
|
48
|
-
end
|
49
|
-
|
50
|
-
when /solaris/
|
51
|
-
unless have_library('pthread') and
|
52
|
-
have_library('nsl') and
|
53
|
-
have_library('socket')
|
54
|
-
exit
|
55
|
-
end
|
56
|
-
|
57
|
-
flags << '-D OS_UNIX'
|
58
|
-
flags << '-D OS_SOLARIS8'
|
59
|
-
flags << '-D BUILD_FOR_RUBY'
|
60
|
-
|
61
|
-
dir_config('ssl')
|
62
|
-
if have_library('ssl') and
|
63
|
-
have_library('crypto') and
|
64
|
-
have_header('openssl/ssl.h') and
|
65
|
-
have_header('openssl/err.h')
|
66
|
-
flags << '-D WITH_SSL'
|
67
|
-
else
|
68
|
-
flags << '-D WITHOUT_SSL'
|
69
|
-
end
|
70
|
-
|
71
|
-
# on Unix we need a g++ link, not gcc.
|
72
|
-
CONFIG['LDSHARED'] = "$(CXX) -shared"
|
73
|
-
|
74
|
-
# Patch by Tim Pease, fixes SUNWspro compile problems.
|
75
|
-
if CONFIG['CC'] == 'cc'
|
76
|
-
$CFLAGS = CONFIG['CFLAGS'] = "-g -O2 -fPIC"
|
77
|
-
CONFIG['CCDLFLAGS'] = "-fPIC"
|
78
|
-
end
|
79
|
-
|
80
|
-
when /darwin/
|
81
|
-
flags << '-DOS_UNIX'
|
82
|
-
flags << '-DBUILD_FOR_RUBY'
|
83
|
-
|
84
|
-
dir_config('ssl')
|
85
|
-
if have_library('ssl') and
|
86
|
-
have_library('crypto') and
|
87
|
-
have_library('C') and
|
88
|
-
have_header('openssl/ssl.h') and
|
89
|
-
have_header('openssl/err.h')
|
90
|
-
flags << '-DWITH_SSL'
|
91
|
-
else
|
92
|
-
flags << '-DWITHOUT_SSL'
|
93
|
-
end
|
94
|
-
# on Unix we need a g++ link, not gcc.
|
95
|
-
# Ff line contributed by Daniel Harple.
|
96
|
-
CONFIG['LDSHARED'] = "$(CXX) " + CONFIG['LDSHARED'].split[1..-1].join(' ')
|
97
|
-
|
98
|
-
when /linux/
|
99
|
-
unless have_library('pthread')
|
100
|
-
exit
|
101
|
-
end
|
102
|
-
|
103
|
-
flags << '-DOS_UNIX'
|
104
|
-
flags << '-DBUILD_FOR_RUBY'
|
105
|
-
|
106
|
-
# Original epoll test is inadequate because 2.4 kernels have the header
|
107
|
-
# but not the code.
|
108
|
-
#flags << '-DHAVE_EPOLL' if have_header('sys/epoll.h')
|
109
|
-
if have_header('sys/epoll.h')
|
110
|
-
File.open("hasEpollTest.c", "w") {|f|
|
111
|
-
f.puts "#include <sys/epoll.h>"
|
112
|
-
f.puts "int main() { epoll_create(1024); return 0;}"
|
113
|
-
}
|
114
|
-
(e = system( "gcc hasEpollTest.c -o hasEpollTest " )) and (e = $?.to_i)
|
115
|
-
`rm -f hasEpollTest.c hasEpollTest`
|
116
|
-
flags << '-DHAVE_EPOLL' if e == 0
|
117
|
-
end
|
118
|
-
|
119
|
-
dir_config('ssl', "#{ENV['OPENSSL']}/include", ENV['OPENSSL'])
|
120
|
-
# Check for libcrypto twice, before and after ssl. That's because on some platforms
|
121
|
-
# and openssl versions, libssl will emit unresolved externals from crypto. It
|
122
|
-
# would be cleaner to simply check crypto first, but that doesn't always work in
|
123
|
-
# Ruby. The order we check them doesn't seem to control the order in which they're
|
124
|
-
# emitted into the link command. This is pretty weird, I have to admit.
|
125
|
-
if have_library('crypto') and
|
126
|
-
have_library('ssl') and
|
127
|
-
have_library('crypto') and
|
128
|
-
have_header('openssl/ssl.h') and
|
129
|
-
have_header('openssl/err.h')
|
130
|
-
flags << '-DWITH_SSL'
|
131
|
-
else
|
132
|
-
flags << '-DWITHOUT_SSL'
|
133
|
-
end
|
134
|
-
# on Unix we need a g++ link, not gcc.
|
135
|
-
CONFIG['LDSHARED'] = "$(CXX) -shared"
|
136
|
-
|
137
|
-
# Modify the mkmf constant LINK_SO so the generated shared object is stripped.
|
138
|
-
# You might think modifying CONFIG['LINK_SO'] would be a better way to do this,
|
139
|
-
# but it doesn't work because mkmf doesn't look at CONFIG['LINK_SO'] again after
|
140
|
-
# it initializes.
|
141
|
-
linkso = Object.send :remove_const, "LINK_SO"
|
142
|
-
LINK_SO = linkso + "; strip $@"
|
143
|
-
|
144
|
-
else
|
145
|
-
unless have_library('pthread')
|
146
|
-
exit
|
147
|
-
end
|
148
|
-
|
149
|
-
flags << '-DOS_UNIX'
|
150
|
-
flags << '-DBUILD_FOR_RUBY'
|
151
|
-
|
152
|
-
dir_config('ssl')
|
153
|
-
if have_library('ssl') and
|
154
|
-
have_library('crypto') and
|
155
|
-
have_header('openssl/ssl.h') and
|
156
|
-
have_header('openssl/err.h')
|
157
|
-
flags << '-DWITH_SSL'
|
158
|
-
else
|
159
|
-
flags << '-DWITHOUT_SSL'
|
160
|
-
end
|
161
|
-
# on Unix we need a g++ link, not gcc.
|
162
|
-
CONFIG['LDSHARED'] = "$(CXX) -shared"
|
163
|
-
|
164
|
-
end
|
165
|
-
|
166
|
-
if $CPPFLAGS
|
167
|
-
$CPPFLAGS += ' ' + flags.join(' ')
|
168
|
-
else
|
169
|
-
$CFLAGS += ' ' + flags.join(' ')
|
170
|
-
end
|
171
|
-
|
172
|
-
|
173
|
-
create_makefile "rubyeventmachine"
|