eventmachine 0.12.6-x86-mswin32-60 → 0.12.8-x86-mswin32-60
Sign up to get free protection for your applications and to get access to all the features.
- data/{docs/README → README} +21 -13
- data/Rakefile +14 -4
- data/docs/DEFERRABLES +0 -5
- data/docs/INSTALL +2 -4
- data/docs/LEGAL +1 -1
- data/docs/LIGHTWEIGHT_CONCURRENCY +0 -2
- data/docs/PURE_RUBY +0 -2
- data/docs/RELEASE_NOTES +0 -2
- data/docs/SMTP +0 -7
- data/docs/SPAWNED_PROCESSES +0 -4
- data/docs/TODO +0 -2
- data/eventmachine.gemspec +41 -32
- data/examples/ex_channel.rb +43 -0
- data/examples/ex_queue.rb +2 -0
- data/examples/helper.rb +2 -0
- data/ext/cmain.cpp +685 -586
- data/ext/cplusplus.cpp +15 -6
- data/ext/ed.cpp +1732 -1522
- data/ext/ed.h +407 -380
- data/ext/em.cpp +2263 -1937
- data/ext/em.h +223 -186
- data/ext/eventmachine.h +111 -98
- data/ext/eventmachine_cpp.h +1 -0
- data/ext/extconf.rb +4 -0
- data/ext/kb.cpp +81 -82
- data/ext/pipe.cpp +349 -351
- data/ext/project.h +21 -0
- data/ext/rubymain.cpp +1047 -847
- data/ext/ssl.cpp +38 -1
- data/ext/ssl.h +5 -1
- data/java/src/com/rubyeventmachine/Application.java +7 -3
- data/java/src/com/rubyeventmachine/EmReactor.java +16 -1
- data/java/src/com/rubyeventmachine/tests/ConnectTest.java +25 -3
- data/lib/{protocols → em}/buftok.rb +16 -5
- data/lib/em/callback.rb +26 -0
- data/lib/em/channel.rb +57 -0
- data/lib/em/connection.rb +505 -0
- data/lib/em/deferrable.rb +144 -165
- data/lib/em/file_watch.rb +54 -0
- data/lib/em/future.rb +24 -25
- data/lib/em/messages.rb +1 -1
- data/lib/em/process_watch.rb +44 -0
- data/lib/em/processes.rb +119 -113
- data/lib/em/protocols.rb +35 -0
- data/lib/em/protocols/header_and_content.rb +138 -0
- data/lib/em/protocols/httpclient.rb +263 -0
- data/lib/em/protocols/httpclient2.rb +582 -0
- data/lib/{protocols → em/protocols}/line_and_text.rb +2 -2
- data/lib/em/protocols/linetext2.rb +160 -0
- data/lib/{protocols → em/protocols}/memcache.rb +37 -7
- data/lib/em/protocols/object_protocol.rb +39 -0
- data/lib/em/protocols/postgres3.rb +247 -0
- data/lib/em/protocols/saslauth.rb +175 -0
- data/lib/em/protocols/smtpclient.rb +331 -0
- data/lib/em/protocols/smtpserver.rb +547 -0
- data/lib/em/protocols/stomp.rb +200 -0
- data/lib/{protocols → em/protocols}/tcptest.rb +21 -25
- data/lib/em/queue.rb +61 -0
- data/lib/em/spawnable.rb +53 -56
- data/lib/em/streamer.rb +92 -74
- data/lib/em/timers.rb +55 -0
- data/lib/em/version.rb +3 -0
- data/lib/eventmachine.rb +1636 -1926
- data/lib/evma.rb +1 -1
- data/lib/jeventmachine.rb +106 -101
- data/lib/pr_eventmachine.rb +47 -36
- data/tasks/project.rake +2 -1
- data/tests/client.crt +31 -0
- data/tests/client.key +51 -0
- data/tests/test_attach.rb +18 -0
- data/tests/test_basic.rb +285 -231
- data/tests/test_channel.rb +63 -0
- data/tests/test_connection_count.rb +2 -2
- data/tests/test_epoll.rb +162 -163
- data/tests/test_errors.rb +36 -36
- data/tests/test_exc.rb +22 -25
- data/tests/test_file_watch.rb +49 -0
- data/tests/test_futures.rb +77 -93
- data/tests/test_hc.rb +2 -2
- data/tests/test_httpclient.rb +55 -52
- data/tests/test_httpclient2.rb +153 -155
- data/tests/test_inactivity_timeout.rb +30 -0
- data/tests/test_kb.rb +8 -9
- data/tests/test_ltp2.rb +274 -277
- data/tests/test_next_tick.rb +135 -109
- data/tests/test_object_protocol.rb +37 -0
- data/tests/test_process_watch.rb +48 -0
- data/tests/test_processes.rb +128 -95
- data/tests/test_proxy_connection.rb +92 -0
- data/tests/test_pure.rb +1 -5
- data/tests/test_queue.rb +44 -0
- data/tests/test_running.rb +9 -14
- data/tests/test_sasl.rb +32 -34
- data/tests/test_send_file.rb +175 -176
- data/tests/test_servers.rb +37 -41
- data/tests/test_smtpserver.rb +47 -55
- data/tests/test_spawn.rb +284 -291
- data/tests/test_ssl_args.rb +1 -1
- data/tests/test_ssl_methods.rb +1 -1
- data/tests/test_ssl_verify.rb +82 -0
- data/tests/test_timers.rb +81 -88
- data/tests/test_ud.rb +0 -7
- data/tests/testem.rb +1 -1
- metadata +52 -36
- data/lib/em/eventable.rb +0 -39
- data/lib/eventmachine_version.rb +0 -31
- data/lib/protocols/header_and_content.rb +0 -129
- data/lib/protocols/httpcli2.rb +0 -803
- data/lib/protocols/httpclient.rb +0 -270
- data/lib/protocols/linetext2.rb +0 -161
- data/lib/protocols/postgres.rb +0 -261
- data/lib/protocols/saslauth.rb +0 -179
- data/lib/protocols/smtpclient.rb +0 -308
- data/lib/protocols/smtpserver.rb +0 -556
- data/lib/protocols/stomp.rb +0 -153
- data/tests/test_eventables.rb +0 -77
data/ext/ed.h
CHANGED
@@ -1,380 +1,407 @@
|
|
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
|
-
|
60
|
-
void ScheduleClose (bool after_writing);
|
61
|
-
bool IsCloseScheduled();
|
62
|
-
|
63
|
-
void SetEventCallback (void (*cb)(const char*, int, const char*, int));
|
64
|
-
|
65
|
-
virtual bool GetPeername (struct sockaddr*) {return false;}
|
66
|
-
virtual bool GetSockname (struct sockaddr*) {return false;}
|
67
|
-
virtual bool GetSubprocessPid (pid_t*) {return false;}
|
68
|
-
|
69
|
-
virtual void StartTls() {}
|
70
|
-
virtual void SetTlsParms (const char *privkey_filename, const char *certchain_filename) {}
|
71
|
-
|
72
|
-
#ifdef WITH_SSL
|
73
|
-
virtual X509 *GetPeerCert() {return NULL;}
|
74
|
-
#endif
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
#
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
bool
|
88
|
-
|
89
|
-
|
90
|
-
protected:
|
91
|
-
|
92
|
-
|
93
|
-
//
|
94
|
-
//
|
95
|
-
//
|
96
|
-
//
|
97
|
-
//
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
#
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
virtual
|
130
|
-
|
131
|
-
virtual void
|
132
|
-
|
133
|
-
virtual
|
134
|
-
|
135
|
-
}
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
static int
|
151
|
-
|
152
|
-
int
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
void
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
virtual void
|
162
|
-
|
163
|
-
virtual
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
virtual
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
#
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
virtual
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
int Offset
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
bool
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
virtual
|
250
|
-
|
251
|
-
|
252
|
-
virtual bool
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
struct
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
virtual
|
322
|
-
|
323
|
-
virtual
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
|
374
|
-
}
|
375
|
-
|
376
|
-
|
377
|
-
|
378
|
-
|
379
|
-
|
380
|
-
|
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
|
+
|
60
|
+
void ScheduleClose (bool after_writing);
|
61
|
+
bool IsCloseScheduled();
|
62
|
+
|
63
|
+
void SetEventCallback (void (*cb)(const char*, int, const char*, int));
|
64
|
+
|
65
|
+
virtual bool GetPeername (struct sockaddr*) {return false;}
|
66
|
+
virtual bool GetSockname (struct sockaddr*) {return false;}
|
67
|
+
virtual bool GetSubprocessPid (pid_t*) {return false;}
|
68
|
+
|
69
|
+
virtual void StartTls() {}
|
70
|
+
virtual void SetTlsParms (const char *privkey_filename, const char *certchain_filename, bool verify_peer) {}
|
71
|
+
|
72
|
+
#ifdef WITH_SSL
|
73
|
+
virtual X509 *GetPeerCert() {return NULL;}
|
74
|
+
#endif
|
75
|
+
|
76
|
+
virtual float GetCommInactivityTimeout() {return 0.0;}
|
77
|
+
virtual int SetCommInactivityTimeout (float value) {return 0;}
|
78
|
+
|
79
|
+
#ifdef HAVE_EPOLL
|
80
|
+
struct epoll_event *GetEpollEvent() { return &EpollEvent; }
|
81
|
+
#endif
|
82
|
+
|
83
|
+
virtual void StartProxy(const char*);
|
84
|
+
virtual void StopProxy();
|
85
|
+
|
86
|
+
private:
|
87
|
+
bool bCloseNow;
|
88
|
+
bool bCloseAfterWriting;
|
89
|
+
|
90
|
+
protected:
|
91
|
+
int MySocket;
|
92
|
+
enum {
|
93
|
+
// 4 seconds is too short, most other libraries default to OS settings
|
94
|
+
// which in 2.6 kernel defaults to a 60 second connect timeout.
|
95
|
+
//
|
96
|
+
// Curl-Multi: http://curl.haxx.se/mail/lib-2001-01/0019.html
|
97
|
+
//
|
98
|
+
// updating to 50 seconds, so we catch it before the OS does
|
99
|
+
|
100
|
+
// can easily be made an instance variable
|
101
|
+
PendingConnectTimeout = 50000000 // now in usec
|
102
|
+
};
|
103
|
+
|
104
|
+
void (*EventCallback)(const char*, int, const char*, int);
|
105
|
+
void _GenericInboundDispatch(const char*, int);
|
106
|
+
|
107
|
+
Int64 CreatedAt;
|
108
|
+
bool bCallbackUnbind;
|
109
|
+
int UnbindReasonCode;
|
110
|
+
char *ProxyTarget;
|
111
|
+
|
112
|
+
#ifdef HAVE_EPOLL
|
113
|
+
struct epoll_event EpollEvent;
|
114
|
+
#endif
|
115
|
+
|
116
|
+
EventMachine_t *MyEventMachine;
|
117
|
+
};
|
118
|
+
|
119
|
+
|
120
|
+
|
121
|
+
/*************************
|
122
|
+
class LoopbreakDescriptor
|
123
|
+
*************************/
|
124
|
+
|
125
|
+
class LoopbreakDescriptor: public EventableDescriptor
|
126
|
+
{
|
127
|
+
public:
|
128
|
+
LoopbreakDescriptor (int, EventMachine_t*);
|
129
|
+
virtual ~LoopbreakDescriptor() {}
|
130
|
+
|
131
|
+
virtual void Read();
|
132
|
+
virtual void Write();
|
133
|
+
virtual void Heartbeat() {}
|
134
|
+
|
135
|
+
virtual bool SelectForRead() {return true;}
|
136
|
+
virtual bool SelectForWrite() {return false;}
|
137
|
+
};
|
138
|
+
|
139
|
+
|
140
|
+
/**************************
|
141
|
+
class ConnectionDescriptor
|
142
|
+
**************************/
|
143
|
+
|
144
|
+
class ConnectionDescriptor: public EventableDescriptor
|
145
|
+
{
|
146
|
+
public:
|
147
|
+
ConnectionDescriptor (int, EventMachine_t*);
|
148
|
+
virtual ~ConnectionDescriptor();
|
149
|
+
|
150
|
+
static int SendDataToConnection (const char*, const char*, int);
|
151
|
+
static void CloseConnection (const char*, bool);
|
152
|
+
static int ReportErrorStatus (const char*);
|
153
|
+
|
154
|
+
int SendOutboundData (const char*, int);
|
155
|
+
|
156
|
+
void SetConnectPending (bool f);
|
157
|
+
|
158
|
+
void SetNotifyReadable (bool);
|
159
|
+
void SetNotifyWritable (bool);
|
160
|
+
|
161
|
+
virtual void Read();
|
162
|
+
virtual void Write();
|
163
|
+
virtual void Heartbeat();
|
164
|
+
|
165
|
+
virtual bool SelectForRead();
|
166
|
+
virtual bool SelectForWrite();
|
167
|
+
|
168
|
+
// Do we have any data to write? This is used by ShouldDelete.
|
169
|
+
virtual int GetOutboundDataSize() {return OutboundDataSize;}
|
170
|
+
|
171
|
+
virtual void StartTls();
|
172
|
+
virtual void SetTlsParms (const char *privkey_filename, const char *certchain_filename, bool verify_peer);
|
173
|
+
|
174
|
+
#ifdef WITH_SSL
|
175
|
+
virtual X509 *GetPeerCert();
|
176
|
+
virtual bool VerifySslPeer(const char*);
|
177
|
+
virtual void AcceptSslPeer();
|
178
|
+
#endif
|
179
|
+
|
180
|
+
void SetServerMode() {bIsServer = true;}
|
181
|
+
|
182
|
+
virtual bool GetPeername (struct sockaddr*);
|
183
|
+
virtual bool GetSockname (struct sockaddr*);
|
184
|
+
|
185
|
+
virtual float GetCommInactivityTimeout();
|
186
|
+
virtual int SetCommInactivityTimeout (float value);
|
187
|
+
|
188
|
+
|
189
|
+
protected:
|
190
|
+
struct OutboundPage {
|
191
|
+
OutboundPage (const char *b, int l, int o=0): Buffer(b), Length(l), Offset(o) {}
|
192
|
+
void Free() {if (Buffer) free ((char*)Buffer); }
|
193
|
+
const char *Buffer;
|
194
|
+
int Length;
|
195
|
+
int Offset;
|
196
|
+
};
|
197
|
+
|
198
|
+
protected:
|
199
|
+
bool bConnectPending;
|
200
|
+
|
201
|
+
bool bNotifyReadable;
|
202
|
+
bool bNotifyWritable;
|
203
|
+
|
204
|
+
bool bReadAttemptedAfterClose;
|
205
|
+
bool bWriteAttemptedAfterClose;
|
206
|
+
|
207
|
+
deque<OutboundPage> OutboundPages;
|
208
|
+
int OutboundDataSize;
|
209
|
+
|
210
|
+
#ifdef WITH_SSL
|
211
|
+
SslBox_t *SslBox;
|
212
|
+
std::string CertChainFilename;
|
213
|
+
std::string PrivateKeyFilename;
|
214
|
+
bool bHandshakeSignaled;
|
215
|
+
bool bSslVerifyPeer;
|
216
|
+
bool bSslPeerAccepted;
|
217
|
+
#endif
|
218
|
+
bool bIsServer;
|
219
|
+
|
220
|
+
#ifdef HAVE_KQUEUE
|
221
|
+
bool bGotExtraKqueueEvent;
|
222
|
+
#endif
|
223
|
+
|
224
|
+
Int64 LastIo;
|
225
|
+
int InactivityTimeout;
|
226
|
+
|
227
|
+
private:
|
228
|
+
void _WriteOutboundData();
|
229
|
+
void _DispatchInboundData (const char *buffer, int size);
|
230
|
+
void _DispatchCiphertext();
|
231
|
+
int _SendRawOutboundData (const char*, int);
|
232
|
+
int _ReportErrorStatus();
|
233
|
+
void _CheckHandshakeStatus();
|
234
|
+
|
235
|
+
};
|
236
|
+
|
237
|
+
|
238
|
+
/************************
|
239
|
+
class DatagramDescriptor
|
240
|
+
************************/
|
241
|
+
|
242
|
+
class DatagramDescriptor: public EventableDescriptor
|
243
|
+
{
|
244
|
+
public:
|
245
|
+
DatagramDescriptor (int, EventMachine_t*);
|
246
|
+
virtual ~DatagramDescriptor();
|
247
|
+
|
248
|
+
virtual void Read();
|
249
|
+
virtual void Write();
|
250
|
+
virtual void Heartbeat();
|
251
|
+
|
252
|
+
virtual bool SelectForRead() {return true;}
|
253
|
+
virtual bool SelectForWrite();
|
254
|
+
|
255
|
+
int SendOutboundData (const char*, int);
|
256
|
+
int SendOutboundDatagram (const char*, int, const char*, int);
|
257
|
+
|
258
|
+
// Do we have any data to write? This is used by ShouldDelete.
|
259
|
+
virtual int GetOutboundDataSize() {return OutboundDataSize;}
|
260
|
+
|
261
|
+
virtual bool GetPeername (struct sockaddr*);
|
262
|
+
virtual bool GetSockname (struct sockaddr*);
|
263
|
+
|
264
|
+
virtual float GetCommInactivityTimeout();
|
265
|
+
virtual int SetCommInactivityTimeout (float value);
|
266
|
+
|
267
|
+
static int SendDatagram (const char*, const char*, int, const char*, int);
|
268
|
+
|
269
|
+
|
270
|
+
protected:
|
271
|
+
struct OutboundPage {
|
272
|
+
OutboundPage (const char *b, int l, struct sockaddr_in f, int o=0): Buffer(b), Length(l), Offset(o), From(f) {}
|
273
|
+
void Free() {if (Buffer) free ((char*)Buffer); }
|
274
|
+
const char *Buffer;
|
275
|
+
int Length;
|
276
|
+
int Offset;
|
277
|
+
struct sockaddr_in From;
|
278
|
+
};
|
279
|
+
|
280
|
+
deque<OutboundPage> OutboundPages;
|
281
|
+
int OutboundDataSize;
|
282
|
+
|
283
|
+
struct sockaddr_in ReturnAddress;
|
284
|
+
|
285
|
+
Int64 LastIo;
|
286
|
+
int InactivityTimeout;
|
287
|
+
};
|
288
|
+
|
289
|
+
|
290
|
+
/************************
|
291
|
+
class AcceptorDescriptor
|
292
|
+
************************/
|
293
|
+
|
294
|
+
class AcceptorDescriptor: public EventableDescriptor
|
295
|
+
{
|
296
|
+
public:
|
297
|
+
AcceptorDescriptor (int, EventMachine_t*);
|
298
|
+
virtual ~AcceptorDescriptor();
|
299
|
+
|
300
|
+
virtual void Read();
|
301
|
+
virtual void Write();
|
302
|
+
virtual void Heartbeat();
|
303
|
+
|
304
|
+
virtual bool SelectForRead() {return true;}
|
305
|
+
virtual bool SelectForWrite() {return false;}
|
306
|
+
|
307
|
+
virtual bool GetSockname (struct sockaddr*);
|
308
|
+
|
309
|
+
static void StopAcceptor (const char *binding);
|
310
|
+
};
|
311
|
+
|
312
|
+
/********************
|
313
|
+
class PipeDescriptor
|
314
|
+
********************/
|
315
|
+
|
316
|
+
#ifdef OS_UNIX
|
317
|
+
class PipeDescriptor: public EventableDescriptor
|
318
|
+
{
|
319
|
+
public:
|
320
|
+
PipeDescriptor (int, pid_t, EventMachine_t*);
|
321
|
+
virtual ~PipeDescriptor();
|
322
|
+
|
323
|
+
virtual void Read();
|
324
|
+
virtual void Write();
|
325
|
+
virtual void Heartbeat();
|
326
|
+
|
327
|
+
virtual bool SelectForRead();
|
328
|
+
virtual bool SelectForWrite();
|
329
|
+
|
330
|
+
int SendOutboundData (const char*, int);
|
331
|
+
virtual int GetOutboundDataSize() {return OutboundDataSize;}
|
332
|
+
|
333
|
+
virtual bool GetSubprocessPid (pid_t*);
|
334
|
+
|
335
|
+
protected:
|
336
|
+
struct OutboundPage {
|
337
|
+
OutboundPage (const char *b, int l, int o=0): Buffer(b), Length(l), Offset(o) {}
|
338
|
+
void Free() {if (Buffer) free ((char*)Buffer); }
|
339
|
+
const char *Buffer;
|
340
|
+
int Length;
|
341
|
+
int Offset;
|
342
|
+
};
|
343
|
+
|
344
|
+
protected:
|
345
|
+
bool bReadAttemptedAfterClose;
|
346
|
+
Int64 LastIo;
|
347
|
+
int InactivityTimeout;
|
348
|
+
|
349
|
+
deque<OutboundPage> OutboundPages;
|
350
|
+
int OutboundDataSize;
|
351
|
+
|
352
|
+
pid_t SubprocessPid;
|
353
|
+
|
354
|
+
private:
|
355
|
+
void _DispatchInboundData (const char *buffer, int size);
|
356
|
+
};
|
357
|
+
#endif // OS_UNIX
|
358
|
+
|
359
|
+
|
360
|
+
/************************
|
361
|
+
class KeyboardDescriptor
|
362
|
+
************************/
|
363
|
+
|
364
|
+
class KeyboardDescriptor: public EventableDescriptor
|
365
|
+
{
|
366
|
+
public:
|
367
|
+
KeyboardDescriptor (EventMachine_t*);
|
368
|
+
virtual ~KeyboardDescriptor();
|
369
|
+
|
370
|
+
virtual void Read();
|
371
|
+
virtual void Write();
|
372
|
+
virtual void Heartbeat();
|
373
|
+
|
374
|
+
virtual bool SelectForRead() {return true;}
|
375
|
+
virtual bool SelectForWrite() {return false;}
|
376
|
+
|
377
|
+
protected:
|
378
|
+
bool bReadAttemptedAfterClose;
|
379
|
+
Int64 LastIo;
|
380
|
+
int InactivityTimeout;
|
381
|
+
|
382
|
+
private:
|
383
|
+
void _DispatchInboundData (const char *buffer, int size);
|
384
|
+
};
|
385
|
+
|
386
|
+
|
387
|
+
/***********************
|
388
|
+
class InotifyDescriptor
|
389
|
+
************************/
|
390
|
+
|
391
|
+
class InotifyDescriptor: public EventableDescriptor
|
392
|
+
{
|
393
|
+
public:
|
394
|
+
InotifyDescriptor (EventMachine_t*);
|
395
|
+
virtual ~InotifyDescriptor();
|
396
|
+
|
397
|
+
void Read();
|
398
|
+
void Write();
|
399
|
+
|
400
|
+
virtual void Heartbeat() {}
|
401
|
+
virtual bool SelectForRead() {return true;}
|
402
|
+
virtual bool SelectForWrite() {return false;}
|
403
|
+
};
|
404
|
+
|
405
|
+
#endif // __EventableDescriptor__H_
|
406
|
+
|
407
|
+
|