eventmachine 0.5.1 → 0.5.2
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.
- data/README +10 -11
- data/RELEASE_NOTES +9 -1
- data/ext/ed.cpp +27 -6
- data/ext/ed.h +5 -2
- data/ext/em.cpp +16 -8
- data/ext/em.h +17 -1
- data/ext/emwin.cpp +307 -0
- data/ext/emwin.h +99 -0
- data/ext/extconf.rb +46 -1
- data/ext/project.h +6 -2
- data/ext/rubymain.cpp +13 -8
- data/ext/ssl.cpp +46 -41
- data/ext/ssl.h +3 -2
- data/lib/eventmachine.rb +12 -5
- metadata +15 -10
data/README
CHANGED
@@ -1,13 +1,14 @@
|
|
1
|
-
$Id: README
|
1
|
+
$Id: README 2484 2006-05-12 16:55:59Z francis $
|
2
2
|
|
3
|
-
|
3
|
+
= RUBY/EventMachine
|
4
4
|
|
5
|
-
|
6
|
-
|
5
|
+
Homepage:: http://rubyeventmachine.com
|
6
|
+
Copyright:: (C) 2006 by Francis Cianfrocca. All Rights Reserved.
|
7
|
+
Email:: gmail address: garbagecat10
|
7
8
|
|
8
|
-
|
9
|
-
|
10
|
-
|
9
|
+
This program is made available under the terms of the Lesser-GPL version 2.
|
10
|
+
See EventMachine and EventMachine::Connection for documentation and
|
11
|
+
usage examples.
|
11
12
|
|
12
13
|
EventMachine implements a fast, single-threaded engine for arbitrary network
|
13
14
|
communications. It's extremely easy to use in Ruby. EventMachine wraps all
|
@@ -50,7 +51,7 @@ for Linux will use <tt>epoll(4)</tt> and will thus require a Linux 2.6 kernel.
|
|
50
51
|
Here's a fully-functional echo server written with EventMachine:
|
51
52
|
|
52
53
|
require 'rubygems'
|
53
|
-
|
54
|
+
require 'eventmachine'
|
54
55
|
|
55
56
|
module EchoServer
|
56
57
|
def receive_data data
|
@@ -63,7 +64,5 @@ Here's a fully-functional echo server written with EventMachine:
|
|
63
64
|
EventMachine::start_server "192.168.0.100", 8081, EchoServer
|
64
65
|
}
|
65
66
|
|
66
|
-
EventMachine is licensed under GPL. We will be adding full support for
|
67
|
-
SSL/TLS-encryption based on OpenSSL in the near future.
|
68
|
-
|
69
67
|
|
68
|
+
# vim: sts=2 sw=2 ts=4 et ai tw=77
|
data/RELEASE_NOTES
CHANGED
@@ -1,7 +1,15 @@
|
|
1
|
-
$Id: RELEASE_NOTES
|
1
|
+
$Id: RELEASE_NOTES 2477 2006-05-11 13:22:39Z francis $
|
2
2
|
|
3
3
|
RUBY/EventMachine RELEASE NOTES
|
4
4
|
|
5
|
+
--------------------------------------------------
|
6
|
+
Version: 0.5.2, released 05May06
|
7
|
+
Made several nonvisible improvements to the Windows
|
8
|
+
implementation.
|
9
|
+
Added an exception-handling patch contributed by Jeff Rose, jeff@rosejn.net.
|
10
|
+
Added a dir-config patch contributed anonymously.
|
11
|
+
Supported builds on Solaris.
|
12
|
+
|
5
13
|
--------------------------------------------------
|
6
14
|
Version: 0.5.1, released 05May06
|
7
15
|
Made it possible to pass a Class rather than a Module
|
data/ext/ed.cpp
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
/*****************************************************************************
|
2
2
|
|
3
|
-
$Id: ed.cpp
|
3
|
+
$Id: ed.cpp 2491 2006-05-12 20:24:19Z francis $
|
4
4
|
|
5
5
|
File: ed.cpp
|
6
6
|
Date: 06Apr06
|
@@ -162,7 +162,9 @@ ConnectionDescriptor::ConnectionDescriptor (int sd):
|
|
162
162
|
EventableDescriptor (sd),
|
163
163
|
bConnectPending (false),
|
164
164
|
OutboundDataSize (0),
|
165
|
+
#ifdef WITH_SSL
|
165
166
|
SslBox (NULL),
|
167
|
+
#endif
|
166
168
|
bIsServer (false)
|
167
169
|
{
|
168
170
|
}
|
@@ -178,8 +180,10 @@ ConnectionDescriptor::~ConnectionDescriptor()
|
|
178
180
|
for (size_t i=0; i < OutboundPages.size(); i++)
|
179
181
|
OutboundPages[i].Free();
|
180
182
|
|
183
|
+
#ifdef WITH_SSL
|
181
184
|
if (SslBox)
|
182
185
|
delete SslBox;
|
186
|
+
#endif
|
183
187
|
}
|
184
188
|
|
185
189
|
|
@@ -220,6 +224,7 @@ ConnectionDescriptor::SendOutboundData
|
|
220
224
|
|
221
225
|
int ConnectionDescriptor::SendOutboundData (const char *data, int length)
|
222
226
|
{
|
227
|
+
#ifdef WITH_SSL
|
223
228
|
if (SslBox) {
|
224
229
|
if (length > 0) {
|
225
230
|
int w = SslBox->PutPlaintext (data, length);
|
@@ -232,6 +237,7 @@ int ConnectionDescriptor::SendOutboundData (const char *data, int length)
|
|
232
237
|
return 1; // That's a wild guess, almost certainly wrong.
|
233
238
|
}
|
234
239
|
else
|
240
|
+
#endif
|
235
241
|
return _SendRawOutboundData (data, length);
|
236
242
|
}
|
237
243
|
|
@@ -382,6 +388,7 @@ ConnectionDescriptor::_DispatchInboundData
|
|
382
388
|
|
383
389
|
void ConnectionDescriptor::_DispatchInboundData (const char *buffer, int size)
|
384
390
|
{
|
391
|
+
#ifdef WITH_SSL
|
385
392
|
if (SslBox) {
|
386
393
|
SslBox->PutCiphertext (buffer, size);
|
387
394
|
|
@@ -399,6 +406,12 @@ void ConnectionDescriptor::_DispatchInboundData (const char *buffer, int size)
|
|
399
406
|
if (EventCallback)
|
400
407
|
(*EventCallback)(GetBinding().c_str(), EventMachine_t::CONNECTION_READ, buffer, size);
|
401
408
|
}
|
409
|
+
#endif
|
410
|
+
|
411
|
+
#ifdef WITHOUT_SSL
|
412
|
+
if (EventCallback)
|
413
|
+
(*EventCallback)(GetBinding().c_str(), EventMachine_t::CONNECTION_READ, buffer, size);
|
414
|
+
#endif
|
402
415
|
}
|
403
416
|
|
404
417
|
|
@@ -519,11 +532,17 @@ ConnectionDescriptor::StartTls
|
|
519
532
|
|
520
533
|
void ConnectionDescriptor::StartTls()
|
521
534
|
{
|
535
|
+
#ifdef WITH_SSL
|
522
536
|
if (SslBox)
|
523
537
|
throw std::runtime_error ("SSL/TLS already running on connection");
|
524
538
|
|
525
539
|
SslBox = new SslBox_t (bIsServer);
|
526
540
|
_DispatchCiphertext();
|
541
|
+
#endif
|
542
|
+
|
543
|
+
#ifdef WITHOUT_SSL
|
544
|
+
throw std::runtime_error ("Encryption not available on this event-machine");
|
545
|
+
#endif
|
527
546
|
}
|
528
547
|
|
529
548
|
|
@@ -531,7 +550,7 @@ void ConnectionDescriptor::StartTls()
|
|
531
550
|
/*****************************************
|
532
551
|
ConnectionDescriptor::_DispatchCiphertext
|
533
552
|
*****************************************/
|
534
|
-
|
553
|
+
#ifdef WITH_SSL
|
535
554
|
void ConnectionDescriptor::_DispatchCiphertext()
|
536
555
|
{
|
537
556
|
assert (SslBox);
|
@@ -588,7 +607,7 @@ void ConnectionDescriptor::_DispatchCiphertext()
|
|
588
607
|
} while (did_work);
|
589
608
|
|
590
609
|
}
|
591
|
-
|
610
|
+
#endif
|
592
611
|
|
593
612
|
|
594
613
|
|
@@ -683,7 +702,7 @@ void AcceptorDescriptor::Read()
|
|
683
702
|
|
684
703
|
// Disable slow-start (Nagle algorithm). Eventually make this configurable.
|
685
704
|
int one = 1;
|
686
|
-
setsockopt (sd, IPPROTO_TCP, TCP_NODELAY, (
|
705
|
+
setsockopt (sd, IPPROTO_TCP, TCP_NODELAY, (char*) &one, sizeof(one));
|
687
706
|
|
688
707
|
|
689
708
|
ConnectionDescriptor *cd = new ConnectionDescriptor (sd);
|
@@ -838,7 +857,8 @@ void DatagramDescriptor::Write()
|
|
838
857
|
break;
|
839
858
|
OutboundPage *op = &(OutboundPages[0]);
|
840
859
|
|
841
|
-
|
860
|
+
// The nasty cast to (char*) is needed because Windows is brain-dead.
|
861
|
+
int s = sendto (sd, (char*)op->Buffer, op->Length, 0, (struct sockaddr*)&(op->From), sizeof(op->From));
|
842
862
|
int e = errno;
|
843
863
|
|
844
864
|
OutboundDataSize -= op->Length;
|
@@ -916,7 +936,8 @@ int DatagramDescriptor::SendOutboundDatagram (const char *data, int length, cons
|
|
916
936
|
|
917
937
|
HostAddr = inet_addr (address);
|
918
938
|
if (HostAddr == INADDR_NONE) {
|
919
|
-
|
939
|
+
// The nasty cast to (char*) is because Windows is brain-dead.
|
940
|
+
hostent *hp = gethostbyname ((char*)address);
|
920
941
|
if (!hp)
|
921
942
|
return 0;
|
922
943
|
HostAddr = ((in_addr*)(hp->h_addr))->s_addr;
|
data/ext/ed.h
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
/*****************************************************************************
|
2
2
|
|
3
|
-
$Id: ed.h
|
3
|
+
$Id: ed.h 2473 2006-05-11 06:37:31Z francis $
|
4
4
|
|
5
5
|
File: ed.h
|
6
6
|
Date: 06Apr06
|
@@ -29,8 +29,9 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
29
29
|
|
30
30
|
|
31
31
|
class EventMachine_t; // forward reference
|
32
|
+
#ifdef WITH_SSL
|
32
33
|
class SslBox_t; // forward reference
|
33
|
-
|
34
|
+
#endif
|
34
35
|
|
35
36
|
bool SetSocketNonblocking (SOCKET);
|
36
37
|
|
@@ -131,7 +132,9 @@ class ConnectionDescriptor: public EventableDescriptor
|
|
131
132
|
deque<OutboundPage> OutboundPages;
|
132
133
|
int OutboundDataSize;
|
133
134
|
|
135
|
+
#ifdef WITH_SSL
|
134
136
|
SslBox_t *SslBox;
|
137
|
+
#endif
|
135
138
|
bool bIsServer;
|
136
139
|
|
137
140
|
private:
|
data/ext/em.cpp
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
/*****************************************************************************
|
2
2
|
|
3
|
-
$Id: em.cpp
|
3
|
+
$Id: em.cpp 2491 2006-05-12 20:24:19Z francis $
|
4
4
|
|
5
5
|
File: ed.cpp
|
6
6
|
Date: 06Apr06
|
@@ -24,6 +24,10 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
24
24
|
|
25
25
|
*****************************************************************************/
|
26
26
|
|
27
|
+
// THIS ENTIRE FILE WILL EVENTUALLY BE FOR UNIX BUILDS ONLY.
|
28
|
+
//#ifdef OS_UNIX
|
29
|
+
|
30
|
+
|
27
31
|
#include "project.h"
|
28
32
|
|
29
33
|
// Keep a global variable floating around
|
@@ -83,6 +87,8 @@ EventMachine_t::Run
|
|
83
87
|
void EventMachine_t::Run()
|
84
88
|
{
|
85
89
|
#ifdef OS_WIN32
|
90
|
+
WSADATA w;
|
91
|
+
WSAStartup (MAKEWORD (1, 1), &w);
|
86
92
|
HookControlC (true);
|
87
93
|
#endif
|
88
94
|
|
@@ -121,7 +127,7 @@ bool EventMachine_t::_RunOnce()
|
|
121
127
|
if (Descriptors.size() == 0) {
|
122
128
|
#ifdef OS_UNIX
|
123
129
|
timeval tv = {0, 200 * 1000};
|
124
|
-
|
130
|
+
EmSelect (0, NULL, NULL, NULL, &tv);
|
125
131
|
#endif
|
126
132
|
#ifdef OS_WIN32
|
127
133
|
Sleep (200);
|
@@ -155,7 +161,7 @@ bool EventMachine_t::_RunOnce()
|
|
155
161
|
|
156
162
|
{ // read and write the sockets
|
157
163
|
timeval tv = {1, 0}; // Solaris fails if the microseconds member is >= 1000000.
|
158
|
-
int s =
|
164
|
+
int s = EmSelect (maxsocket+1, &fdreads, &fdwrites, NULL, &tv);
|
159
165
|
if (s > 0) {
|
160
166
|
for (i=0; i < Descriptors.size(); i++) {
|
161
167
|
EventableDescriptor *ed = Descriptors[i];
|
@@ -175,7 +181,7 @@ bool EventMachine_t::_RunOnce()
|
|
175
181
|
// If the error was EINTR, we probaby caught SIGCHLD or something,
|
176
182
|
// so keep the wait short.
|
177
183
|
timeval tv = {0, ((errno == EINTR) ? 5 : 50) * 1000};
|
178
|
-
|
184
|
+
EmSelect (0, NULL, NULL, NULL, &tv);
|
179
185
|
}
|
180
186
|
}
|
181
187
|
|
@@ -295,7 +301,7 @@ const char *EventMachine_t::ConnectToServer (const char *server, int port)
|
|
295
301
|
|
296
302
|
HostAddr = inet_addr (server);
|
297
303
|
if (HostAddr == INADDR_NONE) {
|
298
|
-
hostent *hp = gethostbyname (server);
|
304
|
+
hostent *hp = gethostbyname ((char*)server); // Windows requires (char*)
|
299
305
|
if (!hp)
|
300
306
|
return NULL;
|
301
307
|
HostAddr = ((in_addr*)(hp->h_addr))->s_addr;
|
@@ -416,7 +422,7 @@ const char *EventMachine_t::CreateTcpServer (const char *server, int port)
|
|
416
422
|
if (server && *server) {
|
417
423
|
sin.sin_addr.s_addr = inet_addr (server);
|
418
424
|
if (sin.sin_addr.s_addr == INADDR_NONE) {
|
419
|
-
hostent *hp = gethostbyname (server);
|
425
|
+
hostent *hp = gethostbyname ((char*)server); // Windows requires the cast.
|
420
426
|
if (hp == NULL) {
|
421
427
|
//__warning ("hostname not resolved: ", server);
|
422
428
|
goto fail;
|
@@ -503,7 +509,7 @@ const char *EventMachine_t::OpenDatagramSocket (const char *address, int port)
|
|
503
509
|
if (address && *address) {
|
504
510
|
sin.sin_addr.s_addr = inet_addr (address);
|
505
511
|
if (sin.sin_addr.s_addr == INADDR_NONE) {
|
506
|
-
hostent *hp = gethostbyname (address);
|
512
|
+
hostent *hp = gethostbyname ((char*)address); // Windows requires the cast.
|
507
513
|
if (hp == NULL)
|
508
514
|
goto fail;
|
509
515
|
sin.sin_addr.s_addr = ((in_addr*)(hp->h_addr))->s_addr;
|
@@ -550,7 +556,7 @@ void EventMachine_t::Add (EventableDescriptor *ed)
|
|
550
556
|
{
|
551
557
|
if (!ed)
|
552
558
|
throw std::runtime_error ("added bad descriptor");
|
553
|
-
|
559
|
+
ed->SetEventCallback (EventCallback);
|
554
560
|
NewDescriptors.push_back (ed);
|
555
561
|
}
|
556
562
|
|
@@ -578,3 +584,5 @@ void EventMachine_t::_AddNewDescriptors()
|
|
578
584
|
}
|
579
585
|
|
580
586
|
|
587
|
+
//#endif // OS_UNIX
|
588
|
+
|
data/ext/em.h
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
/*****************************************************************************
|
2
2
|
|
3
|
-
$Id: em.h
|
3
|
+
$Id: em.h 2469 2006-05-10 18:11:10Z francis $
|
4
4
|
|
5
5
|
File: ed.h
|
6
6
|
Date: 06Apr06
|
@@ -25,9 +25,24 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
25
25
|
*****************************************************************************/
|
26
26
|
|
27
27
|
|
28
|
+
|
29
|
+
#ifdef OS_WIN32
|
30
|
+
#include "emwin.h"
|
31
|
+
#endif
|
32
|
+
|
33
|
+
|
34
|
+
// THIS ENTIRE FILE WILL EVENTUALLY BE FOR UNIX BUILDS ONLY.
|
35
|
+
//#ifdef OS_UNIX
|
36
|
+
|
28
37
|
#ifndef __EventMachine__H_
|
29
38
|
#define __EventMachine__H_
|
30
39
|
|
40
|
+
#ifdef BUILD_FOR_RUBY
|
41
|
+
#include <ruby.h>
|
42
|
+
#define EmSelect rb_thread_select
|
43
|
+
#else
|
44
|
+
#define EmSelect select
|
45
|
+
#endif
|
31
46
|
|
32
47
|
extern time_t gCurrentLoopTime;
|
33
48
|
|
@@ -89,3 +104,4 @@ class EventMachine_t
|
|
89
104
|
|
90
105
|
#endif // __EventMachine__H_
|
91
106
|
|
107
|
+
//#endif // OS_UNIX
|
data/ext/emwin.cpp
ADDED
@@ -0,0 +1,307 @@
|
|
1
|
+
/*****************************************************************************
|
2
|
+
|
3
|
+
$Id: em.cpp 2457 2006-05-05 14:57:21Z francis $
|
4
|
+
|
5
|
+
File: edwin.cpp
|
6
|
+
Date: 05May06
|
7
|
+
|
8
|
+
Copyright (C) 2006 by Francis Cianfrocca. All Rights Reserved.
|
9
|
+
Gmail: garbagecat10
|
10
|
+
|
11
|
+
This program is free software; you can redistribute it and/or modify
|
12
|
+
it under the terms of the GNU General Public License as published by
|
13
|
+
the Free Software Foundation; either version 2 of the License, or
|
14
|
+
(at your option) any later version.
|
15
|
+
|
16
|
+
This program is distributed in the hope that it will be useful,
|
17
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
18
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
19
|
+
GNU General Public License for more details.
|
20
|
+
|
21
|
+
You should have received a copy of the GNU General Public License
|
22
|
+
along with this program; if not, write to the Free Software
|
23
|
+
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
24
|
+
|
25
|
+
*****************************************************************************/
|
26
|
+
|
27
|
+
|
28
|
+
// THIS ENTIRE FILE IS FOR WINDOWS BUILDS ONLY
|
29
|
+
// INCOMPLETE AND DISABLED FOR NOW.
|
30
|
+
#ifdef xOS_WIN32
|
31
|
+
|
32
|
+
#include "project.h"
|
33
|
+
|
34
|
+
|
35
|
+
// Keep a global variable floating around
|
36
|
+
// with the current loop time as set by the Event Machine.
|
37
|
+
// This avoids the need for frequent expensive calls to time(NULL);
|
38
|
+
time_t gCurrentLoopTime;
|
39
|
+
|
40
|
+
|
41
|
+
/******************************
|
42
|
+
EventMachine_t::EventMachine_t
|
43
|
+
******************************/
|
44
|
+
|
45
|
+
EventMachine_t::EventMachine_t (void (*event_callback)(const char*, int, const char*, int)):
|
46
|
+
EventCallback (event_callback),
|
47
|
+
NextHeartbeatTime (0)
|
48
|
+
{
|
49
|
+
gTerminateSignalReceived = false;
|
50
|
+
Iocp = NULL;
|
51
|
+
}
|
52
|
+
|
53
|
+
|
54
|
+
/*******************************
|
55
|
+
EventMachine_t::~EventMachine_t
|
56
|
+
*******************************/
|
57
|
+
|
58
|
+
EventMachine_t::~EventMachine_t()
|
59
|
+
{
|
60
|
+
cerr << "EM __dt\n";
|
61
|
+
if (Iocp)
|
62
|
+
CloseHandle (Iocp);
|
63
|
+
}
|
64
|
+
|
65
|
+
|
66
|
+
/****************************
|
67
|
+
EventMachine_t::ScheduleHalt
|
68
|
+
****************************/
|
69
|
+
|
70
|
+
void EventMachine_t::ScheduleHalt()
|
71
|
+
{
|
72
|
+
/* This is how we stop the machine.
|
73
|
+
* This can be called by clients. Signal handlers will probably
|
74
|
+
* set the global flag.
|
75
|
+
* For now this means there can only be one EventMachine ever running at a time.
|
76
|
+
*/
|
77
|
+
gTerminateSignalReceived = true;
|
78
|
+
}
|
79
|
+
|
80
|
+
|
81
|
+
|
82
|
+
/*******************
|
83
|
+
EventMachine_t::Run
|
84
|
+
*******************/
|
85
|
+
|
86
|
+
void EventMachine_t::Run()
|
87
|
+
{
|
88
|
+
HookControlC (true);
|
89
|
+
|
90
|
+
Iocp = CreateIoCompletionPort (INVALID_HANDLE_VALUE, NULL, 0, 0);
|
91
|
+
if (Iocp == NULL)
|
92
|
+
throw std::runtime_error ("no completion port");
|
93
|
+
|
94
|
+
|
95
|
+
DWORD nBytes, nCompletionKey;
|
96
|
+
LPOVERLAPPED Overlapped;
|
97
|
+
|
98
|
+
do {
|
99
|
+
gCurrentLoopTime = time(NULL);
|
100
|
+
// Have some kind of strategy that will dequeue maybe up to 10 completions
|
101
|
+
// without running the timers as long as they are available immediately.
|
102
|
+
// Otherwise in a busy server we're calling them every time through the loop.
|
103
|
+
if (!_RunTimers())
|
104
|
+
break;
|
105
|
+
if (GetQueuedCompletionStatus (Iocp, &nBytes, &nCompletionKey, &Overlapped, 1000)) {
|
106
|
+
}
|
107
|
+
cerr << "+";
|
108
|
+
} while (!gTerminateSignalReceived);
|
109
|
+
|
110
|
+
|
111
|
+
/*
|
112
|
+
while (true) {
|
113
|
+
gCurrentLoopTime = time(NULL);
|
114
|
+
if (!_RunTimers())
|
115
|
+
break;
|
116
|
+
_AddNewDescriptors();
|
117
|
+
if (!_RunOnce())
|
118
|
+
break;
|
119
|
+
if (gTerminateSignalReceived)
|
120
|
+
break;
|
121
|
+
}
|
122
|
+
*/
|
123
|
+
|
124
|
+
HookControlC (false);
|
125
|
+
}
|
126
|
+
|
127
|
+
|
128
|
+
/**************************
|
129
|
+
EventMachine_t::_RunTimers
|
130
|
+
**************************/
|
131
|
+
|
132
|
+
bool EventMachine_t::_RunTimers()
|
133
|
+
{
|
134
|
+
// These are caller-defined timer handlers.
|
135
|
+
// Return T/F to indicate whether we should continue the main loop.
|
136
|
+
// We rely on the fact that multimaps sort by their keys to avoid
|
137
|
+
// inspecting the whole list every time we come here.
|
138
|
+
// Just keep inspecting and processing the list head until we hit
|
139
|
+
// one that hasn't expired yet.
|
140
|
+
|
141
|
+
while (true) {
|
142
|
+
multimap<time_t,Timer_t>::iterator i = Timers.begin();
|
143
|
+
if (i == Timers.end())
|
144
|
+
break;
|
145
|
+
if (i->first > gCurrentLoopTime)
|
146
|
+
break;
|
147
|
+
if (EventCallback)
|
148
|
+
(*EventCallback) ("", TIMER_FIRED, i->second.GetBinding().c_str(), i->second.GetBinding().length());
|
149
|
+
Timers.erase (i);
|
150
|
+
}
|
151
|
+
return true;
|
152
|
+
}
|
153
|
+
|
154
|
+
|
155
|
+
/***********************************
|
156
|
+
EventMachine_t::InstallOneshotTimer
|
157
|
+
***********************************/
|
158
|
+
|
159
|
+
const char *EventMachine_t::InstallOneshotTimer (int seconds)
|
160
|
+
{
|
161
|
+
if (Timers.size() > MaxOutstandingTimers)
|
162
|
+
return false;
|
163
|
+
// Don't use the global loop-time variable here, because we might
|
164
|
+
// get called before the main event machine is running.
|
165
|
+
|
166
|
+
Timer_t t;
|
167
|
+
Timers.insert (make_pair (time(NULL) + seconds, t));
|
168
|
+
return t.GetBinding().c_str();
|
169
|
+
}
|
170
|
+
|
171
|
+
|
172
|
+
/**********************************
|
173
|
+
EventMachine_t::OpenDatagramSocket
|
174
|
+
**********************************/
|
175
|
+
|
176
|
+
const char *EventMachine_t::OpenDatagramSocket (const char *address, int port)
|
177
|
+
{
|
178
|
+
cerr << "OPEN DATAGRAM SOCKET\n";
|
179
|
+
return "Unimplemented";
|
180
|
+
}
|
181
|
+
|
182
|
+
|
183
|
+
/*******************************
|
184
|
+
EventMachine_t::CreateTcpServer
|
185
|
+
*******************************/
|
186
|
+
|
187
|
+
const char *EventMachine_t::CreateTcpServer (const char *server, int port)
|
188
|
+
{
|
189
|
+
/* Create a TCP-acceptor (server) socket and add it to the event machine.
|
190
|
+
* Return the binding of the new acceptor to the caller.
|
191
|
+
* This binding will be referenced when the new acceptor sends events
|
192
|
+
* to indicate accepted connections.
|
193
|
+
*/
|
194
|
+
|
195
|
+
const char *output_binding = NULL;
|
196
|
+
|
197
|
+
struct sockaddr_in sin;
|
198
|
+
|
199
|
+
SOCKET sd_accept = socket (AF_INET, SOCK_STREAM, 0);
|
200
|
+
if (sd_accept == INVALID_SOCKET) {
|
201
|
+
goto fail;
|
202
|
+
}
|
203
|
+
|
204
|
+
memset (&sin, 0, sizeof(sin));
|
205
|
+
sin.sin_family = AF_INET;
|
206
|
+
sin.sin_addr.s_addr = INADDR_ANY;
|
207
|
+
sin.sin_port = htons (port);
|
208
|
+
|
209
|
+
if (server && *server) {
|
210
|
+
sin.sin_addr.s_addr = inet_addr (server);
|
211
|
+
if (sin.sin_addr.s_addr == INADDR_NONE) {
|
212
|
+
hostent *hp = gethostbyname (server);
|
213
|
+
if (hp == NULL) {
|
214
|
+
//__warning ("hostname not resolved: ", server);
|
215
|
+
goto fail;
|
216
|
+
}
|
217
|
+
sin.sin_addr.s_addr = ((in_addr*)(hp->h_addr))->s_addr;
|
218
|
+
}
|
219
|
+
}
|
220
|
+
|
221
|
+
|
222
|
+
// No need to set reuseaddr on Windows.
|
223
|
+
|
224
|
+
|
225
|
+
if (bind (sd_accept, (struct sockaddr*)&sin, sizeof(sin))) {
|
226
|
+
//__warning ("binding failed");
|
227
|
+
goto fail;
|
228
|
+
}
|
229
|
+
|
230
|
+
if (listen (sd_accept, 100)) {
|
231
|
+
//__warning ("listen failed");
|
232
|
+
goto fail;
|
233
|
+
}
|
234
|
+
|
235
|
+
{ // Looking good.
|
236
|
+
AcceptorDescriptor *ad = new AcceptorDescriptor (this, sd_accept);
|
237
|
+
if (!ad)
|
238
|
+
throw std::runtime_error ("unable to allocate acceptor");
|
239
|
+
Add (ad);
|
240
|
+
output_binding = ad->GetBinding().c_str();
|
241
|
+
|
242
|
+
CreateIoCompletionPort ((HANDLE)sd_accept, Iocp, NULL, 0);
|
243
|
+
SOCKET sd = socket (AF_INET, SOCK_STREAM, 0);
|
244
|
+
CreateIoCompletionPort ((HANDLE)sd, Iocp, NULL, 0);
|
245
|
+
AcceptEx (sd_accept, sd,
|
246
|
+
}
|
247
|
+
|
248
|
+
return output_binding;
|
249
|
+
|
250
|
+
fail:
|
251
|
+
if (sd_accept != INVALID_SOCKET)
|
252
|
+
closesocket (sd_accept);
|
253
|
+
return NULL;
|
254
|
+
}
|
255
|
+
|
256
|
+
|
257
|
+
/*******************************
|
258
|
+
EventMachine_t::ConnectToServer
|
259
|
+
*******************************/
|
260
|
+
|
261
|
+
const char *EventMachine_t::ConnectToServer (const char *server, int port)
|
262
|
+
{
|
263
|
+
if (!server || !*server || !port)
|
264
|
+
return NULL;
|
265
|
+
|
266
|
+
sockaddr_in pin;
|
267
|
+
unsigned long HostAddr;
|
268
|
+
|
269
|
+
HostAddr = inet_addr (server);
|
270
|
+
if (HostAddr == INADDR_NONE) {
|
271
|
+
hostent *hp = gethostbyname (server);
|
272
|
+
if (!hp)
|
273
|
+
return NULL;
|
274
|
+
HostAddr = ((in_addr*)(hp->h_addr))->s_addr;
|
275
|
+
}
|
276
|
+
|
277
|
+
memset (&pin, 0, sizeof(pin));
|
278
|
+
pin.sin_family = AF_INET;
|
279
|
+
pin.sin_addr.s_addr = HostAddr;
|
280
|
+
pin.sin_port = htons (port);
|
281
|
+
|
282
|
+
int sd = socket (AF_INET, SOCK_STREAM, 0);
|
283
|
+
if (sd == INVALID_SOCKET)
|
284
|
+
return NULL;
|
285
|
+
|
286
|
+
|
287
|
+
LPOVERLAPPED olap = (LPOVERLAPPED) calloc (1, sizeof (OVERLAPPED));
|
288
|
+
cerr << "I'm dying now\n";
|
289
|
+
throw runtime_error ("UNIMPLEMENTED!!!\n");
|
290
|
+
|
291
|
+
}
|
292
|
+
|
293
|
+
|
294
|
+
|
295
|
+
/*******************
|
296
|
+
EventMachine_t::Add
|
297
|
+
*******************/
|
298
|
+
|
299
|
+
void EventMachine_t::Add (EventableDescriptor *ed)
|
300
|
+
{
|
301
|
+
cerr << "ADD\n";
|
302
|
+
}
|
303
|
+
|
304
|
+
|
305
|
+
|
306
|
+
#endif // OS_WIN32
|
307
|
+
|
data/ext/emwin.h
ADDED
@@ -0,0 +1,99 @@
|
|
1
|
+
/*****************************************************************************
|
2
|
+
|
3
|
+
$Id: em.h 2362 2006-04-23 13:57:09Z francis $
|
4
|
+
|
5
|
+
File: edwin.h
|
6
|
+
Date: 05May06
|
7
|
+
|
8
|
+
Copyright (C) 2006 by Francis Cianfrocca. All Rights Reserved.
|
9
|
+
Gmail: garbagecat10
|
10
|
+
|
11
|
+
This program is free software; you can redistribute it and/or modify
|
12
|
+
it under the terms of the GNU General Public License as published by
|
13
|
+
the Free Software Foundation; either version 2 of the License, or
|
14
|
+
(at your option) any later version.
|
15
|
+
|
16
|
+
This program is distributed in the hope that it will be useful,
|
17
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
18
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
19
|
+
GNU General Public License for more details.
|
20
|
+
|
21
|
+
You should have received a copy of the GNU General Public License
|
22
|
+
along with this program; if not, write to the Free Software
|
23
|
+
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
24
|
+
|
25
|
+
*****************************************************************************/
|
26
|
+
|
27
|
+
|
28
|
+
// THIS ENTIRE FILE IS FOR WINDOWS BUILDS ONLY.
|
29
|
+
// INCOMPLETE AND DISABLED FOR NOW.
|
30
|
+
#ifdef xOS_WIN32
|
31
|
+
|
32
|
+
#ifndef __EventMachine__H_
|
33
|
+
#define __EventMachine__H_
|
34
|
+
|
35
|
+
|
36
|
+
extern time_t gCurrentLoopTime;
|
37
|
+
|
38
|
+
class EventableDescriptor;
|
39
|
+
|
40
|
+
|
41
|
+
/********************
|
42
|
+
class EventMachine_t
|
43
|
+
********************/
|
44
|
+
|
45
|
+
class EventMachine_t
|
46
|
+
{
|
47
|
+
public:
|
48
|
+
EventMachine_t (void(*event_callback)(const char*, int, const char*, int));
|
49
|
+
virtual ~EventMachine_t();
|
50
|
+
|
51
|
+
void Run();
|
52
|
+
void ScheduleHalt();
|
53
|
+
const char *InstallOneshotTimer (int);
|
54
|
+
const char *ConnectToServer (const char *, int);
|
55
|
+
const char *CreateTcpServer (const char *, int);
|
56
|
+
const char *OpenDatagramSocket (const char *, int);
|
57
|
+
|
58
|
+
void Add (EventableDescriptor*);
|
59
|
+
|
60
|
+
public:
|
61
|
+
enum { // Event names
|
62
|
+
TIMER_FIRED = 100,
|
63
|
+
CONNECTION_READ = 101,
|
64
|
+
CONNECTION_UNBOUND = 102,
|
65
|
+
CONNECTION_ACCEPTED = 103
|
66
|
+
};
|
67
|
+
|
68
|
+
private:
|
69
|
+
HANDLE Iocp;
|
70
|
+
|
71
|
+
private:
|
72
|
+
bool _RunOnce();
|
73
|
+
bool _RunTimers();
|
74
|
+
void _AddNewDescriptors();
|
75
|
+
|
76
|
+
private:
|
77
|
+
enum {
|
78
|
+
MaxOutstandingTimers = 40,
|
79
|
+
HeartbeatInterval = 2
|
80
|
+
};
|
81
|
+
void (*EventCallback)(const char*, int, const char*, int);
|
82
|
+
|
83
|
+
class Timer_t: public Bindable_t {
|
84
|
+
};
|
85
|
+
|
86
|
+
multimap<time_t, Timer_t> Timers;
|
87
|
+
vector<EventableDescriptor*> Descriptors;
|
88
|
+
vector<EventableDescriptor*> NewDescriptors;
|
89
|
+
|
90
|
+
time_t NextHeartbeatTime;
|
91
|
+
};
|
92
|
+
|
93
|
+
|
94
|
+
|
95
|
+
|
96
|
+
#endif // __EventMachine__H_
|
97
|
+
|
98
|
+
#endif // OS_WIN32
|
99
|
+
|
data/ext/extconf.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# $Id: extconf.rb
|
1
|
+
# $Id: extconf.rb 2493 2006-05-12 20:57:03Z francis $
|
2
2
|
#
|
3
3
|
#----------------------------------------------------------------------------
|
4
4
|
#
|
@@ -41,6 +41,7 @@ when 'mswin32', 'mingw32', 'bccwin32'
|
|
41
41
|
end
|
42
42
|
|
43
43
|
flags << "-D OS_WIN32"
|
44
|
+
flags << '-D BUILD_FOR_RUBY'
|
44
45
|
flags << "-GX"
|
45
46
|
flags << "-GR"
|
46
47
|
|
@@ -52,13 +53,57 @@ when 'mswin32', 'mingw32', 'bccwin32'
|
|
52
53
|
else
|
53
54
|
flags << '-D WITHOUT_SSL'
|
54
55
|
end
|
56
|
+
|
57
|
+
when 'solaris2.8'
|
58
|
+
unless have_library('pthread') and
|
59
|
+
have_library('nsl') and
|
60
|
+
have_library('socket')
|
61
|
+
exit
|
62
|
+
end
|
63
|
+
|
64
|
+
flags << '-D OS_UNIX'
|
65
|
+
flags << '-D OS_SOLARIS8'
|
66
|
+
flags << '-D BUILD_FOR_RUBY'
|
67
|
+
|
68
|
+
dir_config('ssl')
|
69
|
+
if have_library('ssl') and
|
70
|
+
have_library('crypto') and
|
71
|
+
have_header('openssl/ssl.h') and
|
72
|
+
have_header('openssl/err.h')
|
73
|
+
flags << '-D WITH_SSL'
|
74
|
+
else
|
75
|
+
flags << '-D WITHOUT_SSL'
|
76
|
+
end
|
77
|
+
|
78
|
+
# on Unix we need a g++ link, not gcc.
|
79
|
+
CONFIG['LDSHARED'] = "$(CXX) -shared"
|
80
|
+
|
81
|
+
when 'darwin8.0'
|
82
|
+
flags << '-D OS_UNIX'
|
83
|
+
flags << '-D BUILD_FOR_RUBY'
|
84
|
+
|
85
|
+
dir_config('ssl')
|
86
|
+
if have_library('ssl') and
|
87
|
+
have_library('crypto') and
|
88
|
+
have_library('C') and
|
89
|
+
have_header('openssl/ssl.h') and
|
90
|
+
have_header('openssl/err.h')
|
91
|
+
flags << '-D WITH_SSL'
|
92
|
+
else
|
93
|
+
flags << '-D WITHOUT_SSL'
|
94
|
+
end
|
95
|
+
# on Unix we need a g++ link, not gcc.
|
96
|
+
CONFIG['LDSHARED'] = "$(CXX) $(RC_CFLAGS) -bundle"
|
97
|
+
|
55
98
|
else
|
56
99
|
unless have_library('pthread')
|
57
100
|
exit
|
58
101
|
end
|
59
102
|
|
60
103
|
flags << '-D OS_UNIX'
|
104
|
+
flags << '-D BUILD_FOR_RUBY'
|
61
105
|
|
106
|
+
dir_config('ssl')
|
62
107
|
if have_library('ssl') and
|
63
108
|
have_library('crypto') and
|
64
109
|
have_header('openssl/ssl.h') and
|
data/ext/project.h
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
/*****************************************************************************
|
2
2
|
|
3
|
-
$Id: project.h
|
3
|
+
$Id: project.h 2473 2006-05-11 06:37:31Z francis $
|
4
4
|
|
5
5
|
File: project.h
|
6
6
|
Date: 06Apr06
|
@@ -58,6 +58,9 @@ typedef int SOCKET;
|
|
58
58
|
#define closesocket close
|
59
59
|
#define INVALID_SOCKET -1
|
60
60
|
#define SOCKET_ERROR -1
|
61
|
+
#ifdef OS_SOLARIS8
|
62
|
+
#define INADDR_NONE ((unsigned long)-1)
|
63
|
+
#endif
|
61
64
|
#endif
|
62
65
|
|
63
66
|
|
@@ -74,9 +77,10 @@ typedef int socklen_t;
|
|
74
77
|
|
75
78
|
using namespace std;
|
76
79
|
|
80
|
+
#ifdef WITH_SSL
|
77
81
|
#include <openssl/ssl.h>
|
78
82
|
#include <openssl/err.h>
|
79
|
-
|
83
|
+
#endif
|
80
84
|
|
81
85
|
#include "binder.h"
|
82
86
|
#include "em.h"
|
data/ext/rubymain.cpp
CHANGED
@@ -128,10 +128,15 @@ t_run_machine
|
|
128
128
|
|
129
129
|
static VALUE t_run_machine (VALUE self)
|
130
130
|
{
|
131
|
+
// This whole method and the whole UseThreads mechanism is
|
132
|
+
// tentatively OBSOLETE. If we replace calls to select with
|
133
|
+
// rb_thread_select, then we appear able to interoperate with
|
134
|
+
// Ruby threads.
|
135
|
+
|
131
136
|
#ifdef OS_UNIX
|
132
137
|
UseThreads = true;
|
133
138
|
|
134
|
-
int sp = socketpair (
|
139
|
+
int sp = socketpair (AF_UNIX, SOCK_STREAM, 0, SyncSockets);
|
135
140
|
if (sp)
|
136
141
|
throw std::runtime_error ("no socket pair");
|
137
142
|
|
@@ -354,10 +359,12 @@ Init_rubyeventmachine
|
|
354
359
|
|
355
360
|
extern "C" void Init_rubyeventmachine()
|
356
361
|
{
|
357
|
-
// INCOMPLETE, we need to define class
|
362
|
+
// INCOMPLETE, we need to define class Connections inside module EventMachine
|
363
|
+
// run_machine and run_machine_without_threads are now identical.
|
364
|
+
// Must deprecate the without_threads variant.
|
358
365
|
EmModule = rb_define_module ("EventMachine");
|
359
366
|
rb_define_module_function (EmModule, "initialize_event_machine", (VALUE(*)(...))t_initialize_event_machine, 0);
|
360
|
-
rb_define_module_function (EmModule, "run_machine", (VALUE(*)(...))
|
367
|
+
rb_define_module_function (EmModule, "run_machine", (VALUE(*)(...))t_run_machine_without_threads, 0);
|
361
368
|
rb_define_module_function (EmModule, "run_machine_without_threads", (VALUE(*)(...))t_run_machine_without_threads, 0);
|
362
369
|
rb_define_module_function (EmModule, "add_oneshot_timer", (VALUE(*)(...))t_add_oneshot_timer, 1);
|
363
370
|
rb_define_module_function (EmModule, "start_tcp_server", (VALUE(*)(...))t_start_server, 2);
|
@@ -370,11 +377,9 @@ extern "C" void Init_rubyeventmachine()
|
|
370
377
|
rb_define_module_function (EmModule, "release_machine", (VALUE(*)(...))t_release_machine, 0);
|
371
378
|
rb_define_module_function (EmModule, "stop", (VALUE(*)(...))t_stop, 0);
|
372
379
|
|
373
|
-
|
374
|
-
|
375
|
-
rb_define_class_under (EmModule, "
|
376
|
-
rb_define_class_under (EmModule, "NoHandlerForAcceptedConnection", exception);
|
377
|
-
rb_define_class_under (EmModule, "UnknownTimerFired", exception);
|
380
|
+
rb_define_class_under (EmModule, "ConnectionNotBound", rb_eException);
|
381
|
+
rb_define_class_under (EmModule, "NoHandlerForAcceptedConnection", rb_eException);
|
382
|
+
rb_define_class_under (EmModule, "UnknownTimerFired", rb_eException);
|
378
383
|
|
379
384
|
rb_define_const (EmModule, "TimerFired", (100 << 1) | 1);
|
380
385
|
rb_define_const (EmModule, "ConnectionData", (101 << 1) | 1);
|
data/ext/ssl.cpp
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
/*****************************************************************************
|
2
2
|
|
3
|
-
$Id: ssl.cpp
|
3
|
+
$Id: ssl.cpp 2491 2006-05-12 20:24:19Z francis $
|
4
4
|
|
5
5
|
File: ssl.cpp
|
6
6
|
Date: 30Apr06
|
7
7
|
|
8
8
|
Copyright (C) 2006 by Francis Cianfrocca. All Rights Reserved.
|
9
|
-
Gmail:
|
9
|
+
Gmail: garbagecat10
|
10
10
|
|
11
11
|
This program is free software; you can redistribute it and/or modify
|
12
12
|
it under the terms of the GNU General Public License as published by
|
@@ -25,6 +25,8 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
25
25
|
*****************************************************************************/
|
26
26
|
|
27
27
|
|
28
|
+
#ifdef WITH_SSL
|
29
|
+
|
28
30
|
#include "project.h"
|
29
31
|
|
30
32
|
|
@@ -36,45 +38,45 @@ static void InitializeDefaultCredentials();
|
|
36
38
|
static EVP_PKEY *DefaultPrivateKey = NULL;
|
37
39
|
static X509 *DefaultCertificate = NULL;
|
38
40
|
|
39
|
-
static char PrivateMaterials[] = {
|
40
|
-
-----BEGIN RSA PRIVATE KEY-----\n
|
41
|
-
MIICXAIBAAKBgQDCYYhcw6cGRbhBVShKmbWm7UVsEoBnUf0cCh8AX+MKhMxwVDWV\n
|
42
|
-
Igdskntn3cSJjRtmgVJHIK0lpb/FYHQB93Ohpd9/Z18pDmovfFF9nDbFF0t39hJ/\n
|
43
|
-
AqSzFB3GiVPoFFZJEE1vJqh+3jzsSF5K56bZ6azz38VlZgXeSozNW5bXkQIDAQAB\n
|
44
|
-
AoGALA89gIFcr6BIBo8N5fL3aNHpZXjAICtGav+kTUpuxSiaym9cAeTHuAVv8Xgk\n
|
45
|
-
H2Wbq11uz+6JMLpkQJH/WZ7EV59DPOicXrp0Imr73F3EXBfR7t2EQDYHPMthOA1D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EE1vJqh+3jzsSF5K56bZ6azz38VlZgXeSozNW5bXkQID\n"
|
70
|
+
"AQABo4IBEzCCAQ8wHQYDVR0OBBYEFPJvPd1Fcmd8o/Tm88r+NjYPICCkMIHfBgNV\n"
|
71
|
+
"HSMEgdcwgdSAFPJvPd1Fcmd8o/Tm88r+NjYPICCkoYGwpIGtMIGqMQswCQYDVQQG\n"
|
72
|
+
"EwJVUzERMA8GA1UECBMITmV3IFlvcmsxETAPBgNVBAcTCE5ldyBZb3JrMRYwFAYD\n"
|
73
|
+
"VQQKEw1TdGVhbWhlYXQubmV0MRQwEgYDVQQLEwtFbmdpbmVlcmluZzEdMBsGA1UE\n"
|
74
|
+
"AxMUb3BlbmNhLnN0ZWFtaGVhdC5uZXQxKDAmBgkqhkiG9w0BCQEWGWVuZ2luZWVy\n"
|
75
|
+
"aW5nQHN0ZWFtaGVhdC5uZXSCCQDZuFv087PrPjAMBgNVHRMEBTADAQH/MA0GCSqG\n"
|
76
|
+
"SIb3DQEBBQUAA4GBAC1CXey/4UoLgJiwcEMDxOvW74plks23090iziFIlGgcIhk0\n"
|
77
|
+
"Df6hTAs7H3MWww62ddvR8l07AWfSzSP5L6mDsbvq7EmQsmPODwb6C+i2aF3EDL8j\n"
|
78
|
+
"uw73m4YIGI0Zw2XdBpiOGkx2H56Kya6mJJe/5XORZedh1wpI7zki01tHYbcy\n"
|
79
|
+
"-----END CERTIFICATE-----\n"};
|
78
80
|
|
79
81
|
/* These private materials were made with:
|
80
82
|
* openssl req -new -x509 -keyout cakey.pem -out cacert.pem -nodes -days 6500
|
@@ -375,3 +377,6 @@ int SslBox_t::PutPlaintext (const char *buf, int bufsize)
|
|
375
377
|
return 0;
|
376
378
|
}
|
377
379
|
|
380
|
+
|
381
|
+
#endif // WITH_SSL
|
382
|
+
|
data/ext/ssl.h
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
/*****************************************************************************
|
2
2
|
|
3
|
-
$Id: ssl.h
|
3
|
+
$Id: ssl.h 2473 2006-05-11 06:37:31Z francis $
|
4
4
|
|
5
5
|
File: ssl.h
|
6
6
|
Date: 30Apr06
|
@@ -31,6 +31,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
31
31
|
|
32
32
|
|
33
33
|
|
34
|
+
#ifdef WITH_SSL
|
34
35
|
|
35
36
|
/******************
|
36
37
|
class SslContext_t
|
@@ -85,7 +86,7 @@ class SslBox_t
|
|
85
86
|
|
86
87
|
PageList OutboundQ;
|
87
88
|
};
|
88
|
-
|
89
|
+
#endif // WITH_SSL
|
89
90
|
|
90
91
|
|
91
92
|
#endif // __SslBox__H_
|
data/lib/eventmachine.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# $Id: eventmachine.rb
|
1
|
+
# $Id: eventmachine.rb 2469 2006-05-10 18:11:10Z francis $
|
2
2
|
#
|
3
3
|
# Author:: blackhedd (gmail address: garbagecat20).
|
4
4
|
# Date:: 8 Apr 2006
|
@@ -163,23 +163,30 @@ module EventMachine
|
|
163
163
|
#
|
164
164
|
# See the description of stop_event_loop for an extremely simple client example.
|
165
165
|
#
|
166
|
-
|
167
|
-
|
166
|
+
#--
|
167
|
+
# Obsoleted the use_threads mechanism.
|
168
|
+
#
|
169
|
+
def EventMachine::run &block
|
170
|
+
#def EventMachine::run use_threads = true, &block
|
168
171
|
@conns = {}
|
169
172
|
@acceptors = {}
|
170
173
|
@timers = {}
|
171
174
|
initialize_event_machine
|
172
175
|
block and add_timer 0, block
|
173
|
-
use_threads ? run_machine : run_machine_without_threads
|
176
|
+
#use_threads ? run_machine : run_machine_without_threads
|
177
|
+
run_machine
|
174
178
|
release_machine
|
175
179
|
end
|
176
180
|
|
181
|
+
# +deprecated+
|
182
|
+
#--
|
177
183
|
# EventMachine#run_without_threads is semantically identical
|
178
184
|
# to EventMachine#run, but it runs somewhat faster.
|
179
185
|
# However, it must not be used in applications that spin
|
180
186
|
# Ruby threads.
|
181
187
|
def EventMachine::run_without_threads &block
|
182
|
-
EventMachine::run false, &block
|
188
|
+
#EventMachine::run false, &block
|
189
|
+
EventMachine::run &block
|
183
190
|
end
|
184
191
|
|
185
192
|
# EventMachine#add_timer adds a one-shot timer to the event loop.
|
metadata
CHANGED
@@ -3,16 +3,15 @@ rubygems_version: 0.8.11
|
|
3
3
|
specification_version: 1
|
4
4
|
name: eventmachine
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 0.5.
|
7
|
-
date: 2006-05-
|
6
|
+
version: 0.5.2
|
7
|
+
date: 2006-05-12 00:00:00 -04:00
|
8
8
|
summary: Ruby/EventMachine socket engine library
|
9
9
|
require_paths:
|
10
10
|
- lib
|
11
|
-
- ext
|
12
11
|
email: garbagecat10@gmail.com
|
13
|
-
homepage: http://
|
14
|
-
rubyforge_project:
|
15
|
-
description:
|
12
|
+
homepage: http://rubyeventmachine.com
|
13
|
+
rubyforge_project: eventmachine
|
14
|
+
description: ""
|
16
15
|
autorequire:
|
17
16
|
default_executable:
|
18
17
|
bindir: bin
|
@@ -26,8 +25,8 @@ required_ruby_version: !ruby/object:Gem::Version::Requirement
|
|
26
25
|
platform: ruby
|
27
26
|
signing_key:
|
28
27
|
cert_chain:
|
29
|
-
authors:
|
30
|
-
|
28
|
+
authors:
|
29
|
+
- Francis Cianfrocca
|
31
30
|
files:
|
32
31
|
- tests/testem.rb
|
33
32
|
- lib/eventmachine.rb
|
@@ -41,11 +40,13 @@ files:
|
|
41
40
|
- ext/binder.h
|
42
41
|
- ext/em.h
|
43
42
|
- ext/ed.h
|
43
|
+
- ext/emwin.h
|
44
44
|
- ext/ssl.cpp
|
45
45
|
- ext/project.h
|
46
46
|
- ext/eventmachine.h
|
47
47
|
- ext/em.cpp
|
48
48
|
- ext/extconf.rb
|
49
|
+
- ext/emwin.cpp
|
49
50
|
- ext/page.cpp
|
50
51
|
- ext/ssl.h
|
51
52
|
- README
|
@@ -53,8 +54,12 @@ files:
|
|
53
54
|
- COPYING
|
54
55
|
test_files:
|
55
56
|
- tests/testem.rb
|
56
|
-
rdoc_options:
|
57
|
-
|
57
|
+
rdoc_options:
|
58
|
+
- --title
|
59
|
+
- EventMachine
|
60
|
+
- --main
|
61
|
+
- README
|
62
|
+
- --line-numbers
|
58
63
|
extra_rdoc_files:
|
59
64
|
- README
|
60
65
|
- RELEASE_NOTES
|