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,827 +0,0 @@
1
- /*****************************************************************************
2
-
3
- $Id$
4
-
5
- File: cmain.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
-
22
- /* 21Sep09: ruby 1.9 defines macros for common i/o functions that point to rb_w32_* implementations.
23
- We need to undef the stat to fix a build failure in evma_send_file_data_to_connection.
24
- See http://groups.google.com/group/eventmachine/browse_thread/thread/fc60d9bb738ffc71
25
- */
26
- #if defined(BUILD_FOR_RUBY) && defined(OS_WIN32)
27
- #undef stat
28
- #endif
29
-
30
- static EventMachine_t *EventMachine;
31
- static int bUseEpoll = 0;
32
- static int bUseKqueue = 0;
33
-
34
- extern "C" void ensure_eventmachine (const char *caller = "unknown caller")
35
- {
36
- if (!EventMachine) {
37
- const int err_size = 128;
38
- char err_string[err_size];
39
- snprintf (err_string, err_size, "eventmachine not initialized: %s", caller);
40
- #ifdef BUILD_FOR_RUBY
41
- rb_raise(rb_eRuntimeError, "%s", err_string);
42
- #else
43
- throw std::runtime_error (err_string);
44
- #endif
45
- }
46
- }
47
-
48
- /***********************
49
- evma_initialize_library
50
- ***********************/
51
-
52
- extern "C" void evma_initialize_library (void(*cb)(const unsigned long, int, const char*, const unsigned long))
53
- {
54
- // Probably a bad idea to mess with the signal mask of a process
55
- // we're just being linked into.
56
- //InstallSignalHandlers();
57
- if (EventMachine)
58
- #ifdef BUILD_FOR_RUBY
59
- rb_raise(rb_eRuntimeError, "eventmachine already initialized: evma_initialize_library");
60
- #else
61
- throw std::runtime_error ("eventmachine already initialized: evma_initialize_library");
62
- #endif
63
- EventMachine = new EventMachine_t (cb);
64
- if (bUseEpoll)
65
- EventMachine->_UseEpoll();
66
- if (bUseKqueue)
67
- EventMachine->_UseKqueue();
68
- }
69
-
70
-
71
- /********************
72
- evma_release_library
73
- ********************/
74
-
75
- extern "C" void evma_release_library()
76
- {
77
- ensure_eventmachine("evma_release_library");
78
- delete EventMachine;
79
- EventMachine = NULL;
80
- }
81
-
82
-
83
- /****************
84
- evma_run_machine
85
- ****************/
86
-
87
- extern "C" void evma_run_machine()
88
- {
89
- ensure_eventmachine("evma_run_machine");
90
- EventMachine->Run();
91
- }
92
-
93
-
94
- /**************************
95
- evma_install_oneshot_timer
96
- **************************/
97
-
98
- extern "C" const unsigned long evma_install_oneshot_timer (int seconds)
99
- {
100
- ensure_eventmachine("evma_install_oneshot_timer");
101
- return EventMachine->InstallOneshotTimer (seconds);
102
- }
103
-
104
-
105
- /**********************
106
- evma_connect_to_server
107
- **********************/
108
-
109
- extern "C" const unsigned long evma_connect_to_server (const char *bind_addr, int bind_port, const char *server, int port)
110
- {
111
- ensure_eventmachine("evma_connect_to_server");
112
- return EventMachine->ConnectToServer (bind_addr, bind_port, server, port);
113
- }
114
-
115
- /***************************
116
- evma_connect_to_unix_server
117
- ***************************/
118
-
119
- extern "C" const unsigned long evma_connect_to_unix_server (const char *server)
120
- {
121
- ensure_eventmachine("evma_connect_to_unix_server");
122
- return EventMachine->ConnectToUnixServer (server);
123
- }
124
-
125
- /**************
126
- evma_attach_fd
127
- **************/
128
-
129
- extern "C" const unsigned long evma_attach_fd (int file_descriptor, int watch_mode)
130
- {
131
- ensure_eventmachine("evma_attach_fd");
132
- return EventMachine->AttachFD (file_descriptor, watch_mode ? true : false);
133
- }
134
-
135
- /**************
136
- evma_detach_fd
137
- **************/
138
-
139
- extern "C" int evma_detach_fd (const unsigned long binding)
140
- {
141
- ensure_eventmachine("evma_detach_fd");
142
- EventableDescriptor *ed = dynamic_cast <EventableDescriptor*> (Bindable_t::GetObject (binding));
143
- if (ed)
144
- return EventMachine->DetachFD (ed);
145
- else
146
- #ifdef BUILD_FOR_RUBY
147
- rb_raise(rb_eRuntimeError, "invalid binding to detach");
148
- #else
149
- throw std::runtime_error ("invalid binding to detach");
150
- #endif
151
- }
152
-
153
- /************************
154
- evma_get_file_descriptor
155
- ************************/
156
-
157
- extern "C" int evma_get_file_descriptor (const unsigned long binding)
158
- {
159
- ensure_eventmachine("evma_get_file_descriptor");
160
- EventableDescriptor *ed = dynamic_cast <EventableDescriptor*> (Bindable_t::GetObject (binding));
161
- if (ed)
162
- return ed->GetSocket();
163
- else
164
- #ifdef BUILD_FOR_RUBY
165
- rb_raise(rb_eRuntimeError, "invalid binding to get_fd");
166
- #else
167
- throw std::runtime_error ("invalid binding to get_fd");
168
- #endif
169
- }
170
-
171
- /***********************
172
- evma_is_notify_readable
173
- ***********************/
174
-
175
- extern "C" int evma_is_notify_readable (const unsigned long binding)
176
- {
177
- ConnectionDescriptor *cd = dynamic_cast <ConnectionDescriptor*> (Bindable_t::GetObject (binding));
178
- if (cd)
179
- return cd->IsNotifyReadable() ? 1 : 0;
180
- return -1;
181
- }
182
-
183
- /************************
184
- evma_set_notify_readable
185
- ************************/
186
-
187
- extern "C" void evma_set_notify_readable (const unsigned long binding, int mode)
188
- {
189
- ConnectionDescriptor *cd = dynamic_cast <ConnectionDescriptor*> (Bindable_t::GetObject (binding));
190
- if (cd)
191
- cd->SetNotifyReadable (mode ? true : false);
192
- }
193
-
194
- /***********************
195
- evma_is_notify_writable
196
- ***********************/
197
-
198
- extern "C" int evma_is_notify_writable (const unsigned long binding)
199
- {
200
- ConnectionDescriptor *cd = dynamic_cast <ConnectionDescriptor*> (Bindable_t::GetObject (binding));
201
- if (cd)
202
- return cd->IsNotifyWritable() ? 1 : 0;
203
- return -1;
204
- }
205
-
206
- /************************
207
- evma_set_notify_writable
208
- ************************/
209
-
210
- extern "C" void evma_set_notify_writable (const unsigned long binding, int mode)
211
- {
212
- ConnectionDescriptor *cd = dynamic_cast <ConnectionDescriptor*> (Bindable_t::GetObject (binding));
213
- if (cd)
214
- cd->SetNotifyWritable (mode ? true : false);
215
- }
216
-
217
- /**********
218
- evma_pause
219
- **********/
220
-
221
- extern "C" int evma_pause (const unsigned long binding)
222
- {
223
- ConnectionDescriptor *cd = dynamic_cast <ConnectionDescriptor*> (Bindable_t::GetObject (binding));
224
- if (cd)
225
- return cd->Pause() ? 1 : 0;
226
-
227
- return 0;
228
- }
229
-
230
- /***********
231
- evma_resume
232
- ***********/
233
-
234
- extern "C" int evma_resume (const unsigned long binding)
235
- {
236
- ConnectionDescriptor *cd = dynamic_cast <ConnectionDescriptor*> (Bindable_t::GetObject (binding));
237
- if (cd)
238
- return cd->Resume() ? 1 : 0;
239
-
240
- return 0;
241
- }
242
-
243
- /**************
244
- evma_is_paused
245
- **************/
246
-
247
- extern "C" int evma_is_paused (const unsigned long binding)
248
- {
249
- ConnectionDescriptor *cd = dynamic_cast <ConnectionDescriptor*> (Bindable_t::GetObject (binding));
250
- if (cd)
251
- return cd->IsPaused() ? 1 : 0;
252
-
253
- return 0;
254
- }
255
-
256
- /**********************
257
- evma_create_tcp_server
258
- **********************/
259
-
260
- extern "C" const unsigned long evma_create_tcp_server (const char *address, int port)
261
- {
262
- ensure_eventmachine("evma_create_tcp_server");
263
- return EventMachine->CreateTcpServer (address, port);
264
- }
265
-
266
- /******************************
267
- evma_create_unix_domain_server
268
- ******************************/
269
-
270
- extern "C" const unsigned long evma_create_unix_domain_server (const char *filename)
271
- {
272
- ensure_eventmachine("evma_create_unix_domain_server");
273
- return EventMachine->CreateUnixDomainServer (filename);
274
- }
275
-
276
- /*************************
277
- evma_open_datagram_socket
278
- *************************/
279
-
280
- extern "C" const unsigned long evma_open_datagram_socket (const char *address, int port)
281
- {
282
- ensure_eventmachine("evma_open_datagram_socket");
283
- return EventMachine->OpenDatagramSocket (address, port);
284
- }
285
-
286
- /******************
287
- evma_open_keyboard
288
- ******************/
289
-
290
- extern "C" const unsigned long evma_open_keyboard()
291
- {
292
- ensure_eventmachine("evma_open_keyboard");
293
- return EventMachine->OpenKeyboard();
294
- }
295
-
296
- /*******************
297
- evma_watch_filename
298
- *******************/
299
-
300
- extern "C" const unsigned long evma_watch_filename (const char *fname)
301
- {
302
- ensure_eventmachine("evma_watch_filename");
303
- return EventMachine->WatchFile(fname);
304
- }
305
-
306
- /*********************
307
- evma_unwatch_filename
308
- *********************/
309
-
310
- extern "C" void evma_unwatch_filename (const unsigned long sig)
311
- {
312
- ensure_eventmachine("evma_unwatch_file");
313
- EventMachine->UnwatchFile(sig);
314
- }
315
-
316
- /**************
317
- evma_watch_pid
318
- **************/
319
-
320
- extern "C" const unsigned long evma_watch_pid (int pid)
321
- {
322
- ensure_eventmachine("evma_watch_pid");
323
- return EventMachine->WatchPid(pid);
324
- }
325
-
326
- /****************
327
- evma_unwatch_pid
328
- ****************/
329
-
330
- extern "C" void evma_unwatch_pid (const unsigned long sig)
331
- {
332
- ensure_eventmachine("evma_unwatch_pid");
333
- EventMachine->UnwatchPid(sig);
334
- }
335
-
336
- /****************************
337
- evma_send_data_to_connection
338
- ****************************/
339
-
340
- extern "C" int evma_send_data_to_connection (const unsigned long binding, const char *data, int data_length)
341
- {
342
- ensure_eventmachine("evma_send_data_to_connection");
343
- return ConnectionDescriptor::SendDataToConnection (binding, data, data_length);
344
- }
345
-
346
- /******************
347
- evma_send_datagram
348
- ******************/
349
-
350
- extern "C" int evma_send_datagram (const unsigned long binding, const char *data, int data_length, const char *address, int port)
351
- {
352
- ensure_eventmachine("evma_send_datagram");
353
- return DatagramDescriptor::SendDatagram (binding, data, data_length, address, port);
354
- }
355
-
356
-
357
- /*********************
358
- evma_close_connection
359
- *********************/
360
-
361
- extern "C" void evma_close_connection (const unsigned long binding, int after_writing)
362
- {
363
- ensure_eventmachine("evma_close_connection");
364
- ConnectionDescriptor::CloseConnection (binding, (after_writing ? true : false));
365
- }
366
-
367
- /***********************************
368
- evma_report_connection_error_status
369
- ***********************************/
370
-
371
- extern "C" int evma_report_connection_error_status (const unsigned long binding)
372
- {
373
- ensure_eventmachine("evma_report_connection_error_status");
374
- return ConnectionDescriptor::ReportErrorStatus (binding);
375
- }
376
-
377
- /********************
378
- evma_stop_tcp_server
379
- ********************/
380
-
381
- extern "C" void evma_stop_tcp_server (const unsigned long binding)
382
- {
383
- ensure_eventmachine("evma_stop_tcp_server");
384
- AcceptorDescriptor::StopAcceptor (binding);
385
- }
386
-
387
-
388
- /*****************
389
- evma_stop_machine
390
- *****************/
391
-
392
- extern "C" void evma_stop_machine()
393
- {
394
- ensure_eventmachine("evma_stop_machine");
395
- EventMachine->ScheduleHalt();
396
- }
397
-
398
-
399
- /**************
400
- evma_start_tls
401
- **************/
402
-
403
- extern "C" void evma_start_tls (const unsigned long binding)
404
- {
405
- ensure_eventmachine("evma_start_tls");
406
- EventableDescriptor *ed = dynamic_cast <EventableDescriptor*> (Bindable_t::GetObject (binding));
407
- if (ed)
408
- ed->StartTls();
409
- }
410
-
411
- /******************
412
- evma_set_tls_parms
413
- ******************/
414
-
415
- extern "C" void evma_set_tls_parms (const unsigned long binding, const char *privatekey_filename, const char *certchain_filename, int verify_peer)
416
- {
417
- ensure_eventmachine("evma_set_tls_parms");
418
- EventableDescriptor *ed = dynamic_cast <EventableDescriptor*> (Bindable_t::GetObject (binding));
419
- if (ed)
420
- ed->SetTlsParms (privatekey_filename, certchain_filename, (verify_peer == 1 ? true : false));
421
- }
422
-
423
- /******************
424
- evma_get_peer_cert
425
- ******************/
426
-
427
- #ifdef WITH_SSL
428
- extern "C" X509 *evma_get_peer_cert (const unsigned long binding)
429
- {
430
- ensure_eventmachine("evma_get_peer_cert");
431
- EventableDescriptor *ed = dynamic_cast <EventableDescriptor*> (Bindable_t::GetObject (binding));
432
- if (ed)
433
- return ed->GetPeerCert();
434
- return NULL;
435
- }
436
- #endif
437
-
438
- /********************
439
- evma_accept_ssl_peer
440
- ********************/
441
-
442
- #ifdef WITH_SSL
443
- extern "C" void evma_accept_ssl_peer (const unsigned long binding)
444
- {
445
- ensure_eventmachine("evma_accept_ssl_peer");
446
- ConnectionDescriptor *cd = dynamic_cast <ConnectionDescriptor*> (Bindable_t::GetObject (binding));
447
- if (cd)
448
- cd->AcceptSslPeer();
449
- }
450
- #endif
451
-
452
- /*****************
453
- evma_get_peername
454
- *****************/
455
-
456
- extern "C" int evma_get_peername (const unsigned long binding, struct sockaddr *sa)
457
- {
458
- ensure_eventmachine("evma_get_peername");
459
- EventableDescriptor *ed = dynamic_cast <EventableDescriptor*> (Bindable_t::GetObject (binding));
460
- if (ed) {
461
- return ed->GetPeername (sa) ? 1 : 0;
462
- }
463
- else
464
- return 0;
465
- }
466
-
467
- /*****************
468
- evma_get_sockname
469
- *****************/
470
-
471
- extern "C" int evma_get_sockname (const unsigned long binding, struct sockaddr *sa)
472
- {
473
- ensure_eventmachine("evma_get_sockname");
474
- EventableDescriptor *ed = dynamic_cast <EventableDescriptor*> (Bindable_t::GetObject (binding));
475
- if (ed) {
476
- return ed->GetSockname (sa) ? 1 : 0;
477
- }
478
- else
479
- return 0;
480
- }
481
-
482
- /***********************
483
- evma_get_subprocess_pid
484
- ***********************/
485
-
486
- extern "C" int evma_get_subprocess_pid (const unsigned long binding, pid_t *pid)
487
- {
488
- ensure_eventmachine("evma_get_subprocess_pid");
489
- #ifdef OS_UNIX
490
- PipeDescriptor *pd = dynamic_cast <PipeDescriptor*> (Bindable_t::GetObject (binding));
491
- if (pd) {
492
- return pd->GetSubprocessPid (pid) ? 1 : 0;
493
- }
494
- else if (pid && EventMachine->SubprocessPid) {
495
- *pid = EventMachine->SubprocessPid;
496
- return 1;
497
- }
498
- else
499
- return 0;
500
- #else
501
- return 0;
502
- #endif
503
- }
504
-
505
- /**************************
506
- evma_get_subprocess_status
507
- **************************/
508
-
509
- extern "C" int evma_get_subprocess_status (const unsigned long binding, int *status)
510
- {
511
- ensure_eventmachine("evma_get_subprocess_status");
512
- if (status) {
513
- *status = EventMachine->SubprocessExitStatus;
514
- return 1;
515
- }
516
- else
517
- return 0;
518
- }
519
-
520
- /*************************
521
- evma_get_connection_count
522
- *************************/
523
-
524
- extern "C" int evma_get_connection_count()
525
- {
526
- ensure_eventmachine("evma_get_connection_count");
527
- return EventMachine->GetConnectionCount();
528
- }
529
-
530
- /*********************
531
- evma_signal_loopbreak
532
- *********************/
533
-
534
- extern "C" void evma_signal_loopbreak()
535
- {
536
- ensure_eventmachine("evma_signal_loopbreak");
537
- EventMachine->SignalLoopBreaker();
538
- }
539
-
540
-
541
-
542
- /****************
543
- evma__write_file
544
- ****************/
545
-
546
- extern "C" const unsigned long evma__write_file (const char *filename)
547
- {
548
- ensure_eventmachine("evma__write_file");
549
- return EventMachine->_OpenFileForWriting (filename);
550
- }
551
-
552
-
553
- /********************************
554
- evma_get_comm_inactivity_timeout
555
- ********************************/
556
-
557
- extern "C" float evma_get_comm_inactivity_timeout (const unsigned long binding)
558
- {
559
- ensure_eventmachine("evma_get_comm_inactivity_timeout");
560
- EventableDescriptor *ed = dynamic_cast <EventableDescriptor*> (Bindable_t::GetObject (binding));
561
- if (ed) {
562
- return ed->GetCommInactivityTimeout();
563
- }
564
- else
565
- return 0.0; //Perhaps this should be an exception. Access to an unknown binding.
566
- }
567
-
568
- /********************************
569
- evma_set_comm_inactivity_timeout
570
- ********************************/
571
-
572
- extern "C" int evma_set_comm_inactivity_timeout (const unsigned long binding, float value)
573
- {
574
- ensure_eventmachine("evma_set_comm_inactivity_timeout");
575
- EventableDescriptor *ed = dynamic_cast <EventableDescriptor*> (Bindable_t::GetObject (binding));
576
- if (ed) {
577
- return ed->SetCommInactivityTimeout (value);
578
- }
579
- else
580
- return 0; //Perhaps this should be an exception. Access to an unknown binding.
581
- }
582
-
583
-
584
- /********************************
585
- evma_get_pending_connect_timeout
586
- ********************************/
587
-
588
- extern "C" float evma_get_pending_connect_timeout (const unsigned long binding)
589
- {
590
- ensure_eventmachine("evma_get_pending_connect_timeout");
591
- EventableDescriptor *ed = dynamic_cast <EventableDescriptor*> (Bindable_t::GetObject (binding));
592
- if (ed) {
593
- return ed->GetPendingConnectTimeout();
594
- }
595
- else
596
- return 0.0;
597
- }
598
-
599
-
600
- /********************************
601
- evma_set_pending_connect_timeout
602
- ********************************/
603
-
604
- extern "C" int evma_set_pending_connect_timeout (const unsigned long binding, float value)
605
- {
606
- ensure_eventmachine("evma_set_pending_connect_timeout");
607
- EventableDescriptor *ed = dynamic_cast <EventableDescriptor*> (Bindable_t::GetObject (binding));
608
- if (ed) {
609
- return ed->SetPendingConnectTimeout (value);
610
- }
611
- else
612
- return 0;
613
- }
614
-
615
-
616
- /**********************
617
- evma_set_timer_quantum
618
- **********************/
619
-
620
- extern "C" void evma_set_timer_quantum (int interval)
621
- {
622
- ensure_eventmachine("evma_set_timer_quantum");
623
- EventMachine->SetTimerQuantum (interval);
624
- }
625
-
626
-
627
- /************************
628
- evma_get_max_timer_count
629
- ************************/
630
-
631
- extern "C" int evma_get_max_timer_count()
632
- {
633
- return EventMachine_t::GetMaxTimerCount();
634
- }
635
-
636
-
637
- /************************
638
- evma_set_max_timer_count
639
- ************************/
640
-
641
- extern "C" void evma_set_max_timer_count (int ct)
642
- {
643
- // This may only be called if the reactor is not running.
644
-
645
- if (EventMachine)
646
- #ifdef BUILD_FOR_RUBY
647
- rb_raise(rb_eRuntimeError, "eventmachine already initialized: evma_set_max_timer_count");
648
- #else
649
- throw std::runtime_error ("eventmachine already initialized: evma_set_max_timer_count");
650
- #endif
651
- EventMachine_t::SetMaxTimerCount (ct);
652
- }
653
-
654
- /******************
655
- evma_setuid_string
656
- ******************/
657
-
658
- extern "C" void evma_setuid_string (const char *username)
659
- {
660
- // We do NOT need to be running an EM instance because this method is static.
661
- EventMachine_t::SetuidString (username);
662
- }
663
-
664
-
665
- /**********
666
- evma_popen
667
- **********/
668
-
669
- extern "C" const unsigned long evma_popen (char * const*cmd_strings)
670
- {
671
- ensure_eventmachine("evma_popen");
672
- return EventMachine->Socketpair (cmd_strings);
673
- }
674
-
675
-
676
- /***************************
677
- evma_get_outbound_data_size
678
- ***************************/
679
-
680
- extern "C" int evma_get_outbound_data_size (const unsigned long binding)
681
- {
682
- ensure_eventmachine("evma_get_outbound_data_size");
683
- EventableDescriptor *ed = dynamic_cast <EventableDescriptor*> (Bindable_t::GetObject (binding));
684
- return ed ? ed->GetOutboundDataSize() : 0;
685
- }
686
-
687
-
688
- /**************
689
- evma_set_epoll
690
- **************/
691
-
692
- extern "C" void evma_set_epoll (int use)
693
- {
694
- bUseEpoll = !!use;
695
- }
696
-
697
- /***************
698
- evma_set_kqueue
699
- ***************/
700
-
701
- extern "C" void evma_set_kqueue (int use)
702
- {
703
- bUseKqueue = !!use;
704
- }
705
-
706
-
707
- /**********************
708
- evma_set_rlimit_nofile
709
- **********************/
710
-
711
- extern "C" int evma_set_rlimit_nofile (int nofiles)
712
- {
713
- return EventMachine_t::SetRlimitNofile (nofiles);
714
- }
715
-
716
-
717
- /*********************************
718
- evma_send_file_data_to_connection
719
- *********************************/
720
-
721
- extern "C" int evma_send_file_data_to_connection (const unsigned long binding, const char *filename)
722
- {
723
- /* This is a sugaring over send_data_to_connection that reads a file into a
724
- * locally-allocated buffer, and sends the file data to the remote peer.
725
- * Return the number of bytes written to the caller.
726
- * TODO, needs to impose a limit on the file size. This is intended only for
727
- * small files. (I don't know, maybe 8K or less.) For larger files, use interleaved
728
- * I/O to avoid slowing the rest of the system down.
729
- * TODO: we should return a code rather than barf, in case of file-not-found.
730
- * TODO, does this compile on Windows?
731
- * TODO, given that we want this to work only with small files, how about allocating
732
- * the buffer on the stack rather than the heap?
733
- *
734
- * Modified 25Jul07. This now returns -1 on file-too-large; 0 for success, and a positive
735
- * errno in case of other errors.
736
- *
737
- * Contributed by Kirk Haines.
738
- */
739
-
740
- char data[32*1024];
741
- int r;
742
-
743
- ensure_eventmachine("evma_send_file_data_to_connection");
744
-
745
- int Fd = open (filename, O_RDONLY);
746
-
747
- if (Fd < 0)
748
- return errno;
749
- // From here on, all early returns MUST close Fd.
750
-
751
- struct stat st;
752
- if (fstat (Fd, &st)) {
753
- int e = errno;
754
- close (Fd);
755
- return e;
756
- }
757
-
758
- off_t filesize = st.st_size;
759
- if (filesize <= 0) {
760
- close (Fd);
761
- return 0;
762
- }
763
- else if (filesize > (off_t) sizeof(data)) {
764
- close (Fd);
765
- return -1;
766
- }
767
-
768
-
769
- r = read (Fd, data, filesize);
770
- if (r != filesize) {
771
- int e = errno;
772
- close (Fd);
773
- return e;
774
- }
775
- evma_send_data_to_connection (binding, data, r);
776
- close (Fd);
777
-
778
- return 0;
779
- }
780
-
781
-
782
- /****************
783
- evma_start_proxy
784
- *****************/
785
-
786
- extern "C" void evma_start_proxy (const unsigned long from, const unsigned long to, const unsigned long bufsize)
787
- {
788
- ensure_eventmachine("evma_start_proxy");
789
- EventableDescriptor *ed = dynamic_cast <EventableDescriptor*> (Bindable_t::GetObject (from));
790
- if (ed)
791
- ed->StartProxy(to, bufsize);
792
- }
793
-
794
-
795
- /***************
796
- evma_stop_proxy
797
- ****************/
798
-
799
- extern "C" void evma_stop_proxy (const unsigned long from)
800
- {
801
- ensure_eventmachine("evma_stop_proxy");
802
- EventableDescriptor *ed = dynamic_cast <EventableDescriptor*> (Bindable_t::GetObject (from));
803
- if (ed)
804
- ed->StopProxy();
805
- }
806
-
807
-
808
- /***************************
809
- evma_get_heartbeat_interval
810
- ****************************/
811
-
812
- extern "C" float evma_get_heartbeat_interval()
813
- {
814
- ensure_eventmachine("evma_get_heartbeat_interval");
815
- return EventMachine->GetHeartbeatInterval();
816
- }
817
-
818
-
819
- /***************************
820
- evma_set_heartbeat_interval
821
- ****************************/
822
-
823
- extern "C" int evma_set_heartbeat_interval(float interval)
824
- {
825
- ensure_eventmachine("evma_set_heartbeat_interval");
826
- return EventMachine->SetHeartbeatInterval(interval);
827
- }