eventmachine 0.12.6-x86-mswin32-60 → 0.12.8-x86-mswin32-60
Sign up to get free protection for your applications and to get access to all the features.
- data/{docs/README → README} +21 -13
- data/Rakefile +14 -4
- data/docs/DEFERRABLES +0 -5
- data/docs/INSTALL +2 -4
- data/docs/LEGAL +1 -1
- data/docs/LIGHTWEIGHT_CONCURRENCY +0 -2
- data/docs/PURE_RUBY +0 -2
- data/docs/RELEASE_NOTES +0 -2
- data/docs/SMTP +0 -7
- data/docs/SPAWNED_PROCESSES +0 -4
- data/docs/TODO +0 -2
- data/eventmachine.gemspec +41 -32
- data/examples/ex_channel.rb +43 -0
- data/examples/ex_queue.rb +2 -0
- data/examples/helper.rb +2 -0
- data/ext/cmain.cpp +685 -586
- data/ext/cplusplus.cpp +15 -6
- data/ext/ed.cpp +1732 -1522
- data/ext/ed.h +407 -380
- data/ext/em.cpp +2263 -1937
- data/ext/em.h +223 -186
- data/ext/eventmachine.h +111 -98
- data/ext/eventmachine_cpp.h +1 -0
- data/ext/extconf.rb +4 -0
- data/ext/kb.cpp +81 -82
- data/ext/pipe.cpp +349 -351
- data/ext/project.h +21 -0
- data/ext/rubymain.cpp +1047 -847
- data/ext/ssl.cpp +38 -1
- data/ext/ssl.h +5 -1
- data/java/src/com/rubyeventmachine/Application.java +7 -3
- data/java/src/com/rubyeventmachine/EmReactor.java +16 -1
- data/java/src/com/rubyeventmachine/tests/ConnectTest.java +25 -3
- data/lib/{protocols → em}/buftok.rb +16 -5
- data/lib/em/callback.rb +26 -0
- data/lib/em/channel.rb +57 -0
- data/lib/em/connection.rb +505 -0
- data/lib/em/deferrable.rb +144 -165
- data/lib/em/file_watch.rb +54 -0
- data/lib/em/future.rb +24 -25
- data/lib/em/messages.rb +1 -1
- data/lib/em/process_watch.rb +44 -0
- data/lib/em/processes.rb +119 -113
- data/lib/em/protocols.rb +35 -0
- data/lib/em/protocols/header_and_content.rb +138 -0
- data/lib/em/protocols/httpclient.rb +263 -0
- data/lib/em/protocols/httpclient2.rb +582 -0
- data/lib/{protocols → em/protocols}/line_and_text.rb +2 -2
- data/lib/em/protocols/linetext2.rb +160 -0
- data/lib/{protocols → em/protocols}/memcache.rb +37 -7
- data/lib/em/protocols/object_protocol.rb +39 -0
- data/lib/em/protocols/postgres3.rb +247 -0
- data/lib/em/protocols/saslauth.rb +175 -0
- data/lib/em/protocols/smtpclient.rb +331 -0
- data/lib/em/protocols/smtpserver.rb +547 -0
- data/lib/em/protocols/stomp.rb +200 -0
- data/lib/{protocols → em/protocols}/tcptest.rb +21 -25
- data/lib/em/queue.rb +61 -0
- data/lib/em/spawnable.rb +53 -56
- data/lib/em/streamer.rb +92 -74
- data/lib/em/timers.rb +55 -0
- data/lib/em/version.rb +3 -0
- data/lib/eventmachine.rb +1636 -1926
- data/lib/evma.rb +1 -1
- data/lib/jeventmachine.rb +106 -101
- data/lib/pr_eventmachine.rb +47 -36
- data/tasks/project.rake +2 -1
- data/tests/client.crt +31 -0
- data/tests/client.key +51 -0
- data/tests/test_attach.rb +18 -0
- data/tests/test_basic.rb +285 -231
- data/tests/test_channel.rb +63 -0
- data/tests/test_connection_count.rb +2 -2
- data/tests/test_epoll.rb +162 -163
- data/tests/test_errors.rb +36 -36
- data/tests/test_exc.rb +22 -25
- data/tests/test_file_watch.rb +49 -0
- data/tests/test_futures.rb +77 -93
- data/tests/test_hc.rb +2 -2
- data/tests/test_httpclient.rb +55 -52
- data/tests/test_httpclient2.rb +153 -155
- data/tests/test_inactivity_timeout.rb +30 -0
- data/tests/test_kb.rb +8 -9
- data/tests/test_ltp2.rb +274 -277
- data/tests/test_next_tick.rb +135 -109
- data/tests/test_object_protocol.rb +37 -0
- data/tests/test_process_watch.rb +48 -0
- data/tests/test_processes.rb +128 -95
- data/tests/test_proxy_connection.rb +92 -0
- data/tests/test_pure.rb +1 -5
- data/tests/test_queue.rb +44 -0
- data/tests/test_running.rb +9 -14
- data/tests/test_sasl.rb +32 -34
- data/tests/test_send_file.rb +175 -176
- data/tests/test_servers.rb +37 -41
- data/tests/test_smtpserver.rb +47 -55
- data/tests/test_spawn.rb +284 -291
- data/tests/test_ssl_args.rb +1 -1
- data/tests/test_ssl_methods.rb +1 -1
- data/tests/test_ssl_verify.rb +82 -0
- data/tests/test_timers.rb +81 -88
- data/tests/test_ud.rb +0 -7
- data/tests/testem.rb +1 -1
- metadata +52 -36
- data/lib/em/eventable.rb +0 -39
- data/lib/eventmachine_version.rb +0 -31
- data/lib/protocols/header_and_content.rb +0 -129
- data/lib/protocols/httpcli2.rb +0 -803
- data/lib/protocols/httpclient.rb +0 -270
- data/lib/protocols/linetext2.rb +0 -161
- data/lib/protocols/postgres.rb +0 -261
- data/lib/protocols/saslauth.rb +0 -179
- data/lib/protocols/smtpclient.rb +0 -308
- data/lib/protocols/smtpserver.rb +0 -556
- data/lib/protocols/stomp.rb +0 -153
- data/tests/test_eventables.rb +0 -77
data/ext/project.h
CHANGED
@@ -102,6 +102,27 @@ using namespace std;
|
|
102
102
|
#include <sys/queue.h>
|
103
103
|
#endif
|
104
104
|
|
105
|
+
#ifdef HAVE_INOTIFY
|
106
|
+
#include <sys/inotify.h>
|
107
|
+
#endif
|
108
|
+
|
109
|
+
#ifdef HAVE_OLD_INOTIFY
|
110
|
+
#include <sys/syscall.h>
|
111
|
+
#include <linux/inotify.h>
|
112
|
+
static inline int inotify_init (void) { return syscall (__NR_inotify_init); }
|
113
|
+
static inline int inotify_add_watch (int fd, const char *name, __u32 mask) { return syscall (__NR_inotify_add_watch, fd, name, mask); }
|
114
|
+
static inline int inotify_rm_watch (int fd, __u32 wd) { return syscall (__NR_inotify_rm_watch, fd, wd); }
|
115
|
+
#define HAVE_INOTIFY 1
|
116
|
+
#endif
|
117
|
+
|
118
|
+
#ifdef HAVE_INOTIFY
|
119
|
+
#define INOTIFY_EVENT_SIZE (sizeof(struct inotify_event))
|
120
|
+
#endif
|
121
|
+
|
122
|
+
#ifdef HAVE_WRITEV
|
123
|
+
#include <sys/uio.h>
|
124
|
+
#endif
|
125
|
+
|
105
126
|
#include "binder.h"
|
106
127
|
#include "em.h"
|
107
128
|
#include "epoll.h"
|
data/ext/rubymain.cpp
CHANGED
@@ -1,847 +1,1047 @@
|
|
1
|
-
/*****************************************************************************
|
2
|
-
|
3
|
-
$Id$
|
4
|
-
|
5
|
-
File: rubymain.cpp
|
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
|
-
#include "project.h"
|
21
|
-
#include "eventmachine.h"
|
22
|
-
#include <ruby.h>
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
static VALUE
|
34
|
-
|
35
|
-
|
36
|
-
static VALUE
|
37
|
-
|
38
|
-
static VALUE
|
39
|
-
static VALUE
|
40
|
-
static VALUE
|
41
|
-
static VALUE
|
42
|
-
static VALUE
|
43
|
-
static VALUE
|
44
|
-
static VALUE
|
45
|
-
static VALUE
|
46
|
-
static VALUE
|
47
|
-
static VALUE
|
48
|
-
|
49
|
-
static VALUE
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
{
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
{
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
return
|
185
|
-
}
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
return
|
246
|
-
}
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
{
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
{
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
|
376
|
-
|
377
|
-
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
return
|
382
|
-
}
|
383
|
-
|
384
|
-
|
385
|
-
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
|
390
|
-
|
391
|
-
|
392
|
-
|
393
|
-
|
394
|
-
|
395
|
-
|
396
|
-
|
397
|
-
|
398
|
-
|
399
|
-
|
400
|
-
|
401
|
-
|
402
|
-
|
403
|
-
|
404
|
-
|
405
|
-
|
406
|
-
|
407
|
-
|
408
|
-
|
409
|
-
|
410
|
-
|
411
|
-
|
412
|
-
|
413
|
-
|
414
|
-
|
415
|
-
|
416
|
-
|
417
|
-
|
418
|
-
|
419
|
-
|
420
|
-
|
421
|
-
|
422
|
-
|
423
|
-
|
424
|
-
|
425
|
-
|
426
|
-
|
427
|
-
|
428
|
-
|
429
|
-
|
430
|
-
|
431
|
-
|
432
|
-
|
433
|
-
|
434
|
-
|
435
|
-
|
436
|
-
|
437
|
-
|
438
|
-
|
439
|
-
|
440
|
-
|
441
|
-
|
442
|
-
|
443
|
-
|
444
|
-
|
445
|
-
|
446
|
-
|
447
|
-
|
448
|
-
|
449
|
-
|
450
|
-
|
451
|
-
|
452
|
-
|
453
|
-
|
454
|
-
|
455
|
-
|
456
|
-
|
457
|
-
|
458
|
-
|
459
|
-
|
460
|
-
|
461
|
-
{
|
462
|
-
|
463
|
-
|
464
|
-
|
465
|
-
|
466
|
-
|
467
|
-
|
468
|
-
|
469
|
-
|
470
|
-
|
471
|
-
|
472
|
-
|
473
|
-
|
474
|
-
|
475
|
-
|
476
|
-
|
477
|
-
|
478
|
-
|
479
|
-
|
480
|
-
|
481
|
-
|
482
|
-
|
483
|
-
|
484
|
-
|
485
|
-
|
486
|
-
|
487
|
-
|
488
|
-
return
|
489
|
-
}
|
490
|
-
|
491
|
-
|
492
|
-
|
493
|
-
|
494
|
-
|
495
|
-
static VALUE
|
496
|
-
{
|
497
|
-
|
498
|
-
|
499
|
-
|
500
|
-
|
501
|
-
|
502
|
-
|
503
|
-
|
504
|
-
|
505
|
-
|
506
|
-
|
507
|
-
|
508
|
-
|
509
|
-
|
510
|
-
|
511
|
-
|
512
|
-
|
513
|
-
|
514
|
-
|
515
|
-
|
516
|
-
|
517
|
-
|
518
|
-
|
519
|
-
|
520
|
-
|
521
|
-
|
522
|
-
|
523
|
-
|
524
|
-
|
525
|
-
|
526
|
-
|
527
|
-
|
528
|
-
|
529
|
-
|
530
|
-
|
531
|
-
|
532
|
-
|
533
|
-
|
534
|
-
|
535
|
-
|
536
|
-
|
537
|
-
|
538
|
-
|
539
|
-
|
540
|
-
|
541
|
-
|
542
|
-
|
543
|
-
|
544
|
-
|
545
|
-
|
546
|
-
|
547
|
-
|
548
|
-
|
549
|
-
|
550
|
-
|
551
|
-
|
552
|
-
|
553
|
-
|
554
|
-
|
555
|
-
|
556
|
-
|
557
|
-
|
558
|
-
|
559
|
-
|
560
|
-
|
561
|
-
|
562
|
-
|
563
|
-
|
564
|
-
|
565
|
-
|
566
|
-
|
567
|
-
|
568
|
-
|
569
|
-
|
570
|
-
|
571
|
-
|
572
|
-
|
573
|
-
|
574
|
-
|
575
|
-
|
576
|
-
|
577
|
-
|
578
|
-
|
579
|
-
|
580
|
-
|
581
|
-
|
582
|
-
|
583
|
-
|
584
|
-
|
585
|
-
|
586
|
-
|
587
|
-
|
588
|
-
|
589
|
-
|
590
|
-
|
591
|
-
|
592
|
-
|
593
|
-
|
594
|
-
|
595
|
-
|
596
|
-
|
597
|
-
|
598
|
-
|
599
|
-
|
600
|
-
|
601
|
-
|
602
|
-
|
603
|
-
|
604
|
-
|
605
|
-
|
606
|
-
|
607
|
-
|
608
|
-
|
609
|
-
|
610
|
-
|
611
|
-
|
612
|
-
|
613
|
-
|
614
|
-
|
615
|
-
|
616
|
-
|
617
|
-
|
618
|
-
|
619
|
-
|
620
|
-
|
621
|
-
|
622
|
-
|
623
|
-
|
624
|
-
|
625
|
-
|
626
|
-
|
627
|
-
|
628
|
-
|
629
|
-
|
630
|
-
|
631
|
-
|
632
|
-
|
633
|
-
|
634
|
-
|
635
|
-
|
636
|
-
|
637
|
-
|
638
|
-
|
639
|
-
|
640
|
-
|
641
|
-
|
642
|
-
|
643
|
-
|
644
|
-
|
645
|
-
|
646
|
-
|
647
|
-
|
648
|
-
|
649
|
-
|
650
|
-
|
651
|
-
|
652
|
-
|
653
|
-
|
654
|
-
|
655
|
-
|
656
|
-
|
657
|
-
|
658
|
-
|
659
|
-
|
660
|
-
|
661
|
-
|
662
|
-
|
663
|
-
|
664
|
-
|
665
|
-
|
666
|
-
|
667
|
-
|
668
|
-
|
669
|
-
|
670
|
-
|
671
|
-
|
672
|
-
|
673
|
-
|
674
|
-
|
675
|
-
|
676
|
-
|
677
|
-
|
678
|
-
|
679
|
-
|
680
|
-
|
681
|
-
|
682
|
-
|
683
|
-
|
684
|
-
|
685
|
-
|
686
|
-
|
687
|
-
|
688
|
-
|
689
|
-
|
690
|
-
|
691
|
-
|
692
|
-
|
693
|
-
|
694
|
-
|
695
|
-
|
696
|
-
|
697
|
-
|
698
|
-
|
699
|
-
|
700
|
-
|
701
|
-
|
702
|
-
|
703
|
-
|
704
|
-
|
705
|
-
|
706
|
-
|
707
|
-
|
708
|
-
|
709
|
-
|
710
|
-
|
711
|
-
|
712
|
-
|
713
|
-
|
714
|
-
|
715
|
-
|
716
|
-
|
717
|
-
|
718
|
-
|
719
|
-
|
720
|
-
|
721
|
-
|
722
|
-
|
723
|
-
|
724
|
-
|
725
|
-
|
726
|
-
|
727
|
-
|
728
|
-
|
729
|
-
|
730
|
-
|
731
|
-
|
732
|
-
|
733
|
-
|
734
|
-
|
735
|
-
|
736
|
-
|
737
|
-
|
738
|
-
|
739
|
-
|
740
|
-
|
741
|
-
|
742
|
-
|
743
|
-
|
744
|
-
|
745
|
-
|
746
|
-
|
747
|
-
|
748
|
-
|
749
|
-
|
750
|
-
|
751
|
-
|
752
|
-
|
753
|
-
|
754
|
-
|
755
|
-
|
756
|
-
|
757
|
-
|
758
|
-
|
759
|
-
|
760
|
-
|
761
|
-
|
762
|
-
|
763
|
-
|
764
|
-
|
765
|
-
|
766
|
-
|
767
|
-
|
768
|
-
|
769
|
-
|
770
|
-
|
771
|
-
|
772
|
-
|
773
|
-
|
774
|
-
|
775
|
-
|
776
|
-
|
777
|
-
|
778
|
-
|
779
|
-
|
780
|
-
|
781
|
-
|
782
|
-
|
783
|
-
|
784
|
-
|
785
|
-
|
786
|
-
|
787
|
-
|
788
|
-
|
789
|
-
|
790
|
-
|
791
|
-
|
792
|
-
|
793
|
-
|
794
|
-
|
795
|
-
|
796
|
-
|
797
|
-
|
798
|
-
|
799
|
-
|
800
|
-
|
801
|
-
|
802
|
-
|
803
|
-
|
804
|
-
|
805
|
-
|
806
|
-
|
807
|
-
|
808
|
-
|
809
|
-
|
810
|
-
|
811
|
-
|
812
|
-
|
813
|
-
|
814
|
-
|
815
|
-
|
816
|
-
|
817
|
-
|
818
|
-
|
819
|
-
|
820
|
-
|
821
|
-
|
822
|
-
|
823
|
-
|
824
|
-
|
825
|
-
|
826
|
-
|
827
|
-
|
828
|
-
|
829
|
-
|
830
|
-
|
831
|
-
|
832
|
-
|
833
|
-
|
834
|
-
|
835
|
-
|
836
|
-
|
837
|
-
|
838
|
-
|
839
|
-
|
840
|
-
|
841
|
-
|
842
|
-
|
843
|
-
|
844
|
-
|
845
|
-
|
846
|
-
|
847
|
-
|
1
|
+
/*****************************************************************************
|
2
|
+
|
3
|
+
$Id$
|
4
|
+
|
5
|
+
File: rubymain.cpp
|
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
|
+
#include "project.h"
|
21
|
+
#include "eventmachine.h"
|
22
|
+
#include <ruby.h>
|
23
|
+
|
24
|
+
#ifndef RFLOAT_VALUE
|
25
|
+
#define RFLOAT_VALUE(arg) RFLOAT(arg)->value
|
26
|
+
#endif
|
27
|
+
|
28
|
+
/*******
|
29
|
+
Statics
|
30
|
+
*******/
|
31
|
+
|
32
|
+
static VALUE EmModule;
|
33
|
+
static VALUE EmConnection;
|
34
|
+
|
35
|
+
static VALUE EM_eUnknownTimerFired;
|
36
|
+
static VALUE EM_eConnectionNotBound;
|
37
|
+
|
38
|
+
static VALUE Intern_at_signature;
|
39
|
+
static VALUE Intern_at_timers;
|
40
|
+
static VALUE Intern_at_conns;
|
41
|
+
static VALUE Intern_at_error_handler;
|
42
|
+
static VALUE Intern_event_callback;
|
43
|
+
static VALUE Intern_run_deferred_callbacks;
|
44
|
+
static VALUE Intern_delete;
|
45
|
+
static VALUE Intern_call;
|
46
|
+
static VALUE Intern_receive_data;
|
47
|
+
static VALUE Intern_ssl_handshake_completed;
|
48
|
+
static VALUE Intern_ssl_verify_peer;
|
49
|
+
static VALUE Intern_notify_readable;
|
50
|
+
static VALUE Intern_notify_writable;
|
51
|
+
static VALUE Intern_proxy_target_unbound;
|
52
|
+
|
53
|
+
static VALUE rb_cProcStatus;
|
54
|
+
|
55
|
+
struct em_event {
|
56
|
+
const char *a1;
|
57
|
+
int a2;
|
58
|
+
const char *a3;
|
59
|
+
int a4;
|
60
|
+
};
|
61
|
+
|
62
|
+
/****************
|
63
|
+
t_event_callback
|
64
|
+
****************/
|
65
|
+
|
66
|
+
static void event_callback (struct em_event* e)
|
67
|
+
{
|
68
|
+
const char *a1 = e->a1;
|
69
|
+
int a2 = e->a2;
|
70
|
+
const char *a3 = e->a3;
|
71
|
+
int a4 = e->a4;
|
72
|
+
|
73
|
+
if (a2 == EM_CONNECTION_READ) {
|
74
|
+
VALUE t = rb_ivar_get (EmModule, Intern_at_conns);
|
75
|
+
VALUE q = rb_hash_aref (t, rb_str_new2(a1));
|
76
|
+
if (q == Qnil)
|
77
|
+
rb_raise (EM_eConnectionNotBound, "received %d bytes of data for unknown signature: %s", a4, a1);
|
78
|
+
rb_funcall (q, Intern_receive_data, 1, rb_str_new (a3, a4));
|
79
|
+
}
|
80
|
+
else if (a2 == EM_CONNECTION_NOTIFY_READABLE) {
|
81
|
+
VALUE t = rb_ivar_get (EmModule, Intern_at_conns);
|
82
|
+
VALUE q = rb_hash_aref (t, rb_str_new2(a1));
|
83
|
+
if (q == Qnil)
|
84
|
+
rb_raise (EM_eConnectionNotBound, "unknown connection: %s", a1);
|
85
|
+
rb_funcall (q, Intern_notify_readable, 0);
|
86
|
+
}
|
87
|
+
else if (a2 == EM_CONNECTION_NOTIFY_WRITABLE) {
|
88
|
+
VALUE t = rb_ivar_get (EmModule, Intern_at_conns);
|
89
|
+
VALUE q = rb_hash_aref (t, rb_str_new2(a1));
|
90
|
+
if (q == Qnil)
|
91
|
+
rb_raise (EM_eConnectionNotBound, "unknown connection: %s", a1);
|
92
|
+
rb_funcall (q, Intern_notify_writable, 0);
|
93
|
+
}
|
94
|
+
else if (a2 == EM_LOOPBREAK_SIGNAL) {
|
95
|
+
rb_funcall (EmModule, Intern_run_deferred_callbacks, 0);
|
96
|
+
}
|
97
|
+
else if (a2 == EM_TIMER_FIRED) {
|
98
|
+
VALUE t = rb_ivar_get (EmModule, Intern_at_timers);
|
99
|
+
VALUE q = rb_funcall (t, Intern_delete, 1, rb_str_new(a3, a4));
|
100
|
+
if (q == Qnil) {
|
101
|
+
rb_raise (EM_eUnknownTimerFired, "no such timer: %s", a1);
|
102
|
+
} else if (q == Qfalse) {
|
103
|
+
/* Timer Canceled */
|
104
|
+
} else {
|
105
|
+
rb_funcall (q, Intern_call, 0);
|
106
|
+
}
|
107
|
+
}
|
108
|
+
#ifdef WITH_SSL
|
109
|
+
else if (a2 == EM_SSL_HANDSHAKE_COMPLETED) {
|
110
|
+
VALUE t = rb_ivar_get (EmModule, Intern_at_conns);
|
111
|
+
VALUE q = rb_hash_aref (t, rb_str_new2(a1));
|
112
|
+
if (q == Qnil)
|
113
|
+
rb_raise (EM_eConnectionNotBound, "unknown connection: %s", a1);
|
114
|
+
rb_funcall (q, Intern_ssl_handshake_completed, 0);
|
115
|
+
}
|
116
|
+
else if (a2 == EM_SSL_VERIFY) {
|
117
|
+
VALUE t = rb_ivar_get (EmModule, Intern_at_conns);
|
118
|
+
VALUE q = rb_hash_aref (t, rb_str_new2(a1));
|
119
|
+
if (q == Qnil)
|
120
|
+
rb_raise (EM_eConnectionNotBound, "unknown connection: %s", a1);
|
121
|
+
VALUE r = rb_funcall (q, Intern_ssl_verify_peer, 1, rb_str_new(a3, a4));
|
122
|
+
if (RTEST(r))
|
123
|
+
evma_accept_ssl_peer (a1);
|
124
|
+
}
|
125
|
+
#endif
|
126
|
+
else if (a2 == EM_PROXY_TARGET_UNBOUND) {
|
127
|
+
VALUE t = rb_ivar_get (EmModule, Intern_at_conns);
|
128
|
+
VALUE q = rb_hash_aref (t, rb_str_new2(a1));
|
129
|
+
if (q == Qnil)
|
130
|
+
rb_raise (EM_eConnectionNotBound, "unknown connection: %s", a1);
|
131
|
+
rb_funcall (q, Intern_proxy_target_unbound, 0);
|
132
|
+
}
|
133
|
+
else
|
134
|
+
rb_funcall (EmModule, Intern_event_callback, 3, rb_str_new2(a1), (a2 << 1) | 1, rb_str_new(a3,a4));
|
135
|
+
}
|
136
|
+
|
137
|
+
/*******************
|
138
|
+
event_error_handler
|
139
|
+
*******************/
|
140
|
+
|
141
|
+
static void event_error_handler(VALUE unused, VALUE err)
|
142
|
+
{
|
143
|
+
VALUE error_handler = rb_ivar_get(EmModule, Intern_at_error_handler);
|
144
|
+
rb_funcall (error_handler, Intern_call, 1, err);
|
145
|
+
}
|
146
|
+
|
147
|
+
/**********************
|
148
|
+
event_callback_wrapper
|
149
|
+
**********************/
|
150
|
+
|
151
|
+
static void event_callback_wrapper (const char *a1, int a2, const char *a3, int a4)
|
152
|
+
{
|
153
|
+
struct em_event e;
|
154
|
+
e.a1 = a1;
|
155
|
+
e.a2 = a2;
|
156
|
+
e.a3 = a3;
|
157
|
+
e.a4 = a4;
|
158
|
+
|
159
|
+
if (!rb_ivar_defined(EmModule, Intern_at_error_handler))
|
160
|
+
event_callback(&e);
|
161
|
+
else
|
162
|
+
rb_rescue((VALUE (*)(ANYARGS))event_callback, (VALUE)&e, (VALUE (*)(ANYARGS))event_error_handler, Qnil);
|
163
|
+
}
|
164
|
+
|
165
|
+
/**************************
|
166
|
+
t_initialize_event_machine
|
167
|
+
**************************/
|
168
|
+
|
169
|
+
static VALUE t_initialize_event_machine (VALUE self)
|
170
|
+
{
|
171
|
+
evma_initialize_library (event_callback_wrapper);
|
172
|
+
return Qnil;
|
173
|
+
}
|
174
|
+
|
175
|
+
|
176
|
+
|
177
|
+
/*****************************
|
178
|
+
t_run_machine_without_threads
|
179
|
+
*****************************/
|
180
|
+
|
181
|
+
static VALUE t_run_machine_without_threads (VALUE self)
|
182
|
+
{
|
183
|
+
evma_run_machine();
|
184
|
+
return Qnil;
|
185
|
+
}
|
186
|
+
|
187
|
+
|
188
|
+
/*******************
|
189
|
+
t_add_oneshot_timer
|
190
|
+
*******************/
|
191
|
+
|
192
|
+
static VALUE t_add_oneshot_timer (VALUE self, VALUE interval)
|
193
|
+
{
|
194
|
+
const char *f = evma_install_oneshot_timer (FIX2INT (interval));
|
195
|
+
if (!f || !*f)
|
196
|
+
rb_raise (rb_eRuntimeError, "no timer");
|
197
|
+
return rb_str_new2 (f);
|
198
|
+
}
|
199
|
+
|
200
|
+
|
201
|
+
/**************
|
202
|
+
t_start_server
|
203
|
+
**************/
|
204
|
+
|
205
|
+
static VALUE t_start_server (VALUE self, VALUE server, VALUE port)
|
206
|
+
{
|
207
|
+
const char *f = evma_create_tcp_server (StringValuePtr(server), FIX2INT(port));
|
208
|
+
if (!f || !*f)
|
209
|
+
rb_raise (rb_eRuntimeError, "no acceptor");
|
210
|
+
return rb_str_new2 (f);
|
211
|
+
}
|
212
|
+
|
213
|
+
/*************
|
214
|
+
t_stop_server
|
215
|
+
*************/
|
216
|
+
|
217
|
+
static VALUE t_stop_server (VALUE self, VALUE signature)
|
218
|
+
{
|
219
|
+
evma_stop_tcp_server (StringValuePtr (signature));
|
220
|
+
return Qnil;
|
221
|
+
}
|
222
|
+
|
223
|
+
|
224
|
+
/*******************
|
225
|
+
t_start_unix_server
|
226
|
+
*******************/
|
227
|
+
|
228
|
+
static VALUE t_start_unix_server (VALUE self, VALUE filename)
|
229
|
+
{
|
230
|
+
const char *f = evma_create_unix_domain_server (StringValuePtr(filename));
|
231
|
+
if (!f || !*f)
|
232
|
+
rb_raise (rb_eRuntimeError, "no unix-domain acceptor");
|
233
|
+
return rb_str_new2 (f);
|
234
|
+
}
|
235
|
+
|
236
|
+
|
237
|
+
|
238
|
+
/***********
|
239
|
+
t_send_data
|
240
|
+
***********/
|
241
|
+
|
242
|
+
static VALUE t_send_data (VALUE self, VALUE signature, VALUE data, VALUE data_length)
|
243
|
+
{
|
244
|
+
int b = evma_send_data_to_connection (StringValuePtr (signature), StringValuePtr (data), FIX2INT (data_length));
|
245
|
+
return INT2NUM (b);
|
246
|
+
}
|
247
|
+
|
248
|
+
|
249
|
+
/***********
|
250
|
+
t_start_tls
|
251
|
+
***********/
|
252
|
+
|
253
|
+
static VALUE t_start_tls (VALUE self, VALUE signature)
|
254
|
+
{
|
255
|
+
evma_start_tls (StringValuePtr (signature));
|
256
|
+
return Qnil;
|
257
|
+
}
|
258
|
+
|
259
|
+
/***************
|
260
|
+
t_set_tls_parms
|
261
|
+
***************/
|
262
|
+
|
263
|
+
static VALUE t_set_tls_parms (VALUE self, VALUE signature, VALUE privkeyfile, VALUE certchainfile, VALUE verify_peer)
|
264
|
+
{
|
265
|
+
/* set_tls_parms takes a series of positional arguments for specifying such things
|
266
|
+
* as private keys and certificate chains.
|
267
|
+
* It's expected that the parameter list will grow as we add more supported features.
|
268
|
+
* ALL of these parameters are optional, and can be specified as empty or NULL strings.
|
269
|
+
*/
|
270
|
+
evma_set_tls_parms (StringValuePtr (signature), StringValuePtr (privkeyfile), StringValuePtr (certchainfile), (verify_peer == Qtrue ? 1 : 0));
|
271
|
+
return Qnil;
|
272
|
+
}
|
273
|
+
|
274
|
+
/***************
|
275
|
+
t_get_peer_cert
|
276
|
+
***************/
|
277
|
+
|
278
|
+
static VALUE t_get_peer_cert (VALUE self, VALUE signature)
|
279
|
+
{
|
280
|
+
VALUE ret = Qnil;
|
281
|
+
|
282
|
+
#ifdef WITH_SSL
|
283
|
+
X509 *cert = NULL;
|
284
|
+
BUF_MEM *buf;
|
285
|
+
BIO *out;
|
286
|
+
|
287
|
+
cert = evma_get_peer_cert (StringValuePtr (signature));
|
288
|
+
|
289
|
+
if (cert != NULL) {
|
290
|
+
out = BIO_new(BIO_s_mem());
|
291
|
+
PEM_write_bio_X509(out, cert);
|
292
|
+
BIO_get_mem_ptr(out, &buf);
|
293
|
+
ret = rb_str_new(buf->data, buf->length);
|
294
|
+
X509_free(cert);
|
295
|
+
BUF_MEM_free(buf);
|
296
|
+
}
|
297
|
+
#endif
|
298
|
+
|
299
|
+
return ret;
|
300
|
+
}
|
301
|
+
|
302
|
+
/**************
|
303
|
+
t_get_peername
|
304
|
+
**************/
|
305
|
+
|
306
|
+
static VALUE t_get_peername (VALUE self, VALUE signature)
|
307
|
+
{
|
308
|
+
struct sockaddr s;
|
309
|
+
if (evma_get_peername (StringValuePtr (signature), &s)) {
|
310
|
+
return rb_str_new ((const char*)&s, sizeof(s));
|
311
|
+
}
|
312
|
+
|
313
|
+
return Qnil;
|
314
|
+
}
|
315
|
+
|
316
|
+
/**************
|
317
|
+
t_get_sockname
|
318
|
+
**************/
|
319
|
+
|
320
|
+
static VALUE t_get_sockname (VALUE self, VALUE signature)
|
321
|
+
{
|
322
|
+
struct sockaddr s;
|
323
|
+
if (evma_get_sockname (StringValuePtr (signature), &s)) {
|
324
|
+
return rb_str_new ((const char*)&s, sizeof(s));
|
325
|
+
}
|
326
|
+
|
327
|
+
return Qnil;
|
328
|
+
}
|
329
|
+
|
330
|
+
/********************
|
331
|
+
t_get_subprocess_pid
|
332
|
+
********************/
|
333
|
+
|
334
|
+
static VALUE t_get_subprocess_pid (VALUE self, VALUE signature)
|
335
|
+
{
|
336
|
+
pid_t pid;
|
337
|
+
if (evma_get_subprocess_pid (StringValuePtr (signature), &pid)) {
|
338
|
+
return INT2NUM (pid);
|
339
|
+
}
|
340
|
+
|
341
|
+
return Qnil;
|
342
|
+
}
|
343
|
+
|
344
|
+
/***********************
|
345
|
+
t_get_subprocess_status
|
346
|
+
***********************/
|
347
|
+
|
348
|
+
static VALUE t_get_subprocess_status (VALUE self, VALUE signature)
|
349
|
+
{
|
350
|
+
VALUE proc_status = Qnil;
|
351
|
+
|
352
|
+
int status;
|
353
|
+
pid_t pid;
|
354
|
+
|
355
|
+
if (evma_get_subprocess_status (StringValuePtr (signature), &status)) {
|
356
|
+
if (evma_get_subprocess_pid (StringValuePtr (signature), &pid)) {
|
357
|
+
proc_status = rb_obj_alloc(rb_cProcStatus);
|
358
|
+
rb_iv_set(proc_status, "status", INT2FIX(status));
|
359
|
+
rb_iv_set(proc_status, "pid", INT2FIX(pid));
|
360
|
+
}
|
361
|
+
}
|
362
|
+
|
363
|
+
return proc_status;
|
364
|
+
}
|
365
|
+
|
366
|
+
/**********************
|
367
|
+
t_get_connection_count
|
368
|
+
**********************/
|
369
|
+
|
370
|
+
static VALUE t_get_connection_count (VALUE self)
|
371
|
+
{
|
372
|
+
return INT2NUM(evma_get_connection_count());
|
373
|
+
}
|
374
|
+
|
375
|
+
/*****************************
|
376
|
+
t_get_comm_inactivity_timeout
|
377
|
+
*****************************/
|
378
|
+
|
379
|
+
static VALUE t_get_comm_inactivity_timeout (VALUE self, VALUE signature)
|
380
|
+
{
|
381
|
+
return rb_float_new(evma_get_comm_inactivity_timeout(StringValuePtr(signature)));
|
382
|
+
}
|
383
|
+
|
384
|
+
/*****************************
|
385
|
+
t_set_comm_inactivity_timeout
|
386
|
+
*****************************/
|
387
|
+
|
388
|
+
static VALUE t_set_comm_inactivity_timeout (VALUE self, VALUE signature, VALUE timeout)
|
389
|
+
{
|
390
|
+
float ti = RFLOAT_VALUE(timeout);
|
391
|
+
if (evma_set_comm_inactivity_timeout (StringValuePtr (signature), ti));
|
392
|
+
return Qtrue;
|
393
|
+
return Qfalse;
|
394
|
+
}
|
395
|
+
|
396
|
+
|
397
|
+
/***************
|
398
|
+
t_send_datagram
|
399
|
+
***************/
|
400
|
+
|
401
|
+
static VALUE t_send_datagram (VALUE self, VALUE signature, VALUE data, VALUE data_length, VALUE address, VALUE port)
|
402
|
+
{
|
403
|
+
int b = evma_send_datagram (StringValuePtr (signature), StringValuePtr (data), FIX2INT (data_length), StringValuePtr(address), FIX2INT(port));
|
404
|
+
return INT2NUM (b);
|
405
|
+
}
|
406
|
+
|
407
|
+
|
408
|
+
/******************
|
409
|
+
t_close_connection
|
410
|
+
******************/
|
411
|
+
|
412
|
+
static VALUE t_close_connection (VALUE self, VALUE signature, VALUE after_writing)
|
413
|
+
{
|
414
|
+
evma_close_connection (StringValuePtr (signature), ((after_writing == Qtrue) ? 1 : 0));
|
415
|
+
return Qnil;
|
416
|
+
}
|
417
|
+
|
418
|
+
/********************************
|
419
|
+
t_report_connection_error_status
|
420
|
+
********************************/
|
421
|
+
|
422
|
+
static VALUE t_report_connection_error_status (VALUE self, VALUE signature)
|
423
|
+
{
|
424
|
+
int b = evma_report_connection_error_status (StringValuePtr (signature));
|
425
|
+
return INT2NUM (b);
|
426
|
+
}
|
427
|
+
|
428
|
+
|
429
|
+
|
430
|
+
/****************
|
431
|
+
t_connect_server
|
432
|
+
****************/
|
433
|
+
|
434
|
+
static VALUE t_connect_server (VALUE self, VALUE server, VALUE port)
|
435
|
+
{
|
436
|
+
// Avoid FIX2INT in this case, because it doesn't deal with type errors properly.
|
437
|
+
// Specifically, if the value of port comes in as a string rather than an integer,
|
438
|
+
// NUM2INT will throw a type error, but FIX2INT will generate garbage.
|
439
|
+
|
440
|
+
const char *f = evma_connect_to_server (NULL, 0, StringValuePtr(server), NUM2INT(port));
|
441
|
+
if (!f || !*f)
|
442
|
+
rb_raise (rb_eRuntimeError, "no connection");
|
443
|
+
return rb_str_new2 (f);
|
444
|
+
}
|
445
|
+
|
446
|
+
/*********************
|
447
|
+
t_bind_connect_server
|
448
|
+
*********************/
|
449
|
+
|
450
|
+
static VALUE t_bind_connect_server (VALUE self, VALUE bind_addr, VALUE bind_port, VALUE server, VALUE port)
|
451
|
+
{
|
452
|
+
// Avoid FIX2INT in this case, because it doesn't deal with type errors properly.
|
453
|
+
// Specifically, if the value of port comes in as a string rather than an integer,
|
454
|
+
// NUM2INT will throw a type error, but FIX2INT will generate garbage.
|
455
|
+
|
456
|
+
const char *f;
|
457
|
+
try {
|
458
|
+
f = evma_connect_to_server (StringValuePtr(bind_addr), NUM2INT(bind_port), StringValuePtr(server), NUM2INT(port));
|
459
|
+
if (!f || !*f)
|
460
|
+
rb_raise (rb_eRuntimeError, "no connection");
|
461
|
+
} catch (std::runtime_error e) {
|
462
|
+
rb_sys_fail(e.what());
|
463
|
+
}
|
464
|
+
return rb_str_new2 (f);
|
465
|
+
}
|
466
|
+
|
467
|
+
/*********************
|
468
|
+
t_connect_unix_server
|
469
|
+
*********************/
|
470
|
+
|
471
|
+
static VALUE t_connect_unix_server (VALUE self, VALUE serversocket)
|
472
|
+
{
|
473
|
+
const char *f = evma_connect_to_unix_server (StringValuePtr(serversocket));
|
474
|
+
if (!f || !*f)
|
475
|
+
rb_raise (rb_eRuntimeError, "no connection");
|
476
|
+
return rb_str_new2 (f);
|
477
|
+
}
|
478
|
+
|
479
|
+
/***********
|
480
|
+
t_attach_fd
|
481
|
+
***********/
|
482
|
+
|
483
|
+
static VALUE t_attach_fd (VALUE self, VALUE file_descriptor, VALUE read_mode, VALUE write_mode)
|
484
|
+
{
|
485
|
+
const char *f = evma_attach_fd (NUM2INT(file_descriptor), (read_mode == Qtrue) ? 1 : 0, (write_mode == Qtrue) ? 1 : 0);
|
486
|
+
if (!f || !*f)
|
487
|
+
rb_raise (rb_eRuntimeError, "no connection");
|
488
|
+
return rb_str_new2 (f);
|
489
|
+
}
|
490
|
+
|
491
|
+
/***********
|
492
|
+
t_detach_fd
|
493
|
+
***********/
|
494
|
+
|
495
|
+
static VALUE t_detach_fd (VALUE self, VALUE signature)
|
496
|
+
{
|
497
|
+
return INT2NUM(evma_detach_fd (StringValuePtr(signature)));
|
498
|
+
}
|
499
|
+
|
500
|
+
/*****************
|
501
|
+
t_open_udp_socket
|
502
|
+
*****************/
|
503
|
+
|
504
|
+
static VALUE t_open_udp_socket (VALUE self, VALUE server, VALUE port)
|
505
|
+
{
|
506
|
+
const char *f = evma_open_datagram_socket (StringValuePtr(server), FIX2INT(port));
|
507
|
+
if (!f || !*f)
|
508
|
+
rb_raise (rb_eRuntimeError, "no datagram socket");
|
509
|
+
return rb_str_new2 (f);
|
510
|
+
}
|
511
|
+
|
512
|
+
|
513
|
+
|
514
|
+
/*****************
|
515
|
+
t_release_machine
|
516
|
+
*****************/
|
517
|
+
|
518
|
+
static VALUE t_release_machine (VALUE self)
|
519
|
+
{
|
520
|
+
evma_release_library();
|
521
|
+
return Qnil;
|
522
|
+
}
|
523
|
+
|
524
|
+
|
525
|
+
/******
|
526
|
+
t_stop
|
527
|
+
******/
|
528
|
+
|
529
|
+
static VALUE t_stop (VALUE self)
|
530
|
+
{
|
531
|
+
evma_stop_machine();
|
532
|
+
return Qnil;
|
533
|
+
}
|
534
|
+
|
535
|
+
/******************
|
536
|
+
t_signal_loopbreak
|
537
|
+
******************/
|
538
|
+
|
539
|
+
static VALUE t_signal_loopbreak (VALUE self)
|
540
|
+
{
|
541
|
+
evma_signal_loopbreak();
|
542
|
+
return Qnil;
|
543
|
+
}
|
544
|
+
|
545
|
+
/**************
|
546
|
+
t_library_type
|
547
|
+
**************/
|
548
|
+
|
549
|
+
static VALUE t_library_type (VALUE self)
|
550
|
+
{
|
551
|
+
return rb_eval_string (":extension");
|
552
|
+
}
|
553
|
+
|
554
|
+
|
555
|
+
|
556
|
+
/*******************
|
557
|
+
t_set_timer_quantum
|
558
|
+
*******************/
|
559
|
+
|
560
|
+
static VALUE t_set_timer_quantum (VALUE self, VALUE interval)
|
561
|
+
{
|
562
|
+
evma_set_timer_quantum (FIX2INT (interval));
|
563
|
+
return Qnil;
|
564
|
+
}
|
565
|
+
|
566
|
+
/********************
|
567
|
+
t_get_max_timer_count
|
568
|
+
********************/
|
569
|
+
|
570
|
+
static VALUE t_get_max_timer_count (VALUE self)
|
571
|
+
{
|
572
|
+
return INT2FIX (evma_get_max_timer_count());
|
573
|
+
}
|
574
|
+
|
575
|
+
/********************
|
576
|
+
t_set_max_timer_count
|
577
|
+
********************/
|
578
|
+
|
579
|
+
static VALUE t_set_max_timer_count (VALUE self, VALUE ct)
|
580
|
+
{
|
581
|
+
evma_set_max_timer_count (FIX2INT (ct));
|
582
|
+
return Qnil;
|
583
|
+
}
|
584
|
+
|
585
|
+
/***************
|
586
|
+
t_setuid_string
|
587
|
+
***************/
|
588
|
+
|
589
|
+
static VALUE t_setuid_string (VALUE self, VALUE username)
|
590
|
+
{
|
591
|
+
evma_setuid_string (StringValuePtr (username));
|
592
|
+
return Qnil;
|
593
|
+
}
|
594
|
+
|
595
|
+
|
596
|
+
|
597
|
+
/*************
|
598
|
+
t__write_file
|
599
|
+
*************/
|
600
|
+
|
601
|
+
static VALUE t__write_file (VALUE self, VALUE filename)
|
602
|
+
{
|
603
|
+
const char *f = evma__write_file (StringValuePtr (filename));
|
604
|
+
if (!f || !*f)
|
605
|
+
rb_raise (rb_eRuntimeError, "file not opened");
|
606
|
+
return rb_str_new2 (f);
|
607
|
+
}
|
608
|
+
|
609
|
+
/**************
|
610
|
+
t_invoke_popen
|
611
|
+
**************/
|
612
|
+
|
613
|
+
static VALUE t_invoke_popen (VALUE self, VALUE cmd)
|
614
|
+
{
|
615
|
+
// 1.8.7+
|
616
|
+
#ifdef RARRAY_LEN
|
617
|
+
int len = RARRAY_LEN(cmd);
|
618
|
+
#else
|
619
|
+
int len = RARRAY (cmd)->len;
|
620
|
+
#endif
|
621
|
+
if (len > 98)
|
622
|
+
rb_raise (rb_eRuntimeError, "too many arguments to popen");
|
623
|
+
char *strings [100];
|
624
|
+
for (int i=0; i < len; i++) {
|
625
|
+
VALUE ix = INT2FIX (i);
|
626
|
+
VALUE s = rb_ary_aref (1, &ix, cmd);
|
627
|
+
strings[i] = StringValuePtr (s);
|
628
|
+
}
|
629
|
+
strings[len] = NULL;
|
630
|
+
|
631
|
+
const char *f = evma_popen (strings);
|
632
|
+
if (!f || !*f) {
|
633
|
+
char *err = strerror (errno);
|
634
|
+
char buf[100];
|
635
|
+
memset (buf, 0, sizeof(buf));
|
636
|
+
snprintf (buf, sizeof(buf)-1, "no popen: %s", (err?err:"???"));
|
637
|
+
rb_raise (rb_eRuntimeError, buf);
|
638
|
+
}
|
639
|
+
return rb_str_new2 (f);
|
640
|
+
}
|
641
|
+
|
642
|
+
|
643
|
+
/***************
|
644
|
+
t_read_keyboard
|
645
|
+
***************/
|
646
|
+
|
647
|
+
static VALUE t_read_keyboard (VALUE self)
|
648
|
+
{
|
649
|
+
const char *f = evma_open_keyboard();
|
650
|
+
if (!f || !*f)
|
651
|
+
rb_raise (rb_eRuntimeError, "no keyboard reader");
|
652
|
+
return rb_str_new2 (f);
|
653
|
+
}
|
654
|
+
|
655
|
+
|
656
|
+
/****************
|
657
|
+
t_watch_filename
|
658
|
+
****************/
|
659
|
+
|
660
|
+
static VALUE t_watch_filename (VALUE self, VALUE fname)
|
661
|
+
{
|
662
|
+
try {
|
663
|
+
return rb_str_new2(evma_watch_filename(StringValuePtr(fname)));
|
664
|
+
} catch (std::runtime_error e) {
|
665
|
+
rb_sys_fail(e.what());
|
666
|
+
}
|
667
|
+
}
|
668
|
+
|
669
|
+
|
670
|
+
/******************
|
671
|
+
t_unwatch_filename
|
672
|
+
******************/
|
673
|
+
|
674
|
+
static VALUE t_unwatch_filename (VALUE self, VALUE sig)
|
675
|
+
{
|
676
|
+
evma_unwatch_filename(StringValuePtr(sig));
|
677
|
+
return Qnil;
|
678
|
+
}
|
679
|
+
|
680
|
+
|
681
|
+
/***********
|
682
|
+
t_watch_pid
|
683
|
+
***********/
|
684
|
+
|
685
|
+
static VALUE t_watch_pid (VALUE self, VALUE pid)
|
686
|
+
{
|
687
|
+
try {
|
688
|
+
return rb_str_new2(evma_watch_pid(NUM2INT(pid)));
|
689
|
+
} catch (std::runtime_error e) {
|
690
|
+
rb_sys_fail(e.what());
|
691
|
+
}
|
692
|
+
}
|
693
|
+
|
694
|
+
|
695
|
+
/*************
|
696
|
+
t_unwatch_pid
|
697
|
+
*************/
|
698
|
+
|
699
|
+
static VALUE t_unwatch_pid (VALUE self, VALUE sig)
|
700
|
+
{
|
701
|
+
evma_unwatch_pid(StringValuePtr(sig));
|
702
|
+
return Qnil;
|
703
|
+
}
|
704
|
+
|
705
|
+
|
706
|
+
/**********
|
707
|
+
t__epoll_p
|
708
|
+
**********/
|
709
|
+
|
710
|
+
static VALUE t__epoll_p (VALUE self)
|
711
|
+
{
|
712
|
+
#ifdef HAVE_EPOLL
|
713
|
+
return Qtrue;
|
714
|
+
#else
|
715
|
+
return Qfalse;
|
716
|
+
#endif
|
717
|
+
}
|
718
|
+
|
719
|
+
/********
|
720
|
+
t__epoll
|
721
|
+
********/
|
722
|
+
|
723
|
+
static VALUE t__epoll (VALUE self)
|
724
|
+
{
|
725
|
+
if (t__epoll_p(self) == Qfalse)
|
726
|
+
return Qfalse;
|
727
|
+
|
728
|
+
evma_set_epoll (1);
|
729
|
+
return Qtrue;
|
730
|
+
}
|
731
|
+
|
732
|
+
/***********
|
733
|
+
t__epoll_set
|
734
|
+
***********/
|
735
|
+
|
736
|
+
static VALUE t__epoll_set (VALUE self, VALUE val)
|
737
|
+
{
|
738
|
+
if (t__epoll_p(self) == Qfalse)
|
739
|
+
return Qfalse;
|
740
|
+
|
741
|
+
evma_set_epoll (val == Qtrue ? 1 : 0);
|
742
|
+
return val;
|
743
|
+
}
|
744
|
+
|
745
|
+
|
746
|
+
/***********
|
747
|
+
t__kqueue_p
|
748
|
+
***********/
|
749
|
+
|
750
|
+
static VALUE t__kqueue_p (VALUE self)
|
751
|
+
{
|
752
|
+
#ifdef HAVE_KQUEUE
|
753
|
+
return Qtrue;
|
754
|
+
#else
|
755
|
+
return Qfalse;
|
756
|
+
#endif
|
757
|
+
}
|
758
|
+
|
759
|
+
/*********
|
760
|
+
t__kqueue
|
761
|
+
*********/
|
762
|
+
|
763
|
+
static VALUE t__kqueue (VALUE self)
|
764
|
+
{
|
765
|
+
if (t__kqueue_p(self) == Qfalse)
|
766
|
+
return Qfalse;
|
767
|
+
|
768
|
+
evma_set_kqueue (1);
|
769
|
+
return Qtrue;
|
770
|
+
}
|
771
|
+
|
772
|
+
/*************
|
773
|
+
t__kqueue_set
|
774
|
+
*************/
|
775
|
+
|
776
|
+
static VALUE t__kqueue_set (VALUE self, VALUE val)
|
777
|
+
{
|
778
|
+
if (t__kqueue_p(self) == Qfalse)
|
779
|
+
return Qfalse;
|
780
|
+
|
781
|
+
evma_set_kqueue (val == Qtrue ? 1 : 0);
|
782
|
+
return val;
|
783
|
+
}
|
784
|
+
|
785
|
+
|
786
|
+
/********
|
787
|
+
t__ssl_p
|
788
|
+
********/
|
789
|
+
|
790
|
+
static VALUE t__ssl_p (VALUE self)
|
791
|
+
{
|
792
|
+
#ifdef WITH_SSL
|
793
|
+
return Qtrue;
|
794
|
+
#else
|
795
|
+
return Qfalse;
|
796
|
+
#endif
|
797
|
+
}
|
798
|
+
|
799
|
+
|
800
|
+
/****************
|
801
|
+
t_send_file_data
|
802
|
+
****************/
|
803
|
+
|
804
|
+
static VALUE t_send_file_data (VALUE self, VALUE signature, VALUE filename)
|
805
|
+
{
|
806
|
+
|
807
|
+
/* The current implementation of evma_send_file_data_to_connection enforces a strict
|
808
|
+
* upper limit on the file size it will transmit (currently 32K). The function returns
|
809
|
+
* zero on success, -1 if the requested file exceeds its size limit, and a positive
|
810
|
+
* number for other errors.
|
811
|
+
* TODO: Positive return values are actually errno's, which is probably the wrong way to
|
812
|
+
* do this. For one thing it's ugly. For another, we can't be sure zero is never a real errno.
|
813
|
+
*/
|
814
|
+
|
815
|
+
int b = evma_send_file_data_to_connection (StringValuePtr(signature), StringValuePtr(filename));
|
816
|
+
if (b == -1)
|
817
|
+
rb_raise(rb_eRuntimeError, "File too large. send_file_data() supports files under 32k.");
|
818
|
+
if (b > 0) {
|
819
|
+
char *err = strerror (b);
|
820
|
+
char buf[1024];
|
821
|
+
memset (buf, 0, sizeof(buf));
|
822
|
+
snprintf (buf, sizeof(buf)-1, ": %s %s", StringValuePtr(filename),(err?err:"???"));
|
823
|
+
|
824
|
+
rb_raise (rb_eIOError, buf);
|
825
|
+
}
|
826
|
+
|
827
|
+
return INT2NUM (0);
|
828
|
+
}
|
829
|
+
|
830
|
+
|
831
|
+
/*******************
|
832
|
+
t_set_rlimit_nofile
|
833
|
+
*******************/
|
834
|
+
|
835
|
+
static VALUE t_set_rlimit_nofile (VALUE self, VALUE arg)
|
836
|
+
{
|
837
|
+
arg = (NIL_P(arg)) ? -1 : NUM2INT (arg);
|
838
|
+
return INT2NUM (evma_set_rlimit_nofile (arg));
|
839
|
+
}
|
840
|
+
|
841
|
+
/***************************
|
842
|
+
conn_get_outbound_data_size
|
843
|
+
***************************/
|
844
|
+
|
845
|
+
static VALUE conn_get_outbound_data_size (VALUE self)
|
846
|
+
{
|
847
|
+
VALUE sig = rb_ivar_get (self, Intern_at_signature);
|
848
|
+
return INT2NUM (evma_get_outbound_data_size (StringValuePtr(sig)));
|
849
|
+
}
|
850
|
+
|
851
|
+
|
852
|
+
/******************************
|
853
|
+
conn_associate_callback_target
|
854
|
+
******************************/
|
855
|
+
|
856
|
+
static VALUE conn_associate_callback_target (VALUE self, VALUE sig)
|
857
|
+
{
|
858
|
+
// No-op for the time being.
|
859
|
+
return Qnil;
|
860
|
+
}
|
861
|
+
|
862
|
+
|
863
|
+
/***************
|
864
|
+
t_get_loop_time
|
865
|
+
****************/
|
866
|
+
|
867
|
+
static VALUE t_get_loop_time (VALUE self)
|
868
|
+
{
|
869
|
+
VALUE cTime = rb_path2class("Time");
|
870
|
+
if (gCurrentLoopTime != 0) {
|
871
|
+
return rb_funcall(cTime,
|
872
|
+
rb_intern("at"),
|
873
|
+
1,
|
874
|
+
INT2NUM(gCurrentLoopTime));
|
875
|
+
}
|
876
|
+
return Qnil;
|
877
|
+
}
|
878
|
+
|
879
|
+
|
880
|
+
/*************
|
881
|
+
t_start_proxy
|
882
|
+
**************/
|
883
|
+
|
884
|
+
static VALUE t_start_proxy (VALUE self, VALUE from, VALUE to)
|
885
|
+
{
|
886
|
+
evma_start_proxy(StringValuePtr(from), StringValuePtr(to));
|
887
|
+
return Qnil;
|
888
|
+
}
|
889
|
+
|
890
|
+
|
891
|
+
/************
|
892
|
+
t_stop_proxy
|
893
|
+
*************/
|
894
|
+
|
895
|
+
static VALUE t_stop_proxy (VALUE self, VALUE from)
|
896
|
+
{
|
897
|
+
evma_stop_proxy(StringValuePtr(from));
|
898
|
+
return Qnil;
|
899
|
+
}
|
900
|
+
|
901
|
+
|
902
|
+
/************************
|
903
|
+
t_get_heartbeat_interval
|
904
|
+
*************************/
|
905
|
+
|
906
|
+
static VALUE t_get_heartbeat_interval (VALUE self)
|
907
|
+
{
|
908
|
+
return rb_float_new(evma_get_heartbeat_interval());
|
909
|
+
}
|
910
|
+
|
911
|
+
|
912
|
+
/************************
|
913
|
+
t_set_heartbeat_interval
|
914
|
+
*************************/
|
915
|
+
|
916
|
+
static VALUE t_set_heartbeat_interval (VALUE self, VALUE interval)
|
917
|
+
{
|
918
|
+
float iv = RFLOAT_VALUE(interval);
|
919
|
+
if (evma_set_heartbeat_interval(iv))
|
920
|
+
return Qtrue;
|
921
|
+
return Qfalse;
|
922
|
+
}
|
923
|
+
|
924
|
+
|
925
|
+
/*********************
|
926
|
+
Init_rubyeventmachine
|
927
|
+
*********************/
|
928
|
+
|
929
|
+
extern "C" void Init_rubyeventmachine()
|
930
|
+
{
|
931
|
+
// Lookup Process::Status for get_subprocess_status
|
932
|
+
VALUE rb_mProcess = rb_const_get(rb_cObject, rb_intern("Process"));
|
933
|
+
rb_cProcStatus = rb_const_get(rb_mProcess, rb_intern("Status"));
|
934
|
+
|
935
|
+
// Tuck away some symbol values so we don't have to look 'em up every time we need 'em.
|
936
|
+
Intern_at_signature = rb_intern ("@signature");
|
937
|
+
Intern_at_timers = rb_intern ("@timers");
|
938
|
+
Intern_at_conns = rb_intern ("@conns");
|
939
|
+
Intern_at_error_handler = rb_intern("@error_handler");
|
940
|
+
|
941
|
+
Intern_event_callback = rb_intern ("event_callback");
|
942
|
+
Intern_run_deferred_callbacks = rb_intern ("run_deferred_callbacks");
|
943
|
+
Intern_delete = rb_intern ("delete");
|
944
|
+
Intern_call = rb_intern ("call");
|
945
|
+
Intern_receive_data = rb_intern ("receive_data");
|
946
|
+
Intern_ssl_handshake_completed = rb_intern ("ssl_handshake_completed");
|
947
|
+
Intern_ssl_verify_peer = rb_intern ("ssl_verify_peer");
|
948
|
+
Intern_notify_readable = rb_intern ("notify_readable");
|
949
|
+
Intern_notify_writable = rb_intern ("notify_writable");
|
950
|
+
Intern_proxy_target_unbound = rb_intern ("proxy_target_unbound");
|
951
|
+
|
952
|
+
// INCOMPLETE, we need to define class Connections inside module EventMachine
|
953
|
+
// run_machine and run_machine_without_threads are now identical.
|
954
|
+
// Must deprecate the without_threads variant.
|
955
|
+
EmModule = rb_define_module ("EventMachine");
|
956
|
+
EmConnection = rb_define_class_under (EmModule, "Connection", rb_cObject);
|
957
|
+
|
958
|
+
rb_define_class_under (EmModule, "NoHandlerForAcceptedConnection", rb_eException);
|
959
|
+
EM_eConnectionNotBound = rb_define_class_under (EmModule, "ConnectionNotBound", rb_eRuntimeError);
|
960
|
+
EM_eUnknownTimerFired = rb_define_class_under (EmModule, "UnknownTimerFired", rb_eRuntimeError);
|
961
|
+
|
962
|
+
rb_define_module_function (EmModule, "initialize_event_machine", (VALUE(*)(...))t_initialize_event_machine, 0);
|
963
|
+
rb_define_module_function (EmModule, "run_machine", (VALUE(*)(...))t_run_machine_without_threads, 0);
|
964
|
+
rb_define_module_function (EmModule, "run_machine_without_threads", (VALUE(*)(...))t_run_machine_without_threads, 0);
|
965
|
+
rb_define_module_function (EmModule, "add_oneshot_timer", (VALUE(*)(...))t_add_oneshot_timer, 1);
|
966
|
+
rb_define_module_function (EmModule, "start_tcp_server", (VALUE(*)(...))t_start_server, 2);
|
967
|
+
rb_define_module_function (EmModule, "stop_tcp_server", (VALUE(*)(...))t_stop_server, 1);
|
968
|
+
rb_define_module_function (EmModule, "start_unix_server", (VALUE(*)(...))t_start_unix_server, 1);
|
969
|
+
rb_define_module_function (EmModule, "set_tls_parms", (VALUE(*)(...))t_set_tls_parms, 4);
|
970
|
+
rb_define_module_function (EmModule, "start_tls", (VALUE(*)(...))t_start_tls, 1);
|
971
|
+
rb_define_module_function (EmModule, "get_peer_cert", (VALUE(*)(...))t_get_peer_cert, 1);
|
972
|
+
rb_define_module_function (EmModule, "send_data", (VALUE(*)(...))t_send_data, 3);
|
973
|
+
rb_define_module_function (EmModule, "send_datagram", (VALUE(*)(...))t_send_datagram, 5);
|
974
|
+
rb_define_module_function (EmModule, "close_connection", (VALUE(*)(...))t_close_connection, 2);
|
975
|
+
rb_define_module_function (EmModule, "report_connection_error_status", (VALUE(*)(...))t_report_connection_error_status, 1);
|
976
|
+
rb_define_module_function (EmModule, "connect_server", (VALUE(*)(...))t_connect_server, 2);
|
977
|
+
rb_define_module_function (EmModule, "bind_connect_server", (VALUE(*)(...))t_bind_connect_server, 4);
|
978
|
+
rb_define_module_function (EmModule, "connect_unix_server", (VALUE(*)(...))t_connect_unix_server, 1);
|
979
|
+
|
980
|
+
rb_define_module_function (EmModule, "attach_fd", (VALUE (*)(...))t_attach_fd, 3);
|
981
|
+
rb_define_module_function (EmModule, "detach_fd", (VALUE (*)(...))t_detach_fd, 1);
|
982
|
+
|
983
|
+
rb_define_module_function (EmModule, "start_proxy", (VALUE (*)(...))t_start_proxy, 2);
|
984
|
+
rb_define_module_function (EmModule, "stop_proxy", (VALUE (*)(...))t_stop_proxy, 1);
|
985
|
+
|
986
|
+
rb_define_module_function (EmModule, "watch_filename", (VALUE (*)(...))t_watch_filename, 1);
|
987
|
+
rb_define_module_function (EmModule, "unwatch_filename", (VALUE (*)(...))t_unwatch_filename, 1);
|
988
|
+
|
989
|
+
rb_define_module_function (EmModule, "watch_pid", (VALUE (*)(...))t_watch_pid, 1);
|
990
|
+
rb_define_module_function (EmModule, "unwatch_pid", (VALUE (*)(...))t_unwatch_pid, 1);
|
991
|
+
|
992
|
+
rb_define_module_function (EmModule, "current_time", (VALUE(*)(...))t_get_loop_time, 0);
|
993
|
+
|
994
|
+
rb_define_module_function (EmModule, "open_udp_socket", (VALUE(*)(...))t_open_udp_socket, 2);
|
995
|
+
rb_define_module_function (EmModule, "read_keyboard", (VALUE(*)(...))t_read_keyboard, 0);
|
996
|
+
rb_define_module_function (EmModule, "release_machine", (VALUE(*)(...))t_release_machine, 0);
|
997
|
+
rb_define_module_function (EmModule, "stop", (VALUE(*)(...))t_stop, 0);
|
998
|
+
rb_define_module_function (EmModule, "signal_loopbreak", (VALUE(*)(...))t_signal_loopbreak, 0);
|
999
|
+
rb_define_module_function (EmModule, "library_type", (VALUE(*)(...))t_library_type, 0);
|
1000
|
+
rb_define_module_function (EmModule, "set_timer_quantum", (VALUE(*)(...))t_set_timer_quantum, 1);
|
1001
|
+
rb_define_module_function (EmModule, "get_max_timer_count", (VALUE(*)(...))t_get_max_timer_count, 0);
|
1002
|
+
rb_define_module_function (EmModule, "set_max_timer_count", (VALUE(*)(...))t_set_max_timer_count, 1);
|
1003
|
+
rb_define_module_function (EmModule, "setuid_string", (VALUE(*)(...))t_setuid_string, 1);
|
1004
|
+
rb_define_module_function (EmModule, "invoke_popen", (VALUE(*)(...))t_invoke_popen, 1);
|
1005
|
+
rb_define_module_function (EmModule, "send_file_data", (VALUE(*)(...))t_send_file_data, 2);
|
1006
|
+
rb_define_module_function (EmModule, "get_heartbeat_interval", (VALUE(*)(...))t_get_heartbeat_interval, 0);
|
1007
|
+
rb_define_module_function (EmModule, "set_heartbeat_interval", (VALUE(*)(...))t_set_heartbeat_interval, 1);
|
1008
|
+
|
1009
|
+
// Provisional:
|
1010
|
+
rb_define_module_function (EmModule, "_write_file", (VALUE(*)(...))t__write_file, 1);
|
1011
|
+
|
1012
|
+
rb_define_module_function (EmModule, "get_peername", (VALUE(*)(...))t_get_peername, 1);
|
1013
|
+
rb_define_module_function (EmModule, "get_sockname", (VALUE(*)(...))t_get_sockname, 1);
|
1014
|
+
rb_define_module_function (EmModule, "get_subprocess_pid", (VALUE(*)(...))t_get_subprocess_pid, 1);
|
1015
|
+
rb_define_module_function (EmModule, "get_subprocess_status", (VALUE(*)(...))t_get_subprocess_status, 1);
|
1016
|
+
rb_define_module_function (EmModule, "get_comm_inactivity_timeout", (VALUE(*)(...))t_get_comm_inactivity_timeout, 1);
|
1017
|
+
rb_define_module_function (EmModule, "set_comm_inactivity_timeout", (VALUE(*)(...))t_set_comm_inactivity_timeout, 2);
|
1018
|
+
rb_define_module_function (EmModule, "set_rlimit_nofile", (VALUE(*)(...))t_set_rlimit_nofile, 1);
|
1019
|
+
rb_define_module_function (EmModule, "get_connection_count", (VALUE(*)(...))t_get_connection_count, 0);
|
1020
|
+
|
1021
|
+
rb_define_module_function (EmModule, "epoll", (VALUE(*)(...))t__epoll, 0);
|
1022
|
+
rb_define_module_function (EmModule, "epoll=", (VALUE(*)(...))t__epoll_set, 1);
|
1023
|
+
rb_define_module_function (EmModule, "epoll?", (VALUE(*)(...))t__epoll_p, 0);
|
1024
|
+
|
1025
|
+
rb_define_module_function (EmModule, "kqueue", (VALUE(*)(...))t__kqueue, 0);
|
1026
|
+
rb_define_module_function (EmModule, "kqueue=", (VALUE(*)(...))t__kqueue_set, 1);
|
1027
|
+
rb_define_module_function (EmModule, "kqueue?", (VALUE(*)(...))t__kqueue_p, 0);
|
1028
|
+
|
1029
|
+
rb_define_module_function (EmModule, "ssl?", (VALUE(*)(...))t__ssl_p, 0);
|
1030
|
+
|
1031
|
+
rb_define_method (EmConnection, "get_outbound_data_size", (VALUE(*)(...))conn_get_outbound_data_size, 0);
|
1032
|
+
rb_define_method (EmConnection, "associate_callback_target", (VALUE(*)(...))conn_associate_callback_target, 1);
|
1033
|
+
|
1034
|
+
rb_define_const (EmModule, "TimerFired", INT2NUM(100));
|
1035
|
+
rb_define_const (EmModule, "ConnectionData", INT2NUM(101));
|
1036
|
+
rb_define_const (EmModule, "ConnectionUnbound", INT2NUM(102));
|
1037
|
+
rb_define_const (EmModule, "ConnectionAccepted", INT2NUM(103));
|
1038
|
+
rb_define_const (EmModule, "ConnectionCompleted", INT2NUM(104));
|
1039
|
+
rb_define_const (EmModule, "LoopbreakSignalled", INT2NUM(105));
|
1040
|
+
|
1041
|
+
rb_define_const (EmModule, "ConnectionNotifyReadable", INT2NUM(106));
|
1042
|
+
rb_define_const (EmModule, "ConnectionNotifyWritable", INT2NUM(107));
|
1043
|
+
|
1044
|
+
rb_define_const (EmModule, "SslHandshakeCompleted", INT2NUM(108));
|
1045
|
+
|
1046
|
+
}
|
1047
|
+
|