sensu-em 2.0.0-java
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +21 -0
- data/.travis.yml +12 -0
- data/.yardopts +7 -0
- data/CHANGELOG.md +33 -0
- data/GNU +281 -0
- data/Gemfile +2 -0
- data/LICENSE +60 -0
- data/README.md +109 -0
- data/Rakefile +20 -0
- data/docs/DocumentationGuidesIndex.md +27 -0
- data/docs/GettingStarted.md +521 -0
- data/docs/old/ChangeLog +211 -0
- data/docs/old/DEFERRABLES +246 -0
- data/docs/old/EPOLL +141 -0
- data/docs/old/INSTALL +13 -0
- data/docs/old/KEYBOARD +42 -0
- data/docs/old/LEGAL +25 -0
- data/docs/old/LIGHTWEIGHT_CONCURRENCY +130 -0
- data/docs/old/PURE_RUBY +75 -0
- data/docs/old/RELEASE_NOTES +94 -0
- data/docs/old/SMTP +4 -0
- data/docs/old/SPAWNED_PROCESSES +148 -0
- data/docs/old/TODO +8 -0
- data/eventmachine.gemspec +38 -0
- data/examples/guides/getting_started/01_eventmachine_echo_server.rb +18 -0
- data/examples/guides/getting_started/02_eventmachine_echo_server_that_recognizes_exit_command.rb +22 -0
- data/examples/guides/getting_started/03_simple_chat_server.rb +149 -0
- data/examples/guides/getting_started/04_simple_chat_server_step_one.rb +27 -0
- data/examples/guides/getting_started/05_simple_chat_server_step_two.rb +43 -0
- data/examples/guides/getting_started/06_simple_chat_server_step_three.rb +98 -0
- data/examples/guides/getting_started/07_simple_chat_server_step_four.rb +121 -0
- data/examples/guides/getting_started/08_simple_chat_server_step_five.rb +141 -0
- data/examples/old/ex_channel.rb +43 -0
- data/examples/old/ex_queue.rb +2 -0
- data/examples/old/ex_tick_loop_array.rb +15 -0
- data/examples/old/ex_tick_loop_counter.rb +32 -0
- data/examples/old/helper.rb +2 -0
- data/ext/binder.cpp +124 -0
- data/ext/binder.h +46 -0
- data/ext/cmain.cpp +887 -0
- data/ext/ed.cpp +1988 -0
- data/ext/ed.h +422 -0
- data/ext/em.cpp +2352 -0
- data/ext/em.h +253 -0
- data/ext/eventmachine.h +128 -0
- data/ext/extconf.rb +179 -0
- data/ext/fastfilereader/extconf.rb +103 -0
- data/ext/fastfilereader/mapper.cpp +214 -0
- data/ext/fastfilereader/mapper.h +59 -0
- data/ext/fastfilereader/rubymain.cpp +127 -0
- data/ext/kb.cpp +79 -0
- data/ext/page.cpp +107 -0
- data/ext/page.h +51 -0
- data/ext/pipe.cpp +347 -0
- data/ext/project.h +161 -0
- data/ext/rubymain.cpp +1318 -0
- data/ext/ssl.cpp +468 -0
- data/ext/ssl.h +94 -0
- data/java/.classpath +6 -0
- data/java/.gitignore +1 -0
- data/java/.project +17 -0
- data/java/src/com/rubyeventmachine/DatagramPacket.java +13 -0
- data/java/src/com/rubyeventmachine/EmReactor.java +529 -0
- data/java/src/com/rubyeventmachine/EmReactorException.java +40 -0
- data/java/src/com/rubyeventmachine/EventCallback.java +7 -0
- data/java/src/com/rubyeventmachine/EventCode.java +26 -0
- data/java/src/com/rubyeventmachine/EventableChannel.java +130 -0
- data/java/src/com/rubyeventmachine/EventableDatagramChannel.java +180 -0
- data/java/src/com/rubyeventmachine/EventableSocketChannel.java +405 -0
- data/java/src/com/rubyeventmachine/SslBox.java +310 -0
- data/lib/em/buftok.rb +110 -0
- data/lib/em/callback.rb +58 -0
- data/lib/em/channel.rb +64 -0
- data/lib/em/completion.rb +304 -0
- data/lib/em/connection.rb +712 -0
- data/lib/em/deferrable/pool.rb +2 -0
- data/lib/em/deferrable.rb +210 -0
- data/lib/em/file_watch.rb +73 -0
- data/lib/em/future.rb +61 -0
- data/lib/em/iterator.rb +231 -0
- data/lib/em/messages.rb +66 -0
- data/lib/em/pool.rb +151 -0
- data/lib/em/process_watch.rb +45 -0
- data/lib/em/processes.rb +123 -0
- data/lib/em/protocols/header_and_content.rb +138 -0
- data/lib/em/protocols/httpclient.rb +279 -0
- data/lib/em/protocols/httpclient2.rb +600 -0
- data/lib/em/protocols/line_and_text.rb +125 -0
- data/lib/em/protocols/line_protocol.rb +29 -0
- data/lib/em/protocols/linetext2.rb +161 -0
- data/lib/em/protocols/memcache.rb +331 -0
- data/lib/em/protocols/object_protocol.rb +46 -0
- data/lib/em/protocols/postgres3.rb +246 -0
- data/lib/em/protocols/saslauth.rb +175 -0
- data/lib/em/protocols/smtpclient.rb +365 -0
- data/lib/em/protocols/smtpserver.rb +643 -0
- data/lib/em/protocols/socks4.rb +66 -0
- data/lib/em/protocols/stomp.rb +205 -0
- data/lib/em/protocols/tcptest.rb +54 -0
- data/lib/em/protocols.rb +37 -0
- data/lib/em/pure_ruby.rb +1017 -0
- data/lib/em/queue.rb +71 -0
- data/lib/em/resolver.rb +209 -0
- data/lib/em/spawnable.rb +84 -0
- data/lib/em/streamer.rb +118 -0
- data/lib/em/threaded_resource.rb +90 -0
- data/lib/em/tick_loop.rb +85 -0
- data/lib/em/timers.rb +61 -0
- data/lib/em/version.rb +3 -0
- data/lib/eventmachine.rb +1553 -0
- data/lib/jeventmachine.rb +321 -0
- data/lib/rubyeventmachine.jar +0 -0
- data/rakelib/cpp.rake_example +77 -0
- data/rakelib/package.rake +98 -0
- data/rakelib/test.rake +8 -0
- data/tests/client.crt +31 -0
- data/tests/client.key +51 -0
- data/tests/em_test_helper.rb +64 -0
- data/tests/server.crt +36 -0
- data/tests/server.key +51 -0
- data/tests/test_attach.rb +150 -0
- data/tests/test_basic.rb +294 -0
- data/tests/test_channel.rb +62 -0
- data/tests/test_completion.rb +177 -0
- data/tests/test_connection_count.rb +53 -0
- data/tests/test_defer.rb +18 -0
- data/tests/test_deferrable.rb +35 -0
- data/tests/test_epoll.rb +145 -0
- data/tests/test_error_handler.rb +38 -0
- data/tests/test_exc.rb +28 -0
- data/tests/test_file_watch.rb +65 -0
- data/tests/test_futures.rb +170 -0
- data/tests/test_get_sock_opt.rb +37 -0
- data/tests/test_handler_check.rb +35 -0
- data/tests/test_hc.rb +155 -0
- data/tests/test_httpclient.rb +190 -0
- data/tests/test_httpclient2.rb +133 -0
- data/tests/test_idle_connection.rb +25 -0
- data/tests/test_inactivity_timeout.rb +54 -0
- data/tests/test_iterator.rb +97 -0
- data/tests/test_kb.rb +34 -0
- data/tests/test_line_protocol.rb +33 -0
- data/tests/test_ltp.rb +138 -0
- data/tests/test_ltp2.rb +288 -0
- data/tests/test_next_tick.rb +104 -0
- data/tests/test_object_protocol.rb +36 -0
- data/tests/test_pause.rb +102 -0
- data/tests/test_pending_connect_timeout.rb +52 -0
- data/tests/test_pool.rb +194 -0
- data/tests/test_process_watch.rb +48 -0
- data/tests/test_processes.rb +128 -0
- data/tests/test_proxy_connection.rb +180 -0
- data/tests/test_pure.rb +88 -0
- data/tests/test_queue.rb +50 -0
- data/tests/test_resolver.rb +55 -0
- data/tests/test_running.rb +14 -0
- data/tests/test_sasl.rb +47 -0
- data/tests/test_send_file.rb +217 -0
- data/tests/test_servers.rb +33 -0
- data/tests/test_set_sock_opt.rb +37 -0
- data/tests/test_shutdown_hooks.rb +23 -0
- data/tests/test_smtpclient.rb +55 -0
- data/tests/test_smtpserver.rb +57 -0
- data/tests/test_spawn.rb +293 -0
- data/tests/test_ssl_args.rb +78 -0
- data/tests/test_ssl_echo_data.rb +60 -0
- data/tests/test_ssl_methods.rb +56 -0
- data/tests/test_ssl_verify.rb +82 -0
- data/tests/test_stomp.rb +37 -0
- data/tests/test_system.rb +42 -0
- data/tests/test_threaded_resource.rb +53 -0
- data/tests/test_tick_loop.rb +59 -0
- data/tests/test_timers.rb +123 -0
- data/tests/test_ud.rb +8 -0
- data/tests/test_unbind_reason.rb +48 -0
- metadata +297 -0
data/ext/ed.h
ADDED
|
@@ -0,0 +1,422 @@
|
|
|
1
|
+
/*****************************************************************************
|
|
2
|
+
|
|
3
|
+
$Id$
|
|
4
|
+
|
|
5
|
+
File: ed.h
|
|
6
|
+
Date: 06Apr06
|
|
7
|
+
|
|
8
|
+
Copyright (C) 2006-07 by Francis Cianfrocca. All Rights Reserved.
|
|
9
|
+
Gmail: blackhedd
|
|
10
|
+
|
|
11
|
+
This program is free software; you can redistribute it and/or modify
|
|
12
|
+
it under the terms of either: 1) the GNU General Public License
|
|
13
|
+
as published by the Free Software Foundation; either version 2 of the
|
|
14
|
+
License, or (at your option) any later version; or 2) Ruby's License.
|
|
15
|
+
|
|
16
|
+
See the file COPYING for complete licensing information.
|
|
17
|
+
|
|
18
|
+
*****************************************************************************/
|
|
19
|
+
|
|
20
|
+
#ifndef __EventableDescriptor__H_
|
|
21
|
+
#define __EventableDescriptor__H_
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
class EventMachine_t; // forward reference
|
|
25
|
+
#ifdef WITH_SSL
|
|
26
|
+
class SslBox_t; // forward reference
|
|
27
|
+
#endif
|
|
28
|
+
|
|
29
|
+
bool SetSocketNonblocking (SOCKET);
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
/*************************
|
|
33
|
+
class EventableDescriptor
|
|
34
|
+
*************************/
|
|
35
|
+
|
|
36
|
+
class EventableDescriptor: public Bindable_t
|
|
37
|
+
{
|
|
38
|
+
public:
|
|
39
|
+
EventableDescriptor (int, EventMachine_t*);
|
|
40
|
+
virtual ~EventableDescriptor();
|
|
41
|
+
|
|
42
|
+
int GetSocket() {return MySocket;}
|
|
43
|
+
void SetSocketInvalid() { MySocket = INVALID_SOCKET; }
|
|
44
|
+
void Close();
|
|
45
|
+
|
|
46
|
+
virtual void Read() = 0;
|
|
47
|
+
virtual void Write() = 0;
|
|
48
|
+
virtual void Heartbeat() = 0;
|
|
49
|
+
|
|
50
|
+
// These methods tell us whether the descriptor
|
|
51
|
+
// should be selected or polled for read/write.
|
|
52
|
+
virtual bool SelectForRead() = 0;
|
|
53
|
+
virtual bool SelectForWrite() = 0;
|
|
54
|
+
|
|
55
|
+
// are we scheduled for a close, or in an error state, or already closed?
|
|
56
|
+
bool ShouldDelete();
|
|
57
|
+
// Do we have any data to write? This is used by ShouldDelete.
|
|
58
|
+
virtual int GetOutboundDataSize() {return 0;}
|
|
59
|
+
virtual bool IsWatchOnly(){ return bWatchOnly; }
|
|
60
|
+
|
|
61
|
+
virtual void ScheduleClose (bool after_writing);
|
|
62
|
+
bool IsCloseScheduled();
|
|
63
|
+
virtual void HandleError(){ ScheduleClose (false); }
|
|
64
|
+
|
|
65
|
+
void SetEventCallback (EMCallback);
|
|
66
|
+
|
|
67
|
+
virtual bool GetPeername (struct sockaddr*, socklen_t*) {return false;}
|
|
68
|
+
virtual bool GetSockname (struct sockaddr*, socklen_t*) {return false;}
|
|
69
|
+
virtual bool GetSubprocessPid (pid_t*) {return false;}
|
|
70
|
+
|
|
71
|
+
virtual void StartTls() {}
|
|
72
|
+
virtual void SetTlsParms (const char *, const char *, bool) {}
|
|
73
|
+
|
|
74
|
+
#ifdef WITH_SSL
|
|
75
|
+
virtual X509 *GetPeerCert() {return NULL;}
|
|
76
|
+
#endif
|
|
77
|
+
|
|
78
|
+
virtual uint64_t GetCommInactivityTimeout() {return 0;}
|
|
79
|
+
virtual int SetCommInactivityTimeout (uint64_t) {return 0;}
|
|
80
|
+
uint64_t GetPendingConnectTimeout();
|
|
81
|
+
int SetPendingConnectTimeout (uint64_t value);
|
|
82
|
+
uint64_t GetLastActivity() { return LastActivity; }
|
|
83
|
+
|
|
84
|
+
#ifdef HAVE_EPOLL
|
|
85
|
+
struct epoll_event *GetEpollEvent() { return &EpollEvent; }
|
|
86
|
+
#endif
|
|
87
|
+
|
|
88
|
+
virtual void StartProxy(const unsigned long, const unsigned long, const unsigned long);
|
|
89
|
+
virtual void StopProxy();
|
|
90
|
+
virtual unsigned long GetProxiedBytes(){ return ProxiedBytes; };
|
|
91
|
+
virtual void SetProxiedFrom(EventableDescriptor*, const unsigned long);
|
|
92
|
+
virtual int SendOutboundData(const char*,int){ return -1; }
|
|
93
|
+
virtual bool IsPaused(){ return bPaused; }
|
|
94
|
+
virtual bool Pause(){ bPaused = true; return bPaused; }
|
|
95
|
+
virtual bool Resume(){ bPaused = false; return bPaused; }
|
|
96
|
+
|
|
97
|
+
void SetUnbindReasonCode(int code){ UnbindReasonCode = code; }
|
|
98
|
+
virtual int ReportErrorStatus(){ return 0; }
|
|
99
|
+
virtual bool IsConnectPending(){ return false; }
|
|
100
|
+
virtual uint64_t GetNextHeartbeat();
|
|
101
|
+
|
|
102
|
+
private:
|
|
103
|
+
bool bCloseNow;
|
|
104
|
+
bool bCloseAfterWriting;
|
|
105
|
+
|
|
106
|
+
protected:
|
|
107
|
+
int MySocket;
|
|
108
|
+
bool bAttached;
|
|
109
|
+
bool bWatchOnly;
|
|
110
|
+
|
|
111
|
+
EMCallback EventCallback;
|
|
112
|
+
void _GenericInboundDispatch(const char*, int);
|
|
113
|
+
|
|
114
|
+
uint64_t CreatedAt;
|
|
115
|
+
bool bCallbackUnbind;
|
|
116
|
+
int UnbindReasonCode;
|
|
117
|
+
|
|
118
|
+
unsigned long BytesToProxy;
|
|
119
|
+
EventableDescriptor *ProxyTarget;
|
|
120
|
+
EventableDescriptor *ProxiedFrom;
|
|
121
|
+
unsigned long ProxiedBytes;
|
|
122
|
+
|
|
123
|
+
unsigned long MaxOutboundBufSize;
|
|
124
|
+
|
|
125
|
+
#ifdef HAVE_EPOLL
|
|
126
|
+
struct epoll_event EpollEvent;
|
|
127
|
+
#endif
|
|
128
|
+
|
|
129
|
+
EventMachine_t *MyEventMachine;
|
|
130
|
+
uint64_t PendingConnectTimeout;
|
|
131
|
+
uint64_t InactivityTimeout;
|
|
132
|
+
uint64_t LastActivity;
|
|
133
|
+
uint64_t NextHeartbeat;
|
|
134
|
+
bool bPaused;
|
|
135
|
+
};
|
|
136
|
+
|
|
137
|
+
|
|
138
|
+
|
|
139
|
+
/*************************
|
|
140
|
+
class LoopbreakDescriptor
|
|
141
|
+
*************************/
|
|
142
|
+
|
|
143
|
+
class LoopbreakDescriptor: public EventableDescriptor
|
|
144
|
+
{
|
|
145
|
+
public:
|
|
146
|
+
LoopbreakDescriptor (int, EventMachine_t*);
|
|
147
|
+
virtual ~LoopbreakDescriptor() {}
|
|
148
|
+
|
|
149
|
+
virtual void Read();
|
|
150
|
+
virtual void Write();
|
|
151
|
+
virtual void Heartbeat() {}
|
|
152
|
+
|
|
153
|
+
virtual bool SelectForRead() {return true;}
|
|
154
|
+
virtual bool SelectForWrite() {return false;}
|
|
155
|
+
};
|
|
156
|
+
|
|
157
|
+
|
|
158
|
+
/**************************
|
|
159
|
+
class ConnectionDescriptor
|
|
160
|
+
**************************/
|
|
161
|
+
|
|
162
|
+
class ConnectionDescriptor: public EventableDescriptor
|
|
163
|
+
{
|
|
164
|
+
public:
|
|
165
|
+
ConnectionDescriptor (int, EventMachine_t*);
|
|
166
|
+
virtual ~ConnectionDescriptor();
|
|
167
|
+
|
|
168
|
+
int SendOutboundData (const char*, int);
|
|
169
|
+
|
|
170
|
+
void SetConnectPending (bool f);
|
|
171
|
+
virtual void ScheduleClose (bool after_writing);
|
|
172
|
+
virtual void HandleError();
|
|
173
|
+
|
|
174
|
+
void SetNotifyReadable (bool);
|
|
175
|
+
void SetNotifyWritable (bool);
|
|
176
|
+
void SetAttached (bool);
|
|
177
|
+
void SetWatchOnly (bool);
|
|
178
|
+
|
|
179
|
+
bool Pause();
|
|
180
|
+
bool Resume();
|
|
181
|
+
|
|
182
|
+
bool IsNotifyReadable(){ return bNotifyReadable; }
|
|
183
|
+
bool IsNotifyWritable(){ return bNotifyWritable; }
|
|
184
|
+
|
|
185
|
+
virtual void Read();
|
|
186
|
+
virtual void Write();
|
|
187
|
+
virtual void Heartbeat();
|
|
188
|
+
|
|
189
|
+
virtual bool SelectForRead();
|
|
190
|
+
virtual bool SelectForWrite();
|
|
191
|
+
|
|
192
|
+
// Do we have any data to write? This is used by ShouldDelete.
|
|
193
|
+
virtual int GetOutboundDataSize() {return OutboundDataSize;}
|
|
194
|
+
|
|
195
|
+
virtual void StartTls();
|
|
196
|
+
virtual void SetTlsParms (const char *privkey_filename, const char *certchain_filename, bool verify_peer);
|
|
197
|
+
|
|
198
|
+
#ifdef WITH_SSL
|
|
199
|
+
virtual X509 *GetPeerCert();
|
|
200
|
+
virtual bool VerifySslPeer(const char*);
|
|
201
|
+
virtual void AcceptSslPeer();
|
|
202
|
+
#endif
|
|
203
|
+
|
|
204
|
+
void SetServerMode() {bIsServer = true;}
|
|
205
|
+
|
|
206
|
+
virtual bool GetPeername (struct sockaddr*, socklen_t*);
|
|
207
|
+
virtual bool GetSockname (struct sockaddr*, socklen_t*);
|
|
208
|
+
|
|
209
|
+
virtual uint64_t GetCommInactivityTimeout();
|
|
210
|
+
virtual int SetCommInactivityTimeout (uint64_t value);
|
|
211
|
+
|
|
212
|
+
virtual int ReportErrorStatus();
|
|
213
|
+
virtual bool IsConnectPending(){ return bConnectPending; }
|
|
214
|
+
|
|
215
|
+
protected:
|
|
216
|
+
struct OutboundPage {
|
|
217
|
+
OutboundPage (const char *b, int l, int o=0): Buffer(b), Length(l), Offset(o) {}
|
|
218
|
+
void Free() {if (Buffer) free (const_cast<char*>(Buffer)); }
|
|
219
|
+
const char *Buffer;
|
|
220
|
+
int Length;
|
|
221
|
+
int Offset;
|
|
222
|
+
};
|
|
223
|
+
|
|
224
|
+
protected:
|
|
225
|
+
bool bConnectPending;
|
|
226
|
+
|
|
227
|
+
bool bNotifyReadable;
|
|
228
|
+
bool bNotifyWritable;
|
|
229
|
+
|
|
230
|
+
bool bReadAttemptedAfterClose;
|
|
231
|
+
bool bWriteAttemptedAfterClose;
|
|
232
|
+
|
|
233
|
+
deque<OutboundPage> OutboundPages;
|
|
234
|
+
int OutboundDataSize;
|
|
235
|
+
|
|
236
|
+
#ifdef WITH_SSL
|
|
237
|
+
SslBox_t *SslBox;
|
|
238
|
+
std::string CertChainFilename;
|
|
239
|
+
std::string PrivateKeyFilename;
|
|
240
|
+
bool bHandshakeSignaled;
|
|
241
|
+
bool bSslVerifyPeer;
|
|
242
|
+
bool bSslPeerAccepted;
|
|
243
|
+
#endif
|
|
244
|
+
|
|
245
|
+
#ifdef HAVE_KQUEUE
|
|
246
|
+
bool bGotExtraKqueueEvent;
|
|
247
|
+
#endif
|
|
248
|
+
|
|
249
|
+
bool bIsServer;
|
|
250
|
+
|
|
251
|
+
private:
|
|
252
|
+
void _UpdateEvents();
|
|
253
|
+
void _UpdateEvents(bool, bool);
|
|
254
|
+
void _WriteOutboundData();
|
|
255
|
+
void _DispatchInboundData (const char *buffer, int size);
|
|
256
|
+
void _DispatchCiphertext();
|
|
257
|
+
int _SendRawOutboundData (const char*, int);
|
|
258
|
+
void _CheckHandshakeStatus();
|
|
259
|
+
|
|
260
|
+
};
|
|
261
|
+
|
|
262
|
+
|
|
263
|
+
/************************
|
|
264
|
+
class DatagramDescriptor
|
|
265
|
+
************************/
|
|
266
|
+
|
|
267
|
+
class DatagramDescriptor: public EventableDescriptor
|
|
268
|
+
{
|
|
269
|
+
public:
|
|
270
|
+
DatagramDescriptor (int, EventMachine_t*);
|
|
271
|
+
virtual ~DatagramDescriptor();
|
|
272
|
+
|
|
273
|
+
virtual void Read();
|
|
274
|
+
virtual void Write();
|
|
275
|
+
virtual void Heartbeat();
|
|
276
|
+
|
|
277
|
+
virtual bool SelectForRead() {return true;}
|
|
278
|
+
virtual bool SelectForWrite();
|
|
279
|
+
|
|
280
|
+
int SendOutboundData (const char*, int);
|
|
281
|
+
int SendOutboundDatagram (const char*, int, const char*, int);
|
|
282
|
+
|
|
283
|
+
// Do we have any data to write? This is used by ShouldDelete.
|
|
284
|
+
virtual int GetOutboundDataSize() {return OutboundDataSize;}
|
|
285
|
+
|
|
286
|
+
virtual bool GetPeername (struct sockaddr*, socklen_t*);
|
|
287
|
+
virtual bool GetSockname (struct sockaddr*, socklen_t*);
|
|
288
|
+
|
|
289
|
+
virtual uint64_t GetCommInactivityTimeout();
|
|
290
|
+
virtual int SetCommInactivityTimeout (uint64_t value);
|
|
291
|
+
|
|
292
|
+
protected:
|
|
293
|
+
struct OutboundPage {
|
|
294
|
+
OutboundPage (const char *b, int l, struct sockaddr_in f, int o=0): Buffer(b), Length(l), Offset(o), From(f) {}
|
|
295
|
+
void Free() {if (Buffer) free (const_cast<char*>(Buffer)); }
|
|
296
|
+
const char *Buffer;
|
|
297
|
+
int Length;
|
|
298
|
+
int Offset;
|
|
299
|
+
struct sockaddr_in From;
|
|
300
|
+
};
|
|
301
|
+
|
|
302
|
+
deque<OutboundPage> OutboundPages;
|
|
303
|
+
int OutboundDataSize;
|
|
304
|
+
|
|
305
|
+
struct sockaddr_in ReturnAddress;
|
|
306
|
+
};
|
|
307
|
+
|
|
308
|
+
|
|
309
|
+
/************************
|
|
310
|
+
class AcceptorDescriptor
|
|
311
|
+
************************/
|
|
312
|
+
|
|
313
|
+
class AcceptorDescriptor: public EventableDescriptor
|
|
314
|
+
{
|
|
315
|
+
public:
|
|
316
|
+
AcceptorDescriptor (int, EventMachine_t*);
|
|
317
|
+
virtual ~AcceptorDescriptor();
|
|
318
|
+
|
|
319
|
+
virtual void Read();
|
|
320
|
+
virtual void Write();
|
|
321
|
+
virtual void Heartbeat();
|
|
322
|
+
|
|
323
|
+
virtual bool SelectForRead() {return true;}
|
|
324
|
+
virtual bool SelectForWrite() {return false;}
|
|
325
|
+
|
|
326
|
+
virtual bool GetSockname (struct sockaddr*, socklen_t*);
|
|
327
|
+
|
|
328
|
+
static void StopAcceptor (const unsigned long binding);
|
|
329
|
+
};
|
|
330
|
+
|
|
331
|
+
/********************
|
|
332
|
+
class PipeDescriptor
|
|
333
|
+
********************/
|
|
334
|
+
|
|
335
|
+
#ifdef OS_UNIX
|
|
336
|
+
class PipeDescriptor: public EventableDescriptor
|
|
337
|
+
{
|
|
338
|
+
public:
|
|
339
|
+
PipeDescriptor (int, pid_t, EventMachine_t*);
|
|
340
|
+
virtual ~PipeDescriptor();
|
|
341
|
+
|
|
342
|
+
virtual void Read();
|
|
343
|
+
virtual void Write();
|
|
344
|
+
virtual void Heartbeat();
|
|
345
|
+
|
|
346
|
+
virtual bool SelectForRead();
|
|
347
|
+
virtual bool SelectForWrite();
|
|
348
|
+
|
|
349
|
+
int SendOutboundData (const char*, int);
|
|
350
|
+
virtual int GetOutboundDataSize() {return OutboundDataSize;}
|
|
351
|
+
|
|
352
|
+
virtual bool GetSubprocessPid (pid_t*);
|
|
353
|
+
|
|
354
|
+
protected:
|
|
355
|
+
struct OutboundPage {
|
|
356
|
+
OutboundPage (const char *b, int l, int o=0): Buffer(b), Length(l), Offset(o) {}
|
|
357
|
+
void Free() {if (Buffer) free (const_cast<char*>(Buffer)); }
|
|
358
|
+
const char *Buffer;
|
|
359
|
+
int Length;
|
|
360
|
+
int Offset;
|
|
361
|
+
};
|
|
362
|
+
|
|
363
|
+
protected:
|
|
364
|
+
bool bReadAttemptedAfterClose;
|
|
365
|
+
|
|
366
|
+
deque<OutboundPage> OutboundPages;
|
|
367
|
+
int OutboundDataSize;
|
|
368
|
+
|
|
369
|
+
pid_t SubprocessPid;
|
|
370
|
+
|
|
371
|
+
private:
|
|
372
|
+
void _DispatchInboundData (const char *buffer, int size);
|
|
373
|
+
};
|
|
374
|
+
#endif // OS_UNIX
|
|
375
|
+
|
|
376
|
+
|
|
377
|
+
/************************
|
|
378
|
+
class KeyboardDescriptor
|
|
379
|
+
************************/
|
|
380
|
+
|
|
381
|
+
class KeyboardDescriptor: public EventableDescriptor
|
|
382
|
+
{
|
|
383
|
+
public:
|
|
384
|
+
KeyboardDescriptor (EventMachine_t*);
|
|
385
|
+
virtual ~KeyboardDescriptor();
|
|
386
|
+
|
|
387
|
+
virtual void Read();
|
|
388
|
+
virtual void Write();
|
|
389
|
+
virtual void Heartbeat();
|
|
390
|
+
|
|
391
|
+
virtual bool SelectForRead() {return true;}
|
|
392
|
+
virtual bool SelectForWrite() {return false;}
|
|
393
|
+
|
|
394
|
+
protected:
|
|
395
|
+
bool bReadAttemptedAfterClose;
|
|
396
|
+
|
|
397
|
+
private:
|
|
398
|
+
void _DispatchInboundData (const char *buffer, int size);
|
|
399
|
+
};
|
|
400
|
+
|
|
401
|
+
|
|
402
|
+
/***********************
|
|
403
|
+
class InotifyDescriptor
|
|
404
|
+
************************/
|
|
405
|
+
|
|
406
|
+
class InotifyDescriptor: public EventableDescriptor
|
|
407
|
+
{
|
|
408
|
+
public:
|
|
409
|
+
InotifyDescriptor (EventMachine_t*);
|
|
410
|
+
virtual ~InotifyDescriptor();
|
|
411
|
+
|
|
412
|
+
void Read();
|
|
413
|
+
void Write();
|
|
414
|
+
|
|
415
|
+
virtual void Heartbeat() {}
|
|
416
|
+
virtual bool SelectForRead() {return true;}
|
|
417
|
+
virtual bool SelectForWrite() {return false;}
|
|
418
|
+
};
|
|
419
|
+
|
|
420
|
+
#endif // __EventableDescriptor__H_
|
|
421
|
+
|
|
422
|
+
|