sidekick-client 0.2.1 → 0.2.2

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