sensu-em 2.0.0-java
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +21 -0
- data/.travis.yml +12 -0
- data/.yardopts +7 -0
- data/CHANGELOG.md +33 -0
- data/GNU +281 -0
- data/Gemfile +2 -0
- data/LICENSE +60 -0
- data/README.md +109 -0
- data/Rakefile +20 -0
- data/docs/DocumentationGuidesIndex.md +27 -0
- data/docs/GettingStarted.md +521 -0
- data/docs/old/ChangeLog +211 -0
- data/docs/old/DEFERRABLES +246 -0
- data/docs/old/EPOLL +141 -0
- data/docs/old/INSTALL +13 -0
- data/docs/old/KEYBOARD +42 -0
- data/docs/old/LEGAL +25 -0
- data/docs/old/LIGHTWEIGHT_CONCURRENCY +130 -0
- data/docs/old/PURE_RUBY +75 -0
- data/docs/old/RELEASE_NOTES +94 -0
- data/docs/old/SMTP +4 -0
- data/docs/old/SPAWNED_PROCESSES +148 -0
- data/docs/old/TODO +8 -0
- data/eventmachine.gemspec +38 -0
- data/examples/guides/getting_started/01_eventmachine_echo_server.rb +18 -0
- data/examples/guides/getting_started/02_eventmachine_echo_server_that_recognizes_exit_command.rb +22 -0
- data/examples/guides/getting_started/03_simple_chat_server.rb +149 -0
- data/examples/guides/getting_started/04_simple_chat_server_step_one.rb +27 -0
- data/examples/guides/getting_started/05_simple_chat_server_step_two.rb +43 -0
- data/examples/guides/getting_started/06_simple_chat_server_step_three.rb +98 -0
- data/examples/guides/getting_started/07_simple_chat_server_step_four.rb +121 -0
- data/examples/guides/getting_started/08_simple_chat_server_step_five.rb +141 -0
- data/examples/old/ex_channel.rb +43 -0
- data/examples/old/ex_queue.rb +2 -0
- data/examples/old/ex_tick_loop_array.rb +15 -0
- data/examples/old/ex_tick_loop_counter.rb +32 -0
- data/examples/old/helper.rb +2 -0
- data/ext/binder.cpp +124 -0
- data/ext/binder.h +46 -0
- data/ext/cmain.cpp +887 -0
- data/ext/ed.cpp +1988 -0
- data/ext/ed.h +422 -0
- data/ext/em.cpp +2352 -0
- data/ext/em.h +253 -0
- data/ext/eventmachine.h +128 -0
- data/ext/extconf.rb +179 -0
- data/ext/fastfilereader/extconf.rb +103 -0
- data/ext/fastfilereader/mapper.cpp +214 -0
- data/ext/fastfilereader/mapper.h +59 -0
- data/ext/fastfilereader/rubymain.cpp +127 -0
- data/ext/kb.cpp +79 -0
- data/ext/page.cpp +107 -0
- data/ext/page.h +51 -0
- data/ext/pipe.cpp +347 -0
- data/ext/project.h +161 -0
- data/ext/rubymain.cpp +1318 -0
- data/ext/ssl.cpp +468 -0
- data/ext/ssl.h +94 -0
- data/java/.classpath +6 -0
- data/java/.gitignore +1 -0
- data/java/.project +17 -0
- data/java/src/com/rubyeventmachine/DatagramPacket.java +13 -0
- data/java/src/com/rubyeventmachine/EmReactor.java +529 -0
- data/java/src/com/rubyeventmachine/EmReactorException.java +40 -0
- data/java/src/com/rubyeventmachine/EventCallback.java +7 -0
- data/java/src/com/rubyeventmachine/EventCode.java +26 -0
- data/java/src/com/rubyeventmachine/EventableChannel.java +130 -0
- data/java/src/com/rubyeventmachine/EventableDatagramChannel.java +180 -0
- data/java/src/com/rubyeventmachine/EventableSocketChannel.java +405 -0
- data/java/src/com/rubyeventmachine/SslBox.java +310 -0
- data/lib/em/buftok.rb +110 -0
- data/lib/em/callback.rb +58 -0
- data/lib/em/channel.rb +64 -0
- data/lib/em/completion.rb +304 -0
- data/lib/em/connection.rb +712 -0
- data/lib/em/deferrable/pool.rb +2 -0
- data/lib/em/deferrable.rb +210 -0
- data/lib/em/file_watch.rb +73 -0
- data/lib/em/future.rb +61 -0
- data/lib/em/iterator.rb +231 -0
- data/lib/em/messages.rb +66 -0
- data/lib/em/pool.rb +151 -0
- data/lib/em/process_watch.rb +45 -0
- data/lib/em/processes.rb +123 -0
- data/lib/em/protocols/header_and_content.rb +138 -0
- data/lib/em/protocols/httpclient.rb +279 -0
- data/lib/em/protocols/httpclient2.rb +600 -0
- data/lib/em/protocols/line_and_text.rb +125 -0
- data/lib/em/protocols/line_protocol.rb +29 -0
- data/lib/em/protocols/linetext2.rb +161 -0
- data/lib/em/protocols/memcache.rb +331 -0
- data/lib/em/protocols/object_protocol.rb +46 -0
- data/lib/em/protocols/postgres3.rb +246 -0
- data/lib/em/protocols/saslauth.rb +175 -0
- data/lib/em/protocols/smtpclient.rb +365 -0
- data/lib/em/protocols/smtpserver.rb +643 -0
- data/lib/em/protocols/socks4.rb +66 -0
- data/lib/em/protocols/stomp.rb +205 -0
- data/lib/em/protocols/tcptest.rb +54 -0
- data/lib/em/protocols.rb +37 -0
- data/lib/em/pure_ruby.rb +1017 -0
- data/lib/em/queue.rb +71 -0
- data/lib/em/resolver.rb +209 -0
- data/lib/em/spawnable.rb +84 -0
- data/lib/em/streamer.rb +118 -0
- data/lib/em/threaded_resource.rb +90 -0
- data/lib/em/tick_loop.rb +85 -0
- data/lib/em/timers.rb +61 -0
- data/lib/em/version.rb +3 -0
- data/lib/eventmachine.rb +1553 -0
- data/lib/jeventmachine.rb +321 -0
- data/lib/rubyeventmachine.jar +0 -0
- data/rakelib/cpp.rake_example +77 -0
- data/rakelib/package.rake +98 -0
- data/rakelib/test.rake +8 -0
- data/tests/client.crt +31 -0
- data/tests/client.key +51 -0
- data/tests/em_test_helper.rb +64 -0
- data/tests/server.crt +36 -0
- data/tests/server.key +51 -0
- data/tests/test_attach.rb +150 -0
- data/tests/test_basic.rb +294 -0
- data/tests/test_channel.rb +62 -0
- data/tests/test_completion.rb +177 -0
- data/tests/test_connection_count.rb +53 -0
- data/tests/test_defer.rb +18 -0
- data/tests/test_deferrable.rb +35 -0
- data/tests/test_epoll.rb +145 -0
- data/tests/test_error_handler.rb +38 -0
- data/tests/test_exc.rb +28 -0
- data/tests/test_file_watch.rb +65 -0
- data/tests/test_futures.rb +170 -0
- data/tests/test_get_sock_opt.rb +37 -0
- data/tests/test_handler_check.rb +35 -0
- data/tests/test_hc.rb +155 -0
- data/tests/test_httpclient.rb +190 -0
- data/tests/test_httpclient2.rb +133 -0
- data/tests/test_idle_connection.rb +25 -0
- data/tests/test_inactivity_timeout.rb +54 -0
- data/tests/test_iterator.rb +97 -0
- data/tests/test_kb.rb +34 -0
- data/tests/test_line_protocol.rb +33 -0
- data/tests/test_ltp.rb +138 -0
- data/tests/test_ltp2.rb +288 -0
- data/tests/test_next_tick.rb +104 -0
- data/tests/test_object_protocol.rb +36 -0
- data/tests/test_pause.rb +102 -0
- data/tests/test_pending_connect_timeout.rb +52 -0
- data/tests/test_pool.rb +194 -0
- data/tests/test_process_watch.rb +48 -0
- data/tests/test_processes.rb +128 -0
- data/tests/test_proxy_connection.rb +180 -0
- data/tests/test_pure.rb +88 -0
- data/tests/test_queue.rb +50 -0
- data/tests/test_resolver.rb +55 -0
- data/tests/test_running.rb +14 -0
- data/tests/test_sasl.rb +47 -0
- data/tests/test_send_file.rb +217 -0
- data/tests/test_servers.rb +33 -0
- data/tests/test_set_sock_opt.rb +37 -0
- data/tests/test_shutdown_hooks.rb +23 -0
- data/tests/test_smtpclient.rb +55 -0
- data/tests/test_smtpserver.rb +57 -0
- data/tests/test_spawn.rb +293 -0
- data/tests/test_ssl_args.rb +78 -0
- data/tests/test_ssl_echo_data.rb +60 -0
- data/tests/test_ssl_methods.rb +56 -0
- data/tests/test_ssl_verify.rb +82 -0
- data/tests/test_stomp.rb +37 -0
- data/tests/test_system.rb +42 -0
- data/tests/test_threaded_resource.rb +53 -0
- data/tests/test_tick_loop.rb +59 -0
- data/tests/test_timers.rb +123 -0
- data/tests/test_ud.rb +8 -0
- data/tests/test_unbind_reason.rb +48 -0
- metadata +297 -0
data/ext/em.h
ADDED
@@ -0,0 +1,253 @@
|
|
1
|
+
/*****************************************************************************
|
2
|
+
|
3
|
+
$Id$
|
4
|
+
|
5
|
+
File: em.h
|
6
|
+
Date: 06Apr06
|
7
|
+
|
8
|
+
Copyright (C) 2006-07 by Francis Cianfrocca. All Rights Reserved.
|
9
|
+
Gmail: blackhedd
|
10
|
+
|
11
|
+
This program is free software; you can redistribute it and/or modify
|
12
|
+
it under the terms of either: 1) the GNU General Public License
|
13
|
+
as published by the Free Software Foundation; either version 2 of the
|
14
|
+
License, or (at your option) any later version; or 2) Ruby's License.
|
15
|
+
|
16
|
+
See the file COPYING for complete licensing information.
|
17
|
+
|
18
|
+
*****************************************************************************/
|
19
|
+
|
20
|
+
#ifndef __EventMachine__H_
|
21
|
+
#define __EventMachine__H_
|
22
|
+
|
23
|
+
#ifdef BUILD_FOR_RUBY
|
24
|
+
#include <ruby.h>
|
25
|
+
|
26
|
+
#ifdef HAVE_RB_THREAD_FD_SELECT
|
27
|
+
#define EmSelect rb_thread_fd_select
|
28
|
+
#else
|
29
|
+
#define EmSelect rb_thread_select
|
30
|
+
#endif
|
31
|
+
|
32
|
+
#ifdef HAVE_RB_THREAD_CALL_WITHOUT_GVL
|
33
|
+
#include <ruby/thread.h>
|
34
|
+
#endif
|
35
|
+
|
36
|
+
#ifdef HAVE_RB_WAIT_FOR_SINGLE_FD
|
37
|
+
#include <ruby/io.h>
|
38
|
+
#endif
|
39
|
+
|
40
|
+
#if defined(HAVE_RBTRAP)
|
41
|
+
#include <rubysig.h>
|
42
|
+
#elif defined(HAVE_RB_ENABLE_INTERRUPT)
|
43
|
+
extern "C" {
|
44
|
+
void rb_enable_interrupt(void);
|
45
|
+
void rb_disable_interrupt(void);
|
46
|
+
}
|
47
|
+
|
48
|
+
#define TRAP_BEG rb_enable_interrupt()
|
49
|
+
#define TRAP_END do { rb_disable_interrupt(); rb_thread_check_ints(); } while(0)
|
50
|
+
#else
|
51
|
+
#define TRAP_BEG
|
52
|
+
#define TRAP_END
|
53
|
+
#endif
|
54
|
+
|
55
|
+
// 1.9.0 compat
|
56
|
+
#ifndef RUBY_UBF_IO
|
57
|
+
#define RUBY_UBF_IO RB_UBF_DFL
|
58
|
+
#endif
|
59
|
+
#ifndef RSTRING_PTR
|
60
|
+
#define RSTRING_PTR(str) RSTRING(str)->ptr
|
61
|
+
#endif
|
62
|
+
#ifndef RSTRING_LEN
|
63
|
+
#define RSTRING_LEN(str) RSTRING(str)->len
|
64
|
+
#endif
|
65
|
+
#ifndef RSTRING_LENINT
|
66
|
+
#define RSTRING_LENINT(str) RSTRING_LEN(str)
|
67
|
+
#endif
|
68
|
+
#else
|
69
|
+
#define EmSelect select
|
70
|
+
#endif
|
71
|
+
|
72
|
+
class EventableDescriptor;
|
73
|
+
class InotifyDescriptor;
|
74
|
+
|
75
|
+
|
76
|
+
/********************
|
77
|
+
class EventMachine_t
|
78
|
+
********************/
|
79
|
+
|
80
|
+
class EventMachine_t
|
81
|
+
{
|
82
|
+
public:
|
83
|
+
static int GetMaxTimerCount();
|
84
|
+
static void SetMaxTimerCount (int);
|
85
|
+
|
86
|
+
public:
|
87
|
+
EventMachine_t (EMCallback);
|
88
|
+
virtual ~EventMachine_t();
|
89
|
+
|
90
|
+
void Run();
|
91
|
+
void ScheduleHalt();
|
92
|
+
void SignalLoopBreaker();
|
93
|
+
const unsigned long InstallOneshotTimer (int);
|
94
|
+
const unsigned long ConnectToServer (const char *, int, const char *, int);
|
95
|
+
const unsigned long ConnectToUnixServer (const char *);
|
96
|
+
|
97
|
+
const unsigned long CreateTcpServer (const char *, int);
|
98
|
+
const unsigned long OpenDatagramSocket (const char *, int);
|
99
|
+
const unsigned long CreateUnixDomainServer (const char*);
|
100
|
+
const unsigned long AttachSD (int);
|
101
|
+
const unsigned long OpenKeyboard();
|
102
|
+
//const char *Popen (const char*, const char*);
|
103
|
+
const unsigned long Socketpair (char* const*);
|
104
|
+
|
105
|
+
void Add (EventableDescriptor*);
|
106
|
+
void Modify (EventableDescriptor*);
|
107
|
+
void Deregister (EventableDescriptor*);
|
108
|
+
|
109
|
+
const unsigned long AttachFD (int, bool);
|
110
|
+
int DetachFD (EventableDescriptor*);
|
111
|
+
|
112
|
+
void ArmKqueueWriter (EventableDescriptor*);
|
113
|
+
void ArmKqueueReader (EventableDescriptor*);
|
114
|
+
|
115
|
+
void SetTimerQuantum (int);
|
116
|
+
static void SetuidString (const char*);
|
117
|
+
static int SetRlimitNofile (int);
|
118
|
+
|
119
|
+
pid_t SubprocessPid;
|
120
|
+
int SubprocessExitStatus;
|
121
|
+
|
122
|
+
int GetConnectionCount();
|
123
|
+
float GetHeartbeatInterval();
|
124
|
+
int SetHeartbeatInterval(float);
|
125
|
+
|
126
|
+
const unsigned long WatchFile (const char*);
|
127
|
+
void UnwatchFile (int);
|
128
|
+
void UnwatchFile (const unsigned long);
|
129
|
+
|
130
|
+
#ifdef HAVE_KQUEUE
|
131
|
+
void _HandleKqueueFileEvent (struct kevent*);
|
132
|
+
void _RegisterKqueueFileEvent(int);
|
133
|
+
#endif
|
134
|
+
|
135
|
+
const unsigned long WatchPid (int);
|
136
|
+
void UnwatchPid (int);
|
137
|
+
void UnwatchPid (const unsigned long);
|
138
|
+
|
139
|
+
#ifdef HAVE_KQUEUE
|
140
|
+
void _HandleKqueuePidEvent (struct kevent*);
|
141
|
+
#endif
|
142
|
+
|
143
|
+
uint64_t GetCurrentLoopTime() { return MyCurrentLoopTime; }
|
144
|
+
|
145
|
+
// Temporary:
|
146
|
+
void _UseEpoll();
|
147
|
+
void _UseKqueue();
|
148
|
+
|
149
|
+
bool UsingKqueue() { return bKqueue; }
|
150
|
+
bool UsingEpoll() { return bEpoll; }
|
151
|
+
|
152
|
+
void QueueHeartbeat(EventableDescriptor*);
|
153
|
+
void ClearHeartbeat(uint64_t, EventableDescriptor*);
|
154
|
+
|
155
|
+
uint64_t GetRealTime();
|
156
|
+
|
157
|
+
private:
|
158
|
+
void _RunOnce();
|
159
|
+
void _RunTimers();
|
160
|
+
void _UpdateTime();
|
161
|
+
void _AddNewDescriptors();
|
162
|
+
void _ModifyDescriptors();
|
163
|
+
void _InitializeLoopBreaker();
|
164
|
+
void _CleanupSockets();
|
165
|
+
|
166
|
+
void _RunSelectOnce();
|
167
|
+
void _RunEpollOnce();
|
168
|
+
void _RunKqueueOnce();
|
169
|
+
|
170
|
+
void _ModifyEpollEvent (EventableDescriptor*);
|
171
|
+
void _DispatchHeartbeats();
|
172
|
+
timeval _TimeTilNextEvent();
|
173
|
+
void _CleanBadDescriptors();
|
174
|
+
|
175
|
+
public:
|
176
|
+
void _ReadLoopBreaker();
|
177
|
+
void _ReadInotifyEvents();
|
178
|
+
int NumCloseScheduled;
|
179
|
+
|
180
|
+
private:
|
181
|
+
enum {
|
182
|
+
MaxEpollDescriptors = 64*1024,
|
183
|
+
MaxEvents = 4096
|
184
|
+
};
|
185
|
+
int HeartbeatInterval;
|
186
|
+
EMCallback EventCallback;
|
187
|
+
|
188
|
+
class Timer_t: public Bindable_t {
|
189
|
+
};
|
190
|
+
|
191
|
+
multimap<uint64_t, Timer_t> Timers;
|
192
|
+
multimap<uint64_t, EventableDescriptor*> Heartbeats;
|
193
|
+
map<int, Bindable_t*> Files;
|
194
|
+
map<int, Bindable_t*> Pids;
|
195
|
+
vector<EventableDescriptor*> Descriptors;
|
196
|
+
vector<EventableDescriptor*> NewDescriptors;
|
197
|
+
set<EventableDescriptor*> ModifiedDescriptors;
|
198
|
+
|
199
|
+
uint64_t NextHeartbeatTime;
|
200
|
+
|
201
|
+
int LoopBreakerReader;
|
202
|
+
int LoopBreakerWriter;
|
203
|
+
#ifdef OS_WIN32
|
204
|
+
struct sockaddr_in LoopBreakerTarget;
|
205
|
+
#endif
|
206
|
+
|
207
|
+
timeval Quantum;
|
208
|
+
|
209
|
+
uint64_t MyCurrentLoopTime;
|
210
|
+
|
211
|
+
#ifdef OS_WIN32
|
212
|
+
unsigned TickCountTickover;
|
213
|
+
unsigned LastTickCount;
|
214
|
+
#endif
|
215
|
+
|
216
|
+
private:
|
217
|
+
bool bTerminateSignalReceived;
|
218
|
+
|
219
|
+
bool bEpoll;
|
220
|
+
int epfd; // Epoll file-descriptor
|
221
|
+
#ifdef HAVE_EPOLL
|
222
|
+
struct epoll_event epoll_events [MaxEvents];
|
223
|
+
#endif
|
224
|
+
|
225
|
+
bool bKqueue;
|
226
|
+
int kqfd; // Kqueue file-descriptor
|
227
|
+
#ifdef HAVE_KQUEUE
|
228
|
+
struct kevent Karray [MaxEvents];
|
229
|
+
#endif
|
230
|
+
|
231
|
+
InotifyDescriptor *inotify; // pollable descriptor for our inotify instance
|
232
|
+
};
|
233
|
+
|
234
|
+
|
235
|
+
/*******************
|
236
|
+
struct SelectData_t
|
237
|
+
*******************/
|
238
|
+
|
239
|
+
struct SelectData_t
|
240
|
+
{
|
241
|
+
SelectData_t();
|
242
|
+
|
243
|
+
int _Select();
|
244
|
+
|
245
|
+
int maxsocket;
|
246
|
+
fd_set fdreads;
|
247
|
+
fd_set fdwrites;
|
248
|
+
fd_set fderrors;
|
249
|
+
timeval tv;
|
250
|
+
int nSockets;
|
251
|
+
};
|
252
|
+
|
253
|
+
#endif // __EventMachine__H_
|
data/ext/eventmachine.h
ADDED
@@ -0,0 +1,128 @@
|
|
1
|
+
/*****************************************************************************
|
2
|
+
|
3
|
+
$Id$
|
4
|
+
|
5
|
+
File: eventmachine.h
|
6
|
+
Date: 15Apr06
|
7
|
+
|
8
|
+
Copyright (C) 2006-07 by Francis Cianfrocca. All Rights Reserved.
|
9
|
+
Gmail: blackhedd
|
10
|
+
|
11
|
+
This program is free software; you can redistribute it and/or modify
|
12
|
+
it under the terms of either: 1) the GNU General Public License
|
13
|
+
as published by the Free Software Foundation; either version 2 of the
|
14
|
+
License, or (at your option) any later version; or 2) Ruby's License.
|
15
|
+
|
16
|
+
See the file COPYING for complete licensing information.
|
17
|
+
|
18
|
+
*****************************************************************************/
|
19
|
+
|
20
|
+
#ifndef __EVMA_EventMachine__H_
|
21
|
+
#define __EVMA_EventMachine__H_
|
22
|
+
|
23
|
+
#if __cplusplus
|
24
|
+
extern "C" {
|
25
|
+
#endif
|
26
|
+
|
27
|
+
enum { // Event names
|
28
|
+
EM_TIMER_FIRED = 100,
|
29
|
+
EM_CONNECTION_READ = 101,
|
30
|
+
EM_CONNECTION_UNBOUND = 102,
|
31
|
+
EM_CONNECTION_ACCEPTED = 103,
|
32
|
+
EM_CONNECTION_COMPLETED = 104,
|
33
|
+
EM_LOOPBREAK_SIGNAL = 105,
|
34
|
+
EM_CONNECTION_NOTIFY_READABLE = 106,
|
35
|
+
EM_CONNECTION_NOTIFY_WRITABLE = 107,
|
36
|
+
EM_SSL_HANDSHAKE_COMPLETED = 108,
|
37
|
+
EM_SSL_VERIFY = 109,
|
38
|
+
EM_PROXY_TARGET_UNBOUND = 110,
|
39
|
+
EM_PROXY_COMPLETED = 111
|
40
|
+
|
41
|
+
};
|
42
|
+
|
43
|
+
void evma_initialize_library (EMCallback);
|
44
|
+
void evma_run_machine();
|
45
|
+
void evma_release_library();
|
46
|
+
const unsigned long evma_install_oneshot_timer (int seconds);
|
47
|
+
const unsigned long evma_connect_to_server (const char *bind_addr, int bind_port, const char *server, int port);
|
48
|
+
const unsigned long evma_connect_to_unix_server (const char *server);
|
49
|
+
|
50
|
+
const unsigned long evma_attach_fd (int file_descriptor, int watch_mode);
|
51
|
+
int evma_detach_fd (const unsigned long binding);
|
52
|
+
int evma_get_file_descriptor (const unsigned long binding);
|
53
|
+
int evma_is_notify_readable (const unsigned long binding);
|
54
|
+
void evma_set_notify_readable (const unsigned long binding, int mode);
|
55
|
+
int evma_is_notify_writable (const unsigned long binding);
|
56
|
+
void evma_set_notify_writable (const unsigned long binding, int mode);
|
57
|
+
|
58
|
+
int evma_pause(const unsigned long binding);
|
59
|
+
int evma_is_paused(const unsigned long binding);
|
60
|
+
int evma_resume(const unsigned long binding);
|
61
|
+
|
62
|
+
int evma_num_close_scheduled();
|
63
|
+
|
64
|
+
void evma_stop_tcp_server (const unsigned long signature);
|
65
|
+
const unsigned long evma_create_tcp_server (const char *address, int port);
|
66
|
+
const unsigned long evma_create_unix_domain_server (const char *filename);
|
67
|
+
const unsigned long evma_attach_sd (int sd);
|
68
|
+
const unsigned long evma_open_datagram_socket (const char *server, int port);
|
69
|
+
const unsigned long evma_open_keyboard();
|
70
|
+
void evma_set_tls_parms (const unsigned long binding, const char *privatekey_filename, const char *certchain_filenane, int verify_peer);
|
71
|
+
void evma_start_tls (const unsigned long binding);
|
72
|
+
|
73
|
+
#ifdef WITH_SSL
|
74
|
+
X509 *evma_get_peer_cert (const unsigned long binding);
|
75
|
+
void evma_accept_ssl_peer (const unsigned long binding);
|
76
|
+
#endif
|
77
|
+
|
78
|
+
int evma_get_peername (const unsigned long binding, struct sockaddr*, socklen_t*);
|
79
|
+
int evma_get_sockname (const unsigned long binding, struct sockaddr*, socklen_t*);
|
80
|
+
int evma_get_subprocess_pid (const unsigned long binding, pid_t*);
|
81
|
+
int evma_get_subprocess_status (const unsigned long binding, int*);
|
82
|
+
int evma_get_connection_count();
|
83
|
+
int evma_send_data_to_connection (const unsigned long binding, const char *data, int data_length);
|
84
|
+
int evma_send_datagram (const unsigned long binding, const char *data, int data_length, const char *address, int port);
|
85
|
+
float evma_get_comm_inactivity_timeout (const unsigned long binding);
|
86
|
+
int evma_set_comm_inactivity_timeout (const unsigned long binding, float value);
|
87
|
+
float evma_get_pending_connect_timeout (const unsigned long binding);
|
88
|
+
int evma_set_pending_connect_timeout (const unsigned long binding, float value);
|
89
|
+
int evma_get_outbound_data_size (const unsigned long binding);
|
90
|
+
uint64_t evma_get_last_activity_time (const unsigned long);
|
91
|
+
int evma_send_file_data_to_connection (const unsigned long binding, const char *filename);
|
92
|
+
|
93
|
+
void evma_close_connection (const unsigned long binding, int after_writing);
|
94
|
+
int evma_report_connection_error_status (const unsigned long binding);
|
95
|
+
void evma_signal_loopbreak();
|
96
|
+
void evma_set_timer_quantum (int);
|
97
|
+
int evma_get_max_timer_count();
|
98
|
+
void evma_set_max_timer_count (int);
|
99
|
+
void evma_setuid_string (const char *username);
|
100
|
+
void evma_stop_machine();
|
101
|
+
float evma_get_heartbeat_interval();
|
102
|
+
int evma_set_heartbeat_interval(float);
|
103
|
+
|
104
|
+
const unsigned long evma_popen (char * const*cmd_strings);
|
105
|
+
|
106
|
+
const unsigned long evma_watch_filename (const char *fname);
|
107
|
+
void evma_unwatch_filename (const unsigned long);
|
108
|
+
|
109
|
+
const unsigned long evma_watch_pid (int);
|
110
|
+
void evma_unwatch_pid (const unsigned long);
|
111
|
+
|
112
|
+
void evma_start_proxy(const unsigned long, const unsigned long, const unsigned long, const unsigned long);
|
113
|
+
void evma_stop_proxy(const unsigned long);
|
114
|
+
unsigned long evma_proxied_bytes(const unsigned long);
|
115
|
+
|
116
|
+
int evma_set_rlimit_nofile (int n_files);
|
117
|
+
|
118
|
+
void evma_set_epoll (int use);
|
119
|
+
void evma_set_kqueue (int use);
|
120
|
+
|
121
|
+
uint64_t evma_get_current_loop_time();
|
122
|
+
#if __cplusplus
|
123
|
+
}
|
124
|
+
#endif
|
125
|
+
|
126
|
+
|
127
|
+
#endif // __EventMachine__H_
|
128
|
+
|
data/ext/extconf.rb
ADDED
@@ -0,0 +1,179 @@
|
|
1
|
+
require 'fileutils'
|
2
|
+
require 'mkmf'
|
3
|
+
|
4
|
+
def check_libs libs = [], fatal = false
|
5
|
+
libs.all? { |lib| have_library(lib) || (abort("could not find library: #{lib}") if fatal) }
|
6
|
+
end
|
7
|
+
|
8
|
+
def check_heads heads = [], fatal = false
|
9
|
+
heads.all? { |head| have_header(head) || (abort("could not find header: #{head}") if fatal)}
|
10
|
+
end
|
11
|
+
|
12
|
+
def add_define(name)
|
13
|
+
$defs.push("-D#{name}")
|
14
|
+
end
|
15
|
+
|
16
|
+
##
|
17
|
+
# OpenSSL:
|
18
|
+
|
19
|
+
# override append_library, so it actually appends (instead of prepending)
|
20
|
+
# this fixes issues with linking ssl, since libcrypto depends on symbols in libssl
|
21
|
+
def append_library(libs, lib)
|
22
|
+
libs + " " + format(LIBARG, lib)
|
23
|
+
end
|
24
|
+
|
25
|
+
def manual_ssl_config
|
26
|
+
ssl_libs_heads_args = {
|
27
|
+
:unix => [%w[ssl crypto], %w[openssl/ssl.h openssl/err.h]],
|
28
|
+
:mswin => [%w[ssleay32 eay32], %w[openssl/ssl.h openssl/err.h]],
|
29
|
+
}
|
30
|
+
|
31
|
+
dc_flags = ['ssl']
|
32
|
+
dc_flags += ["#{ENV['OPENSSL']}/include", ENV['OPENSSL']] if /linux/ =~ RUBY_PLATFORM and ENV['OPENSSL']
|
33
|
+
|
34
|
+
libs, heads = case RUBY_PLATFORM
|
35
|
+
when /mswin/ ; ssl_libs_heads_args[:mswin]
|
36
|
+
else ssl_libs_heads_args[:unix]
|
37
|
+
end
|
38
|
+
dir_config(*dc_flags)
|
39
|
+
check_libs(libs) and check_heads(heads)
|
40
|
+
end
|
41
|
+
|
42
|
+
if ENV['CROSS_COMPILING']
|
43
|
+
openssl_version = ENV.fetch("OPENSSL_VERSION", "1.0.0j")
|
44
|
+
openssl_dir = File.expand_path("~/.rake-compiler/builds/openssl-#{openssl_version}/")
|
45
|
+
if File.exists?(openssl_dir)
|
46
|
+
FileUtils.mkdir_p Dir.pwd+"/openssl/"
|
47
|
+
FileUtils.cp Dir[openssl_dir+"/include/openssl/*.h"], Dir.pwd+"/openssl/", :verbose => true
|
48
|
+
FileUtils.cp Dir[openssl_dir+"/lib*.a"], Dir.pwd, :verbose => true
|
49
|
+
$INCFLAGS << " -I#{Dir.pwd}" # for the openssl headers
|
50
|
+
else
|
51
|
+
STDERR.puts
|
52
|
+
STDERR.puts "**************************************************************************************"
|
53
|
+
STDERR.puts "**** Cross-compiled OpenSSL not found"
|
54
|
+
STDERR.puts "**** Run: hg clone http://bitbucket.org/ged/ruby-pg && cd ruby-pg && rake openssl_libs"
|
55
|
+
STDERR.puts "**************************************************************************************"
|
56
|
+
STDERR.puts
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
# Try to use pkg_config first, fixes #73
|
61
|
+
if (!ENV['CROSS_COMPILING'] and pkg_config('openssl')) || manual_ssl_config
|
62
|
+
add_define "WITH_SSL"
|
63
|
+
else
|
64
|
+
add_define "WITHOUT_SSL"
|
65
|
+
end
|
66
|
+
|
67
|
+
add_define 'BUILD_FOR_RUBY'
|
68
|
+
add_define 'HAVE_RBTRAP' if have_var('rb_trap_immediate', ['ruby.h', 'rubysig.h'])
|
69
|
+
add_define "HAVE_TBR" if have_func('rb_thread_blocking_region')# and have_macro('RUBY_UBF_IO', 'ruby.h')
|
70
|
+
add_define "HAVE_RB_THREAD_CALL_WITHOUT_GVL" if have_header('ruby/thread.h') && have_func('rb_thread_call_without_gvl', 'ruby/thread.h')
|
71
|
+
add_define "HAVE_INOTIFY" if inotify = have_func('inotify_init', 'sys/inotify.h')
|
72
|
+
add_define "HAVE_OLD_INOTIFY" if !inotify && have_macro('__NR_inotify_init', 'sys/syscall.h')
|
73
|
+
add_define 'HAVE_WRITEV' if have_func('writev', 'sys/uio.h')
|
74
|
+
add_define 'HAVE_RB_THREAD_FD_SELECT' if have_func('rb_thread_fd_select')
|
75
|
+
|
76
|
+
have_func('rb_wait_for_single_fd')
|
77
|
+
have_func('rb_enable_interrupt')
|
78
|
+
have_func('rb_time_new')
|
79
|
+
|
80
|
+
# Minor platform details between *nix and Windows:
|
81
|
+
|
82
|
+
if RUBY_PLATFORM =~ /(mswin|mingw|bccwin)/
|
83
|
+
GNU_CHAIN = ENV['CROSS_COMPILING'] || $1 == 'mingw'
|
84
|
+
OS_WIN32 = true
|
85
|
+
add_define "OS_WIN32"
|
86
|
+
else
|
87
|
+
GNU_CHAIN = true
|
88
|
+
OS_UNIX = true
|
89
|
+
add_define 'OS_UNIX'
|
90
|
+
|
91
|
+
add_define "HAVE_KQUEUE" if have_header("sys/event.h") and have_header("sys/queue.h")
|
92
|
+
end
|
93
|
+
|
94
|
+
# Adjust number of file descriptors (FD) on Windows
|
95
|
+
|
96
|
+
if RbConfig::CONFIG["host_os"] =~ /mingw/
|
97
|
+
found = RbConfig::CONFIG.values_at("CFLAGS", "CPPFLAGS").
|
98
|
+
any? { |v| v.include?("FD_SETSIZE") }
|
99
|
+
|
100
|
+
add_define "FD_SETSIZE=32767" unless found
|
101
|
+
end
|
102
|
+
|
103
|
+
# Main platform invariances:
|
104
|
+
|
105
|
+
case RUBY_PLATFORM
|
106
|
+
when /mswin32/, /mingw32/, /bccwin32/
|
107
|
+
check_heads(%w[windows.h winsock.h], true)
|
108
|
+
check_libs(%w[kernel32 rpcrt4 gdi32], true)
|
109
|
+
|
110
|
+
if GNU_CHAIN
|
111
|
+
CONFIG['LDSHAREDXX'] = "$(CXX) -shared -static-libgcc -static-libstdc++"
|
112
|
+
else
|
113
|
+
$defs.push "-EHs"
|
114
|
+
$defs.push "-GR"
|
115
|
+
end
|
116
|
+
|
117
|
+
when /solaris/
|
118
|
+
add_define 'OS_SOLARIS8'
|
119
|
+
check_libs(%w[nsl socket], true)
|
120
|
+
|
121
|
+
if CONFIG['CC'] == 'cc' and `cc -flags 2>&1` =~ /Sun/ # detect SUNWspro compiler
|
122
|
+
# SUN CHAIN
|
123
|
+
add_define 'CC_SUNWspro'
|
124
|
+
$preload = ["\nCXX = CC"] # hack a CXX= line into the makefile
|
125
|
+
$CFLAGS = CONFIG['CFLAGS'] = "-KPIC"
|
126
|
+
CONFIG['CCDLFLAGS'] = "-KPIC"
|
127
|
+
CONFIG['LDSHARED'] = "$(CXX) -G -KPIC -lCstd"
|
128
|
+
else
|
129
|
+
# GNU CHAIN
|
130
|
+
# on Unix we need a g++ link, not gcc.
|
131
|
+
CONFIG['LDSHARED'] = "$(CXX) -shared"
|
132
|
+
end
|
133
|
+
|
134
|
+
when /openbsd/
|
135
|
+
# OpenBSD branch contributed by Guillaume Sellier.
|
136
|
+
|
137
|
+
# on Unix we need a g++ link, not gcc. On OpenBSD, linking against libstdc++ have to be explicitly done for shared libs
|
138
|
+
CONFIG['LDSHARED'] = "$(CXX) -shared -lstdc++ -fPIC"
|
139
|
+
CONFIG['LDSHAREDXX'] = "$(CXX) -shared -lstdc++ -fPIC"
|
140
|
+
|
141
|
+
when /darwin/
|
142
|
+
# on Unix we need a g++ link, not gcc.
|
143
|
+
# Ff line contributed by Daniel Harple.
|
144
|
+
CONFIG['LDSHARED'] = "$(CXX) " + CONFIG['LDSHARED'].split[1..-1].join(' ')
|
145
|
+
|
146
|
+
when /linux/
|
147
|
+
add_define 'HAVE_EPOLL' if have_func('epoll_create', 'sys/epoll.h')
|
148
|
+
|
149
|
+
# on Unix we need a g++ link, not gcc.
|
150
|
+
CONFIG['LDSHARED'] = "$(CXX) -shared"
|
151
|
+
|
152
|
+
when /aix/
|
153
|
+
CONFIG['LDSHARED'] = "$(CXX) -shared -Wl,-G -Wl,-brtl"
|
154
|
+
|
155
|
+
when /cygwin/
|
156
|
+
# For rubies built with Cygwin, CXX may be set to CC, which is just
|
157
|
+
# a wrapper for gcc.
|
158
|
+
# This will compile, but it will not link to the C++ std library.
|
159
|
+
# Explicitly set CXX to use g++.
|
160
|
+
CONFIG['CXX'] = "g++"
|
161
|
+
# on Unix we need a g++ link, not gcc.
|
162
|
+
CONFIG['LDSHARED'] = "$(CXX) -shared"
|
163
|
+
|
164
|
+
else
|
165
|
+
# on Unix we need a g++ link, not gcc.
|
166
|
+
CONFIG['LDSHARED'] = "$(CXX) -shared"
|
167
|
+
end
|
168
|
+
|
169
|
+
|
170
|
+
# solaris c++ compiler doesn't have make_pair()
|
171
|
+
TRY_LINK.sub!('$(CC)', '$(CXX)')
|
172
|
+
add_define 'HAVE_MAKE_PAIR' if try_link(<<SRC, '-lstdc++')
|
173
|
+
#include <utility>
|
174
|
+
using namespace std;
|
175
|
+
int main(){ pair<const int,int> tuple = make_pair(1,2); }
|
176
|
+
SRC
|
177
|
+
TRY_LINK.sub!('$(CXX)', '$(CC)')
|
178
|
+
|
179
|
+
create_makefile "rubyeventmachine"
|
@@ -0,0 +1,103 @@
|
|
1
|
+
require 'mkmf'
|
2
|
+
|
3
|
+
def check_libs libs = [], fatal = false
|
4
|
+
libs.all? { |lib| have_library(lib) || (abort("could not find library: #{lib}") if fatal) }
|
5
|
+
end
|
6
|
+
|
7
|
+
def check_heads heads = [], fatal = false
|
8
|
+
heads.all? { |head| have_header(head) || (abort("could not find header: #{head}") if fatal)}
|
9
|
+
end
|
10
|
+
|
11
|
+
def add_define(name)
|
12
|
+
$defs.push("-D#{name}")
|
13
|
+
end
|
14
|
+
|
15
|
+
add_define 'BUILD_FOR_RUBY'
|
16
|
+
|
17
|
+
# Minor platform details between *nix and Windows:
|
18
|
+
|
19
|
+
if RUBY_PLATFORM =~ /(mswin|mingw|bccwin)/
|
20
|
+
GNU_CHAIN = ENV['CROSS_COMPILING'] || $1 == 'mingw'
|
21
|
+
OS_WIN32 = true
|
22
|
+
add_define "OS_WIN32"
|
23
|
+
else
|
24
|
+
GNU_CHAIN = true
|
25
|
+
OS_UNIX = true
|
26
|
+
add_define 'OS_UNIX'
|
27
|
+
end
|
28
|
+
|
29
|
+
# Adjust number of file descriptors (FD) on Windows
|
30
|
+
|
31
|
+
if RbConfig::CONFIG["host_os"] =~ /mingw/
|
32
|
+
found = RbConfig::CONFIG.values_at("CFLAGS", "CPPFLAGS").
|
33
|
+
any? { |v| v.include?("FD_SETSIZE") }
|
34
|
+
|
35
|
+
add_define "FD_SETSIZE=32767" unless found
|
36
|
+
end
|
37
|
+
|
38
|
+
# Main platform invariances:
|
39
|
+
|
40
|
+
case RUBY_PLATFORM
|
41
|
+
when /mswin32/, /mingw32/, /bccwin32/
|
42
|
+
check_heads(%w[windows.h winsock.h], true)
|
43
|
+
check_libs(%w[kernel32 rpcrt4 gdi32], true)
|
44
|
+
|
45
|
+
if GNU_CHAIN
|
46
|
+
CONFIG['LDSHAREDXX'] = "$(CXX) -shared -static-libgcc -static-libstdc++"
|
47
|
+
else
|
48
|
+
$defs.push "-EHs"
|
49
|
+
$defs.push "-GR"
|
50
|
+
end
|
51
|
+
|
52
|
+
when /solaris/
|
53
|
+
add_define 'OS_SOLARIS8'
|
54
|
+
check_libs(%w[nsl socket], true)
|
55
|
+
|
56
|
+
if CONFIG['CC'] == 'cc' and `cc -flags 2>&1` =~ /Sun/ # detect SUNWspro compiler
|
57
|
+
# SUN CHAIN
|
58
|
+
add_define 'CC_SUNWspro'
|
59
|
+
$preload = ["\nCXX = CC"] # hack a CXX= line into the makefile
|
60
|
+
$CFLAGS = CONFIG['CFLAGS'] = "-KPIC"
|
61
|
+
CONFIG['CCDLFLAGS'] = "-KPIC"
|
62
|
+
CONFIG['LDSHARED'] = "$(CXX) -G -KPIC -lCstd"
|
63
|
+
else
|
64
|
+
# GNU CHAIN
|
65
|
+
# on Unix we need a g++ link, not gcc.
|
66
|
+
CONFIG['LDSHARED'] = "$(CXX) -shared"
|
67
|
+
end
|
68
|
+
|
69
|
+
when /openbsd/
|
70
|
+
# OpenBSD branch contributed by Guillaume Sellier.
|
71
|
+
|
72
|
+
# on Unix we need a g++ link, not gcc. On OpenBSD, linking against libstdc++ have to be explicitly done for shared libs
|
73
|
+
CONFIG['LDSHARED'] = "$(CXX) -shared -lstdc++ -fPIC"
|
74
|
+
CONFIG['LDSHAREDXX'] = "$(CXX) -shared -lstdc++ -fPIC"
|
75
|
+
|
76
|
+
when /darwin/
|
77
|
+
# on Unix we need a g++ link, not gcc.
|
78
|
+
# Ff line contributed by Daniel Harple.
|
79
|
+
CONFIG['LDSHARED'] = "$(CXX) " + CONFIG['LDSHARED'].split[1..-1].join(' ')
|
80
|
+
|
81
|
+
when /linux/
|
82
|
+
# on Unix we need a g++ link, not gcc.
|
83
|
+
CONFIG['LDSHARED'] = "$(CXX) -shared"
|
84
|
+
|
85
|
+
when /aix/
|
86
|
+
# on Unix we need a g++ link, not gcc.
|
87
|
+
CONFIG['LDSHARED'] = "$(CXX) -shared -Wl,-G"
|
88
|
+
|
89
|
+
when /cygwin/
|
90
|
+
# For rubies built with Cygwin, CXX may be set to CC, which is just
|
91
|
+
# a wrapper for gcc.
|
92
|
+
# This will compile, but it will not link to the C++ std library.
|
93
|
+
# Explicitly set CXX to use g++.
|
94
|
+
CONFIG['CXX'] = "g++"
|
95
|
+
# on Unix we need a g++ link, not gcc.
|
96
|
+
CONFIG['LDSHARED'] = "$(CXX) -shared"
|
97
|
+
|
98
|
+
else
|
99
|
+
# on Unix we need a g++ link, not gcc.
|
100
|
+
CONFIG['LDSHARED'] = "$(CXX) -shared"
|
101
|
+
end
|
102
|
+
|
103
|
+
create_makefile "fastfilereaderext"
|