eventmachine 1.2.5-x86-mingw32 → 1.2.6-x86-mingw32

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 94a7adfe0994ad28cc3436b19f15699396d42502
4
- data.tar.gz: 83bc8cbe5c49477ad13d6ed991f381dda4aa4e93
3
+ metadata.gz: 01fce4049efa1515b05c6b4366c197f459cedff5
4
+ data.tar.gz: cedca2bc589b3433080e3846dca1ff09d196007e
5
5
  SHA512:
6
- metadata.gz: e74771d1ccde88a58d03bb4f20059a28c934d45612622460f3e5226663db269e6e56e21dcf16e98cb7cf128491acf3c56f216398b4038352b1caf3423311b729
7
- data.tar.gz: 30eff5534f7fa343da26fe2d853880a265808ffec874591b9cb1be95df08bf8aca8d54ccbf961f93f3b04dcaafaba4f2f16e38fcc691a5d598128e3dc197cbc4
6
+ metadata.gz: 0637c8858e2a67de090ff92f8c16bd8a9e13348ed6468f9f4e111bb2656d950fdfc2dbd9780ce55b676a89ab316192855a7240337c145cfd80bd5c97373044b0
7
+ data.tar.gz: 41cf81247ae2693cc03d6e9b993c84ae5639a2c9933ad98092412360a1b1d55c36c6788df577a179ab2b4545398f1631890805fd9ff2d6377488fc908723206c
@@ -1,5 +1,15 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.2.6 (April 30, 2018)
4
+ * *Fix segfault when an Exception is raised from unbind callback (for real this time!)*
5
+ * Fix race condition while initializing the machine [#756]
6
+ * Fix for newer compilers where bind() and std::bind() conflict [#830, #831]
7
+ * Be verbose about SSL connection errors [#807]
8
+ * Avoid explicitly calling class methods when in class scope
9
+ * Java: Add EM_PROTO_SSL/TLS definitions [#773, #791]
10
+ * Java: return zero when sending data to a closed connection [#475, #804]
11
+ * Pure Ruby: Connection::error? calls report_connection_error_status [#801]
12
+
3
13
  ## 1.2.5 (July 27, 2017)
4
14
  * Java: Use long for larger values in oneshot timer intervals [#784, #794]
5
15
 
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # About EventMachine [![Code Climate](https://codeclimate.com/github/eventmachine/eventmachine.svg)](https://codeclimate.com/github/eventmachine/eventmachine)
1
+ # About EventMachine [![Build Status](https://travis-ci.org/eventmachine/eventmachine.svg?branch=master)](https://travis-ci.org/eventmachine/eventmachine) [![Code Climate Maintainability](https://api.codeclimate.com/v1/badges/e9b0603462905d5b9118/maintainability)](https://codeclimate.com/github/eventmachine/eventmachine/maintainability)
2
2
 
3
3
 
4
4
  ## What is EventMachine ##
@@ -32,7 +32,7 @@ EventMachine has been around since the early 2000s and is a mature and battle-te
32
32
 
33
33
  ## What platforms are supported by EventMachine? ##
34
34
 
35
- EventMachine supports Ruby 1.8.7 through 2.3, REE, JRuby and **works well on Windows** as well
35
+ EventMachine supports Ruby 1.8.7 through 2.6, REE, JRuby and **works well on Windows** as well
36
36
  as many operating systems from the Unix family (Linux, Mac OS X, BSD flavors).
37
37
 
38
38
 
@@ -22,7 +22,7 @@ See the file COPYING for complete licensing information.
22
22
  #define DEV_URANDOM "/dev/urandom"
23
23
 
24
24
 
25
- map<uintptr_t, Bindable_t*> Bindable_t::BindingBag;
25
+ std::map<uintptr_t, Bindable_t*> Bindable_t::BindingBag;
26
26
 
27
27
 
28
28
  /********************************
@@ -92,7 +92,7 @@ STATIC: Bindable_t::GetObject
92
92
 
93
93
  Bindable_t *Bindable_t::GetObject (const uintptr_t binding)
94
94
  {
95
- map<uintptr_t, Bindable_t*>::const_iterator i = BindingBag.find (binding);
95
+ std::map<uintptr_t, Bindable_t*>::const_iterator i = BindingBag.find (binding);
96
96
  if (i != BindingBag.end())
97
97
  return i->second;
98
98
  else
@@ -32,7 +32,7 @@ class Bindable_t
32
32
  public:
33
33
  static uintptr_t CreateBinding();
34
34
  static Bindable_t *GetObject (const uintptr_t);
35
- static map<uintptr_t, Bindable_t*> BindingBag;
35
+ static std::map<uintptr_t, Bindable_t*> BindingBag;
36
36
 
37
37
  public:
38
38
  Bindable_t();
data/ext/ed.cpp CHANGED
@@ -320,7 +320,7 @@ void EventableDescriptor::_GenericInboundDispatch(const char *buf, unsigned long
320
320
 
321
321
  if (ProxyTarget) {
322
322
  if (BytesToProxy > 0) {
323
- unsigned long proxied = min(BytesToProxy, size);
323
+ unsigned long proxied = std::min(BytesToProxy, size);
324
324
  ProxyTarget->SendOutboundData(buf, proxied);
325
325
  ProxiedBytes += (unsigned long) proxied;
326
326
  BytesToProxy -= proxied;
@@ -1148,7 +1148,7 @@ void ConnectionDescriptor::_WriteOutboundData()
1148
1148
  #ifdef HAVE_WRITEV
1149
1149
  if (!err) {
1150
1150
  unsigned int sent = bytes_written;
1151
- deque<OutboundPage>::iterator op = OutboundPages.begin();
1151
+ std::deque<OutboundPage>::iterator op = OutboundPages.begin();
1152
1152
 
1153
1153
  for (int i = 0; i < iovcnt; i++) {
1154
1154
  if (iov[i].iov_len <= sent) {
data/ext/ed.h CHANGED
@@ -251,7 +251,7 @@ class ConnectionDescriptor: public EventableDescriptor
251
251
  bool bReadAttemptedAfterClose;
252
252
  bool bWriteAttemptedAfterClose;
253
253
 
254
- deque<OutboundPage> OutboundPages;
254
+ std::deque<OutboundPage> OutboundPages;
255
255
  int OutboundDataSize;
256
256
 
257
257
  #ifdef WITH_SSL
@@ -326,7 +326,7 @@ class DatagramDescriptor: public EventableDescriptor
326
326
  struct sockaddr_in6 From;
327
327
  };
328
328
 
329
- deque<OutboundPage> OutboundPages;
329
+ std::deque<OutboundPage> OutboundPages;
330
330
  int OutboundDataSize;
331
331
 
332
332
  struct sockaddr_in6 ReturnAddress;
@@ -394,7 +394,7 @@ class PipeDescriptor: public EventableDescriptor
394
394
  protected:
395
395
  bool bReadAttemptedAfterClose;
396
396
 
397
- deque<OutboundPage> OutboundPages;
397
+ std::deque<OutboundPage> OutboundPages;
398
398
  int OutboundDataSize;
399
399
 
400
400
  pid_t SubprocessPid;
data/ext/em.cpp CHANGED
@@ -164,8 +164,6 @@ EventMachine_t::~EventMachine_t()
164
164
  {
165
165
  // Run down descriptors
166
166
  size_t i;
167
- for (i = 0; i < DescriptorsToDelete.size(); i++)
168
- delete DescriptorsToDelete[i];
169
167
  for (i = 0; i < NewDescriptors.size(); i++)
170
168
  delete NewDescriptors[i];
171
169
  for (i = 0; i < Descriptors.size(); i++)
@@ -176,7 +174,7 @@ EventMachine_t::~EventMachine_t()
176
174
 
177
175
  // Remove any file watch descriptors
178
176
  while(!Files.empty()) {
179
- map<int, Bindable_t*>::iterator f = Files.begin();
177
+ std::map<int, Bindable_t*>::iterator f = Files.begin();
180
178
  UnwatchFile (f->first);
181
179
  }
182
180
 
@@ -506,7 +504,7 @@ void EventMachine_t::_DispatchHeartbeats()
506
504
  const EventableDescriptor *head = NULL;
507
505
 
508
506
  while (true) {
509
- multimap<uint64_t,EventableDescriptor*>::iterator i = Heartbeats.begin();
507
+ std::multimap<uint64_t,EventableDescriptor*>::iterator i = Heartbeats.begin();
510
508
  if (i == Heartbeats.end())
511
509
  break;
512
510
  if (i->first > MyCurrentLoopTime)
@@ -534,9 +532,9 @@ void EventMachine_t::QueueHeartbeat(EventableDescriptor *ed)
534
532
 
535
533
  if (heartbeat) {
536
534
  #ifndef HAVE_MAKE_PAIR
537
- Heartbeats.insert (multimap<uint64_t,EventableDescriptor*>::value_type (heartbeat, ed));
535
+ Heartbeats.insert (std::multimap<uint64_t,EventableDescriptor*>::value_type (heartbeat, ed));
538
536
  #else
539
- Heartbeats.insert (make_pair (heartbeat, ed));
537
+ Heartbeats.insert (std::make_pair (heartbeat, ed));
540
538
  #endif
541
539
  }
542
540
  }
@@ -547,8 +545,8 @@ EventMachine_t::ClearHeartbeat
547
545
 
548
546
  void EventMachine_t::ClearHeartbeat(uint64_t key, EventableDescriptor* ed)
549
547
  {
550
- multimap<uint64_t,EventableDescriptor*>::iterator it;
551
- pair<multimap<uint64_t,EventableDescriptor*>::iterator,multimap<uint64_t,EventableDescriptor*>::iterator> ret;
548
+ std::multimap<uint64_t,EventableDescriptor*>::iterator it;
549
+ std::pair<std::multimap<uint64_t,EventableDescriptor*>::iterator,std::multimap<uint64_t,EventableDescriptor*>::iterator> ret;
552
550
  ret = Heartbeats.equal_range (key);
553
551
  for (it = ret.first; it != ret.second; ++it) {
554
552
  if (it->second == ed) {
@@ -747,7 +745,7 @@ void EventMachine_t::_RunKqueueOnce()
747
745
  else if (ke->filter == EVFILT_WRITE)
748
746
  ed->Write();
749
747
  else
750
- cerr << "Discarding unknown kqueue event " << ke->filter << endl;
748
+ std::cerr << "Discarding unknown kqueue event " << ke->filter << std::endl;
751
749
 
752
750
  break;
753
751
  }
@@ -786,12 +784,12 @@ timeval EventMachine_t::_TimeTilNextEvent()
786
784
  uint64_t current_time = GetRealTime();
787
785
 
788
786
  if (!Heartbeats.empty()) {
789
- multimap<uint64_t,EventableDescriptor*>::iterator heartbeats = Heartbeats.begin();
787
+ std::multimap<uint64_t,EventableDescriptor*>::iterator heartbeats = Heartbeats.begin();
790
788
  next_event = heartbeats->first;
791
789
  }
792
790
 
793
791
  if (!Timers.empty()) {
794
- multimap<uint64_t,Timer_t>::iterator timers = Timers.begin();
792
+ std::multimap<uint64_t,Timer_t>::iterator timers = Timers.begin();
795
793
  if (next_event == 0 || timers->first < next_event)
796
794
  next_event = timers->first;
797
795
  }
@@ -842,17 +840,6 @@ void EventMachine_t::_CleanupSockets()
842
840
  EventableDescriptor *ed = Descriptors[i];
843
841
  assert (ed);
844
842
  if (ed->ShouldDelete()) {
845
- DescriptorsToDelete.push_back(ed);
846
- }
847
- else
848
- Descriptors [j++] = ed;
849
- }
850
- while ((size_t)j < Descriptors.size())
851
- Descriptors.pop_back();
852
-
853
- nSockets = DescriptorsToDelete.size();
854
- for (i=0; i < nSockets; i++) {
855
- EventableDescriptor *ed = DescriptorsToDelete[i];
856
843
  #ifdef HAVE_EPOLL
857
844
  if (Poller == Poller_Epoll) {
858
845
  assert (epfd != -1);
@@ -868,9 +855,13 @@ void EventMachine_t::_CleanupSockets()
868
855
  ModifiedDescriptors.erase(ed);
869
856
  }
870
857
  #endif
871
- delete ed;
858
+ delete ed;
859
+ }
860
+ else
861
+ Descriptors [j++] = ed;
872
862
  }
873
- DescriptorsToDelete.clear();
863
+ while ((size_t)j < Descriptors.size())
864
+ Descriptors.pop_back();
874
865
  }
875
866
 
876
867
  /*********************************
@@ -1134,7 +1125,7 @@ void EventMachine_t::_RunTimers()
1134
1125
  // one that hasn't expired yet.
1135
1126
 
1136
1127
  while (true) {
1137
- multimap<uint64_t,Timer_t>::iterator i = Timers.begin();
1128
+ std::multimap<uint64_t,Timer_t>::iterator i = Timers.begin();
1138
1129
  if (i == Timers.end())
1139
1130
  break;
1140
1131
  if (i->first > MyCurrentLoopTime)
@@ -1161,9 +1152,9 @@ const uintptr_t EventMachine_t::InstallOneshotTimer (uint64_t milliseconds)
1161
1152
 
1162
1153
  Timer_t t;
1163
1154
  #ifndef HAVE_MAKE_PAIR
1164
- multimap<uint64_t,Timer_t>::iterator i = Timers.insert (multimap<uint64_t,Timer_t>::value_type (fire_at, t));
1155
+ std::multimap<uint64_t,Timer_t>::iterator i = Timers.insert (std::multimap<uint64_t,Timer_t>::value_type (fire_at, t));
1165
1156
  #else
1166
- multimap<uint64_t,Timer_t>::iterator i = Timers.insert (make_pair (fire_at, t));
1157
+ std::multimap<uint64_t,Timer_t>::iterator i = Timers.insert (std::make_pair (fire_at, t));
1167
1158
  #endif
1168
1159
  return i->second.GetBinding();
1169
1160
  }
@@ -1840,7 +1831,7 @@ void EventMachine_t::_ModifyDescriptors()
1840
1831
 
1841
1832
  #ifdef HAVE_EPOLL
1842
1833
  if (Poller == Poller_Epoll) {
1843
- set<EventableDescriptor*>::iterator i = ModifiedDescriptors.begin();
1834
+ std::set<EventableDescriptor*>::iterator i = ModifiedDescriptors.begin();
1844
1835
  while (i != ModifiedDescriptors.end()) {
1845
1836
  assert (*i);
1846
1837
  _ModifyEpollEvent (*i);
@@ -1851,7 +1842,7 @@ void EventMachine_t::_ModifyDescriptors()
1851
1842
 
1852
1843
  #ifdef HAVE_KQUEUE
1853
1844
  if (Poller == Poller_Kqueue) {
1854
- set<EventableDescriptor*>::iterator i = ModifiedDescriptors.begin();
1845
+ std::set<EventableDescriptor*>::iterator i = ModifiedDescriptors.begin();
1855
1846
  while (i != ModifiedDescriptors.end()) {
1856
1847
  assert (*i);
1857
1848
  if ((*i)->GetKqueueArmWrite())
@@ -2129,7 +2120,7 @@ const uintptr_t EventMachine_t::WatchPid (int pid)
2129
2120
  throw std::runtime_error(errbuf);
2130
2121
  }
2131
2122
  Bindable_t* b = new Bindable_t();
2132
- Pids.insert(make_pair (pid, b));
2123
+ Pids.insert(std::make_pair (pid, b));
2133
2124
 
2134
2125
  return b->GetBinding();
2135
2126
  }
@@ -2166,7 +2157,7 @@ void EventMachine_t::UnwatchPid (int pid)
2166
2157
 
2167
2158
  void EventMachine_t::UnwatchPid (const uintptr_t sig)
2168
2159
  {
2169
- for(map<int, Bindable_t*>::iterator i=Pids.begin(); i != Pids.end(); i++)
2160
+ for(std::map<int, Bindable_t*>::iterator i=Pids.begin(); i != Pids.end(); i++)
2170
2161
  {
2171
2162
  if (i->second->GetBinding() == sig) {
2172
2163
  UnwatchPid (i->first);
@@ -2228,7 +2219,7 @@ const uintptr_t EventMachine_t::WatchFile (const char *fpath)
2228
2219
 
2229
2220
  if (wd != -1) {
2230
2221
  Bindable_t* b = new Bindable_t();
2231
- Files.insert(make_pair (wd, b));
2222
+ Files.insert(std::make_pair (wd, b));
2232
2223
 
2233
2224
  return b->GetBinding();
2234
2225
  }
@@ -2262,7 +2253,7 @@ void EventMachine_t::UnwatchFile (int wd)
2262
2253
 
2263
2254
  void EventMachine_t::UnwatchFile (const uintptr_t sig)
2264
2255
  {
2265
- for(map<int, Bindable_t*>::iterator i=Files.begin(); i != Files.end(); i++)
2256
+ for(std::map<int, Bindable_t*>::iterator i=Files.begin(); i != Files.end(); i++)
2266
2257
  {
2267
2258
  if (i->second->GetBinding() == sig) {
2268
2259
  UnwatchFile (i->first);
@@ -2293,7 +2284,7 @@ void EventMachine_t::_ReadInotifyEvents()
2293
2284
  int current = 0;
2294
2285
  while (current < returned) {
2295
2286
  struct inotify_event* event = (struct inotify_event*)(buffer+current);
2296
- map<int, Bindable_t*>::const_iterator bindable = Files.find(event->wd);
2287
+ std::map<int, Bindable_t*>::const_iterator bindable = Files.find(event->wd);
2297
2288
  if (bindable != Files.end()) {
2298
2289
  if (event->mask & (IN_MODIFY | IN_CREATE | IN_DELETE | IN_MOVE)){
2299
2290
  (*EventCallback)(bindable->second->GetBinding(), EM_CONNECTION_READ, "modified", 8);
data/ext/em.h CHANGED
@@ -236,14 +236,13 @@ class EventMachine_t
236
236
  class Timer_t: public Bindable_t {
237
237
  };
238
238
 
239
- multimap<uint64_t, Timer_t> Timers;
240
- multimap<uint64_t, EventableDescriptor*> Heartbeats;
241
- map<int, Bindable_t*> Files;
242
- map<int, Bindable_t*> Pids;
243
- vector<EventableDescriptor*> Descriptors;
244
- vector<EventableDescriptor*> NewDescriptors;
245
- vector<EventableDescriptor*> DescriptorsToDelete;
246
- set<EventableDescriptor*> ModifiedDescriptors;
239
+ std::multimap<uint64_t, Timer_t> Timers;
240
+ std::multimap<uint64_t, EventableDescriptor*> Heartbeats;
241
+ std::map<int, Bindable_t*> Files;
242
+ std::map<int, Bindable_t*> Pids;
243
+ std::vector<EventableDescriptor*> Descriptors;
244
+ std::vector<EventableDescriptor*> NewDescriptors;
245
+ std::set<EventableDescriptor*> ModifiedDescriptors;
247
246
 
248
247
  SOCKET LoopBreakerReader;
249
248
  SOCKET LoopBreakerWriter;
@@ -30,13 +30,12 @@ See the file COPYING for complete licensing information.
30
30
  #include <sys/mman.h>
31
31
  #include <fcntl.h>
32
32
  #include <errno.h>
33
+ #include <unistd.h>
33
34
 
34
35
  #include <iostream>
35
- #include "unistd.h"
36
36
  #include <string>
37
37
  #include <cstring>
38
38
  #include <stdexcept>
39
- using namespace std;
40
39
 
41
40
  #include "mapper.h"
42
41
 
@@ -44,7 +43,7 @@ using namespace std;
44
43
  Mapper_t::Mapper_t
45
44
  ******************/
46
45
 
47
- Mapper_t::Mapper_t (const string &filename)
46
+ Mapper_t::Mapper_t (const std::string &filename)
48
47
  {
49
48
  /* We ASSUME we can open the file.
50
49
  * (More precisely, we assume someone else checked before we got here.)
@@ -52,11 +51,11 @@ Mapper_t::Mapper_t (const string &filename)
52
51
 
53
52
  Fd = open (filename.c_str(), O_RDONLY);
54
53
  if (Fd < 0)
55
- throw runtime_error (strerror (errno));
54
+ throw std::runtime_error (strerror (errno));
56
55
 
57
56
  struct stat st;
58
57
  if (fstat (Fd, &st))
59
- throw runtime_error (strerror (errno));
58
+ throw std::runtime_error (strerror (errno));
60
59
  FileSize = st.st_size;
61
60
 
62
61
  #ifdef OS_WIN32
@@ -65,7 +64,7 @@ Mapper_t::Mapper_t (const string &filename)
65
64
  MapPoint = (const char*) mmap (0, FileSize, PROT_READ, MAP_SHARED, Fd, 0);
66
65
  #endif
67
66
  if (MapPoint == MAP_FAILED)
68
- throw runtime_error (strerror (errno));
67
+ throw std::runtime_error (strerror (errno));
69
68
  }
70
69
 
71
70
 
@@ -128,7 +127,6 @@ const char *Mapper_t::GetChunk (unsigned start)
128
127
  #include <iostream>
129
128
  #include <string>
130
129
  #include <stdexcept>
131
- using namespace std;
132
130
 
133
131
  #include "mapper.h"
134
132
 
@@ -136,7 +134,7 @@ using namespace std;
136
134
  Mapper_t::Mapper_t
137
135
  ******************/
138
136
 
139
- Mapper_t::Mapper_t (const string &filename)
137
+ Mapper_t::Mapper_t (const std::string &filename)
140
138
  {
141
139
  /* We ASSUME we can open the file.
142
140
  * (More precisely, we assume someone else checked before we got here.)
@@ -150,7 +148,7 @@ Mapper_t::Mapper_t (const string &filename)
150
148
  hFile = CreateFile (filename.c_str(), GENERIC_READ|GENERIC_WRITE, FILE_SHARE_DELETE|FILE_SHARE_READ|FILE_SHARE_WRITE, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
151
149
 
152
150
  if (hFile == INVALID_HANDLE_VALUE)
153
- throw runtime_error ("File not found");
151
+ throw std::runtime_error ("File not found");
154
152
 
155
153
  BY_HANDLE_FILE_INFORMATION i;
156
154
  if (GetFileInformationByHandle (hFile, &i))
@@ -158,7 +156,7 @@ Mapper_t::Mapper_t (const string &filename)
158
156
 
159
157
  hMapping = CreateFileMapping (hFile, NULL, PAGE_READWRITE, 0, 0, NULL);
160
158
  if (!hMapping)
161
- throw runtime_error ("File not mapped");
159
+ throw std::runtime_error ("File not mapped");
162
160
 
163
161
  #ifdef OS_WIN32
164
162
  MapPoint = (char*) MapViewOfFile (hMapping, FILE_MAP_WRITE, 0, 0, 0);
@@ -166,7 +164,7 @@ Mapper_t::Mapper_t (const string &filename)
166
164
  MapPoint = (const char*) MapViewOfFile (hMapping, FILE_MAP_WRITE, 0, 0, 0);
167
165
  #endif
168
166
  if (!MapPoint)
169
- throw runtime_error ("Mappoint not read");
167
+ throw std::runtime_error ("Mappoint not read");
170
168
  }
171
169
 
172
170
 
@@ -29,7 +29,7 @@ class Mapper_t
29
29
  class Mapper_t
30
30
  {
31
31
  public:
32
- Mapper_t (const string&);
32
+ Mapper_t (const std::string&);
33
33
  virtual ~Mapper_t();
34
34
 
35
35
  const char *GetChunk (unsigned);
@@ -21,7 +21,6 @@ See the file COPYING for complete licensing information.
21
21
 
22
22
  #include <iostream>
23
23
  #include <stdexcept>
24
- using namespace std;
25
24
 
26
25
  #include <ruby.h>
27
26
  #include "mapper.h"
@@ -95,7 +95,7 @@ void PageList::Push (const char *buf, int size)
95
95
  if (buf && (size > 0)) {
96
96
  char *copy = (char*) malloc (size);
97
97
  if (!copy)
98
- throw runtime_error ("no memory in pagelist");
98
+ throw std::runtime_error ("no memory in pagelist");
99
99
  memcpy (copy, buf, size);
100
100
  Pages.push_back (Page (copy, size));
101
101
  }
data/ext/page.h CHANGED
@@ -44,7 +44,7 @@ class PageList
44
44
  void PopFront();
45
45
 
46
46
  private:
47
- deque<Page> Pages;
47
+ std::deque<Page> Pages;
48
48
  };
49
49
 
50
50
 
@@ -115,8 +115,6 @@ typedef int SOCKET;
115
115
  #include <stdint.h>
116
116
  #endif
117
117
 
118
- using namespace std;
119
-
120
118
  #ifdef WITH_SSL
121
119
  #include <openssl/ssl.h>
122
120
  #include <openssl/err.h>
@@ -120,7 +120,7 @@ static void InitializeDefaultCredentials()
120
120
  SslContext_t::SslContext_t
121
121
  **************************/
122
122
 
123
- SslContext_t::SslContext_t (bool is_server, const string &privkeyfile, const string &certchainfile, const string &cipherlist, const string &ecdh_curve, const string &dhparam, int ssl_version) :
123
+ SslContext_t::SslContext_t (bool is_server, const std::string &privkeyfile, const std::string &certchainfile, const std::string &cipherlist, const std::string &ecdh_curve, const std::string &dhparam, int ssl_version) :
124
124
  bIsServer (is_server),
125
125
  pCtx (NULL),
126
126
  PrivateKey (NULL),
@@ -219,7 +219,7 @@ SslContext_t::SslContext_t (bool is_server, const string &privkeyfile, const str
219
219
  BIO_free(bio);
220
220
  char buf [500];
221
221
  snprintf (buf, sizeof(buf)-1, "dhparam: PEM_read_bio_DHparams(%s) failed", dhparam.c_str());
222
- throw new std::runtime_error(buf);
222
+ throw std::runtime_error (buf);
223
223
  }
224
224
 
225
225
  SSL_CTX_set_tmp_dh(pCtx, dh);
@@ -304,7 +304,7 @@ SslContext_t::~SslContext_t()
304
304
  SslBox_t::SslBox_t
305
305
  ******************/
306
306
 
307
- SslBox_t::SslBox_t (bool is_server, const string &privkeyfile, const string &certchainfile, bool verify_peer, bool fail_if_no_peer_cert, const string &snihostname, const string &cipherlist, const string &ecdh_curve, const string &dhparam, int ssl_version, const uintptr_t binding):
307
+ SslBox_t::SslBox_t (bool is_server, const std::string &privkeyfile, const std::string &certchainfile, bool verify_peer, bool fail_if_no_peer_cert, const std::string &snihostname, const std::string &cipherlist, const std::string &ecdh_curve, const std::string &dhparam, int ssl_version, const uintptr_t binding):
308
308
  bIsServer (is_server),
309
309
  bHandshakeCompleted (false),
310
310
  bVerifyPeer (verify_peer),
@@ -345,8 +345,11 @@ SslBox_t::SslBox_t (bool is_server, const string &privkeyfile, const string &cer
345
345
  SSL_set_verify(pSSL, mode, ssl_verify_wrapper);
346
346
  }
347
347
 
348
- if (!bIsServer)
349
- SSL_connect (pSSL);
348
+ if (!bIsServer) {
349
+ int e = SSL_connect (pSSL);
350
+ if (e != 1)
351
+ ERR_print_errors_fp(stderr);
352
+ }
350
353
  }
351
354
 
352
355
 
@@ -397,6 +400,7 @@ int SslBox_t::GetPlaintext (char *buf, int bufsize)
397
400
  if (e != 1) {
398
401
  int er = SSL_get_error (pSSL, e);
399
402
  if (er != SSL_ERROR_WANT_READ) {
403
+ ERR_print_errors_fp(stderr);
400
404
  // Return -1 for a nonfatal error, -2 for an error that should force the connection down.
401
405
  return (er == SSL_ERROR_SSL) ? (-2) : (-1);
402
406
  }
data/ext/ssl.h CHANGED
@@ -33,7 +33,7 @@ class SslContext_t
33
33
  class SslContext_t
34
34
  {
35
35
  public:
36
- SslContext_t (bool is_server, const string &privkeyfile, const string &certchainfile, const string &cipherlist, const string &ecdh_curve, const string &dhparam, int ssl_version);
36
+ SslContext_t (bool is_server, const std::string &privkeyfile, const std::string &certchainfile, const std::string &cipherlist, const std::string &ecdh_curve, const std::string &dhparam, int ssl_version);
37
37
  virtual ~SslContext_t();
38
38
 
39
39
  private:
@@ -61,7 +61,7 @@ class SslBox_t
61
61
  class SslBox_t
62
62
  {
63
63
  public:
64
- SslBox_t (bool is_server, const string &privkeyfile, const string &certchainfile, bool verify_peer, bool fail_if_no_peer_cert, const string &snihostname, const string &cipherlist, const string &ecdh_curve, const string &dhparam, int ssl_version, const uintptr_t binding);
64
+ SslBox_t (bool is_server, const std::string &privkeyfile, const std::string &certchainfile, bool verify_peer, bool fail_if_no_peer_cert, const std::string &snihostname, const std::string &cipherlist, const std::string &ecdh_curve, const std::string &dhparam, int ssl_version, const uintptr_t binding);
65
65
  virtual ~SslBox_t();
66
66
 
67
67
  int PutPlaintext (const char*, int);
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
@@ -430,6 +430,11 @@ module EventMachine
430
430
  # Needs to be implemented. Currently a no-op stub to allow
431
431
  # certain software to operate with the EM pure-ruby.
432
432
  end
433
+
434
+ # @private
435
+ def report_connection_error_status signature
436
+ get_sock_opt(signature, Socket::SOL_SOCKET, Socket::SO_ERROR).int
437
+ end
433
438
  end
434
439
  end
435
440
 
@@ -1,3 +1,3 @@
1
1
  module EventMachine
2
- VERSION = "1.2.5"
2
+ VERSION = "1.2.6"
3
3
  end
@@ -177,14 +177,15 @@ module EventMachine
177
177
  @next_tick_queue ||= []
178
178
  @tails ||= []
179
179
  begin
180
+ initialize_event_machine
180
181
  @reactor_pid = Process.pid
182
+ @reactor_thread = Thread.current
181
183
  @reactor_running = true
182
- initialize_event_machine
184
+
183
185
  (b = blk || block) and add_timer(0, b)
184
186
  if @next_tick_queue && !@next_tick_queue.empty?
185
187
  add_timer(0) { signal_loopbreak }
186
188
  end
187
- @reactor_thread = Thread.current
188
189
 
189
190
  # Rubinius needs to come back into "Ruby space" for GC to work,
190
191
  # so we'll crank the machine here.
@@ -984,7 +985,7 @@ module EventMachine
984
985
  # do some work during the next_tick. The only mechanism we have from the
985
986
  # ruby side is next_tick itself, although ideally, we'd just drop a byte
986
987
  # on the loopback descriptor.
987
- EM.next_tick {} if exception_raised
988
+ next_tick {} if exception_raised
988
989
  end
989
990
  end
990
991
  end
@@ -1079,7 +1080,7 @@ module EventMachine
1079
1080
  raise error unless eback
1080
1081
  @resultqueue << [error, eback]
1081
1082
  end
1082
- EventMachine.signal_loopbreak
1083
+ signal_loopbreak
1083
1084
  end
1084
1085
  end
1085
1086
  @threadpool << thread
@@ -1490,12 +1491,22 @@ module EventMachine
1490
1491
  rescue Errno::EBADF, IOError
1491
1492
  end
1492
1493
  end
1493
- rescue Exception => e
1494
- if stopping?
1495
- @wrapped_exception = $!
1496
- stop
1494
+ # As noted above, unbind absolutely must not raise an exception or the reactor will crash.
1495
+ # If there is no EM.error_handler, or if the error_handler retrows, then stop the reactor,
1496
+ # stash the exception in $wrapped_exception, and the exception will be raised after the
1497
+ # reactor is cleaned up (see the last line of self.run).
1498
+ rescue Exception => error
1499
+ if instance_variable_defined? :@error_handler
1500
+ begin
1501
+ @error_handler.call error
1502
+ # No need to stop unless error_handler rethrows
1503
+ rescue Exception => error
1504
+ @wrapped_exception = error
1505
+ stop
1506
+ end
1497
1507
  else
1498
- raise e
1508
+ @wrapped_exception = error
1509
+ stop
1499
1510
  end
1500
1511
  end
1501
1512
  elsif c = @acceptors.delete( conn_binding )
@@ -1503,7 +1514,7 @@ module EventMachine
1503
1514
  else
1504
1515
  if $! # Bubble user generated errors.
1505
1516
  @wrapped_exception = $!
1506
- EM.stop
1517
+ stop
1507
1518
  else
1508
1519
  raise ConnectionNotBound, "received ConnectionUnbound for an unknown signature: #{conn_binding}"
1509
1520
  end
@@ -80,6 +80,17 @@ module EventMachine
80
80
  # @private
81
81
  SslVerify = 109
82
82
 
83
+ # @private
84
+ EM_PROTO_SSLv2 = 2
85
+ # @private
86
+ EM_PROTO_SSLv3 = 4
87
+ # @private
88
+ EM_PROTO_TLSv1 = 8
89
+ # @private
90
+ EM_PROTO_TLSv1_1 = 16
91
+ # @private
92
+ EM_PROTO_TLSv1_2 = 32
93
+
83
94
  # Exceptions that are defined in rubymain.cpp
84
95
  class ConnectionError < RuntimeError; end
85
96
  class ConnectionNotBound < RuntimeError; end
@@ -127,6 +138,8 @@ module EventMachine
127
138
  end
128
139
  def self.send_data sig, data, length
129
140
  @em.sendData sig, data.to_java_bytes
141
+ rescue java.lang.NullPointerException
142
+ 0
130
143
  end
131
144
  def self.send_datagram sig, data, length, address, port
132
145
  @em.sendDatagram sig, data.to_java_bytes, length, address, port
@@ -113,6 +113,9 @@ class TestBasic < Test::Unit::TestCase
113
113
  EM.start_server "127.0.0.1", @port
114
114
  EM.connect "127.0.0.1", @port, UnbindError
115
115
  }
116
+
117
+ # Remove the error handler before the next test
118
+ EM.error_handler(nil)
116
119
  end
117
120
 
118
121
  module BrsTestSrv
@@ -309,6 +312,9 @@ class TestBasic < Test::Unit::TestCase
309
312
  EM.add_timer(0.001) { EM.stop }
310
313
  end
311
314
 
315
+ # Remove the error handler before the next test
316
+ EM.error_handler(nil)
317
+
312
318
  assert_equal 1, errors.size
313
319
  assert_equal [:first, :second], ticks
314
320
  end
@@ -41,7 +41,7 @@ class TestIPv6 < Test::Unit::TestCase
41
41
  EM.run do
42
42
  EM.open_datagram_socket(@@public_ipv6, @local_port) do |s|
43
43
  def s.receive_data data
44
- _port, @@remote_ip = Socket.unpack_sockaddr_in(s.get_peername)
44
+ _port, @@remote_ip = Socket.unpack_sockaddr_in(get_peername)
45
45
  @@received_data = data
46
46
  EM.stop
47
47
  end
@@ -56,7 +56,7 @@ class TestPool < Test::Unit::TestCase
56
56
  assert_equal pooled_res, pooled_res2
57
57
  end
58
58
 
59
- def test_supports_custom_error_handler
59
+ def test_supports_custom_on_error
60
60
  eres = nil
61
61
  pool.on_error do |res|
62
62
  eres = res
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: eventmachine
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.5
4
+ version: 1.2.6
5
5
  platform: x86-mingw32
6
6
  authors:
7
7
  - Francis Cianfrocca
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2017-07-28 00:00:00.000000000 Z
12
+ date: 2018-04-30 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: test-unit