Skip to content

Commit

Permalink
Merge pull request #839 from sodabrew/release-1.2.6
Browse files Browse the repository at this point in the history
Release 1.2.6
  • Loading branch information
sodabrew authored Apr 30, 2018
2 parents 9f9b05c + 358a6d4 commit 159ad95
Show file tree
Hide file tree
Showing 24 changed files with 135 additions and 98 deletions.
21 changes: 12 additions & 9 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
sudo: false
dist: trusty
language: ruby
bundler_args: --without documentation
script: bundle exec rake compile test
# Pin Rubygems to a working version. Sometimes it breaks upstream. Update now and then.
before_install:
- 'if [[ "$TRAVIS_OS_NAME" = "osx" ]]; then brew install openssl; fi'
- gem update --system 2.7.4
- gem update bundler
env:
global:
- TESTOPTS=-v
language: ruby
sudo: false
dist: trusty
rvm:
- 2.6
- 2.5
- 2.4
- 2.3
- 2.2
Expand All @@ -18,25 +23,23 @@ rvm:
- ruby-head
# - rbx
# - rbx-2
# - rbx-3
# - jruby-1.7
# - jruby-9
matrix:
fast_finish: true
allow_failures:
# - rvm: rbx
# - rvm: rbx-2
# - rvm: rbx-3
- rvm: ruby-head
- rvm: 2.0.0
- rvm: 2.0.0
- rvm: 2.3
os: osx
osx_image: xcode8
# - rvm: jruby-1.7
# - rvm: jruby-9
include:
- rvm: 1.8.7
dist: precise
- rvm: 1.9.2
dist: precise
- rvm: 2.0.0
- rvm: 2.3
os: osx
osx_image: xcode8
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# Changelog

## 1.2.6 (April 30, 2018)
* *Fix segfault when an Exception is raised from unbind callback (for real this time!)*
* Fix race condition while initializing the machine [#756]
* Fix for newer compilers where bind() and std::bind() conflict [#830, #831]
* Be verbose about SSL connection errors [#807]
* Avoid explicitly calling class methods when in class scope
* Java: Add EM_PROTO_SSL/TLS definitions [#773, #791]
* Java: return zero when sending data to a closed connection [#475, #804]
* Pure Ruby: Connection::error? calls report_connection_error_status [#801]

## 1.2.5 (July 27, 2017)
* Java: Use long for larger values in oneshot timer intervals [#784, #794]

Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# About EventMachine [![Code Climate](https://codeclimate.com/github/eventmachine/eventmachine.svg)](https://codeclimate.com/github/eventmachine/eventmachine)
# 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)


## What is EventMachine ##
Expand Down Expand Up @@ -32,7 +32,7 @@ EventMachine has been around since the early 2000s and is a mature and battle-te

## What platforms are supported by EventMachine? ##

EventMachine supports Ruby 1.8.7 through 2.3, REE, JRuby and **works well on Windows** as well
EventMachine supports Ruby 1.8.7 through 2.6, REE, JRuby and **works well on Windows** as well
as many operating systems from the Unix family (Linux, Mac OS X, BSD flavors).


Expand Down
4 changes: 2 additions & 2 deletions ext/binder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ See the file COPYING for complete licensing information.
#define DEV_URANDOM "/dev/urandom"


map<uintptr_t, Bindable_t*> Bindable_t::BindingBag;
std::map<uintptr_t, Bindable_t*> Bindable_t::BindingBag;


/********************************
Expand Down Expand Up @@ -92,7 +92,7 @@ STATIC: Bindable_t::GetObject

Bindable_t *Bindable_t::GetObject (const uintptr_t binding)
{
map<uintptr_t, Bindable_t*>::const_iterator i = BindingBag.find (binding);
std::map<uintptr_t, Bindable_t*>::const_iterator i = BindingBag.find (binding);
if (i != BindingBag.end())
return i->second;
else
Expand Down
2 changes: 1 addition & 1 deletion ext/binder.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class Bindable_t
public:
static uintptr_t CreateBinding();
static Bindable_t *GetObject (const uintptr_t);
static map<uintptr_t, Bindable_t*> BindingBag;
static std::map<uintptr_t, Bindable_t*> BindingBag;

public:
Bindable_t();
Expand Down
4 changes: 2 additions & 2 deletions ext/ed.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ void EventableDescriptor::_GenericInboundDispatch(const char *buf, unsigned long

if (ProxyTarget) {
if (BytesToProxy > 0) {
unsigned long proxied = min(BytesToProxy, size);
unsigned long proxied = std::min(BytesToProxy, size);
ProxyTarget->SendOutboundData(buf, proxied);
ProxiedBytes += (unsigned long) proxied;
BytesToProxy -= proxied;
Expand Down Expand Up @@ -1148,7 +1148,7 @@ void ConnectionDescriptor::_WriteOutboundData()
#ifdef HAVE_WRITEV
if (!err) {
unsigned int sent = bytes_written;
deque<OutboundPage>::iterator op = OutboundPages.begin();
std::deque<OutboundPage>::iterator op = OutboundPages.begin();

for (int i = 0; i < iovcnt; i++) {
if (iov[i].iov_len <= sent) {
Expand Down
6 changes: 3 additions & 3 deletions ext/ed.h
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ class ConnectionDescriptor: public EventableDescriptor
bool bReadAttemptedAfterClose;
bool bWriteAttemptedAfterClose;

deque<OutboundPage> OutboundPages;
std::deque<OutboundPage> OutboundPages;
int OutboundDataSize;

#ifdef WITH_SSL
Expand Down Expand Up @@ -326,7 +326,7 @@ class DatagramDescriptor: public EventableDescriptor
struct sockaddr_in6 From;
};

deque<OutboundPage> OutboundPages;
std::deque<OutboundPage> OutboundPages;
int OutboundDataSize;

struct sockaddr_in6 ReturnAddress;
Expand Down Expand Up @@ -394,7 +394,7 @@ class PipeDescriptor: public EventableDescriptor
protected:
bool bReadAttemptedAfterClose;

deque<OutboundPage> OutboundPages;
std::deque<OutboundPage> OutboundPages;
int OutboundDataSize;

pid_t SubprocessPid;
Expand Down
59 changes: 25 additions & 34 deletions ext/em.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,6 @@ EventMachine_t::~EventMachine_t()
{
// Run down descriptors
size_t i;
for (i = 0; i < DescriptorsToDelete.size(); i++)
delete DescriptorsToDelete[i];
for (i = 0; i < NewDescriptors.size(); i++)
delete NewDescriptors[i];
for (i = 0; i < Descriptors.size(); i++)
Expand All @@ -176,7 +174,7 @@ EventMachine_t::~EventMachine_t()

// Remove any file watch descriptors
while(!Files.empty()) {
map<int, Bindable_t*>::iterator f = Files.begin();
std::map<int, Bindable_t*>::iterator f = Files.begin();
UnwatchFile (f->first);
}

Expand Down Expand Up @@ -506,7 +504,7 @@ void EventMachine_t::_DispatchHeartbeats()
const EventableDescriptor *head = NULL;

while (true) {
multimap<uint64_t,EventableDescriptor*>::iterator i = Heartbeats.begin();
std::multimap<uint64_t,EventableDescriptor*>::iterator i = Heartbeats.begin();
if (i == Heartbeats.end())
break;
if (i->first > MyCurrentLoopTime)
Expand Down Expand Up @@ -534,9 +532,9 @@ void EventMachine_t::QueueHeartbeat(EventableDescriptor *ed)

if (heartbeat) {
#ifndef HAVE_MAKE_PAIR
Heartbeats.insert (multimap<uint64_t,EventableDescriptor*>::value_type (heartbeat, ed));
Heartbeats.insert (std::multimap<uint64_t,EventableDescriptor*>::value_type (heartbeat, ed));
#else
Heartbeats.insert (make_pair (heartbeat, ed));
Heartbeats.insert (std::make_pair (heartbeat, ed));
#endif
}
}
Expand All @@ -547,8 +545,8 @@ EventMachine_t::ClearHeartbeat

void EventMachine_t::ClearHeartbeat(uint64_t key, EventableDescriptor* ed)
{
multimap<uint64_t,EventableDescriptor*>::iterator it;
pair<multimap<uint64_t,EventableDescriptor*>::iterator,multimap<uint64_t,EventableDescriptor*>::iterator> ret;
std::multimap<uint64_t,EventableDescriptor*>::iterator it;
std::pair<std::multimap<uint64_t,EventableDescriptor*>::iterator,std::multimap<uint64_t,EventableDescriptor*>::iterator> ret;
ret = Heartbeats.equal_range (key);
for (it = ret.first; it != ret.second; ++it) {
if (it->second == ed) {
Expand Down Expand Up @@ -747,7 +745,7 @@ void EventMachine_t::_RunKqueueOnce()
else if (ke->filter == EVFILT_WRITE)
ed->Write();
else
cerr << "Discarding unknown kqueue event " << ke->filter << endl;
std::cerr << "Discarding unknown kqueue event " << ke->filter << std::endl;

break;
}
Expand Down Expand Up @@ -786,12 +784,12 @@ timeval EventMachine_t::_TimeTilNextEvent()
uint64_t current_time = GetRealTime();

if (!Heartbeats.empty()) {
multimap<uint64_t,EventableDescriptor*>::iterator heartbeats = Heartbeats.begin();
std::multimap<uint64_t,EventableDescriptor*>::iterator heartbeats = Heartbeats.begin();
next_event = heartbeats->first;
}

if (!Timers.empty()) {
multimap<uint64_t,Timer_t>::iterator timers = Timers.begin();
std::multimap<uint64_t,Timer_t>::iterator timers = Timers.begin();
if (next_event == 0 || timers->first < next_event)
next_event = timers->first;
}
Expand Down Expand Up @@ -842,17 +840,6 @@ void EventMachine_t::_CleanupSockets()
EventableDescriptor *ed = Descriptors[i];
assert (ed);
if (ed->ShouldDelete()) {
DescriptorsToDelete.push_back(ed);
}
else
Descriptors [j++] = ed;
}
while ((size_t)j < Descriptors.size())
Descriptors.pop_back();

nSockets = DescriptorsToDelete.size();
for (i=0; i < nSockets; i++) {
EventableDescriptor *ed = DescriptorsToDelete[i];
#ifdef HAVE_EPOLL
if (Poller == Poller_Epoll) {
assert (epfd != -1);
Expand All @@ -868,9 +855,13 @@ void EventMachine_t::_CleanupSockets()
ModifiedDescriptors.erase(ed);
}
#endif
delete ed;
delete ed;
}
else
Descriptors [j++] = ed;
}
DescriptorsToDelete.clear();
while ((size_t)j < Descriptors.size())
Descriptors.pop_back();
}

/*********************************
Expand Down Expand Up @@ -1134,7 +1125,7 @@ void EventMachine_t::_RunTimers()
// one that hasn't expired yet.

while (true) {
multimap<uint64_t,Timer_t>::iterator i = Timers.begin();
std::multimap<uint64_t,Timer_t>::iterator i = Timers.begin();
if (i == Timers.end())
break;
if (i->first > MyCurrentLoopTime)
Expand All @@ -1161,9 +1152,9 @@ const uintptr_t EventMachine_t::InstallOneshotTimer (uint64_t milliseconds)

Timer_t t;
#ifndef HAVE_MAKE_PAIR
multimap<uint64_t,Timer_t>::iterator i = Timers.insert (multimap<uint64_t,Timer_t>::value_type (fire_at, t));
std::multimap<uint64_t,Timer_t>::iterator i = Timers.insert (std::multimap<uint64_t,Timer_t>::value_type (fire_at, t));
#else
multimap<uint64_t,Timer_t>::iterator i = Timers.insert (make_pair (fire_at, t));
std::multimap<uint64_t,Timer_t>::iterator i = Timers.insert (std::make_pair (fire_at, t));
#endif
return i->second.GetBinding();
}
Expand Down Expand Up @@ -1840,7 +1831,7 @@ void EventMachine_t::_ModifyDescriptors()

#ifdef HAVE_EPOLL
if (Poller == Poller_Epoll) {
set<EventableDescriptor*>::iterator i = ModifiedDescriptors.begin();
std::set<EventableDescriptor*>::iterator i = ModifiedDescriptors.begin();
while (i != ModifiedDescriptors.end()) {
assert (*i);
_ModifyEpollEvent (*i);
Expand All @@ -1851,7 +1842,7 @@ void EventMachine_t::_ModifyDescriptors()

#ifdef HAVE_KQUEUE
if (Poller == Poller_Kqueue) {
set<EventableDescriptor*>::iterator i = ModifiedDescriptors.begin();
std::set<EventableDescriptor*>::iterator i = ModifiedDescriptors.begin();
while (i != ModifiedDescriptors.end()) {
assert (*i);
if ((*i)->GetKqueueArmWrite())
Expand Down Expand Up @@ -2129,7 +2120,7 @@ const uintptr_t EventMachine_t::WatchPid (int pid)
throw std::runtime_error(errbuf);
}
Bindable_t* b = new Bindable_t();
Pids.insert(make_pair (pid, b));
Pids.insert(std::make_pair (pid, b));

return b->GetBinding();
}
Expand Down Expand Up @@ -2166,7 +2157,7 @@ void EventMachine_t::UnwatchPid (int pid)

void EventMachine_t::UnwatchPid (const uintptr_t sig)
{
for(map<int, Bindable_t*>::iterator i=Pids.begin(); i != Pids.end(); i++)
for(std::map<int, Bindable_t*>::iterator i=Pids.begin(); i != Pids.end(); i++)
{
if (i->second->GetBinding() == sig) {
UnwatchPid (i->first);
Expand Down Expand Up @@ -2228,7 +2219,7 @@ const uintptr_t EventMachine_t::WatchFile (const char *fpath)

if (wd != -1) {
Bindable_t* b = new Bindable_t();
Files.insert(make_pair (wd, b));
Files.insert(std::make_pair (wd, b));

return b->GetBinding();
}
Expand Down Expand Up @@ -2262,7 +2253,7 @@ void EventMachine_t::UnwatchFile (int wd)

void EventMachine_t::UnwatchFile (const uintptr_t sig)
{
for(map<int, Bindable_t*>::iterator i=Files.begin(); i != Files.end(); i++)
for(std::map<int, Bindable_t*>::iterator i=Files.begin(); i != Files.end(); i++)
{
if (i->second->GetBinding() == sig) {
UnwatchFile (i->first);
Expand Down Expand Up @@ -2293,7 +2284,7 @@ void EventMachine_t::_ReadInotifyEvents()
int current = 0;
while (current < returned) {
struct inotify_event* event = (struct inotify_event*)(buffer+current);
map<int, Bindable_t*>::const_iterator bindable = Files.find(event->wd);
std::map<int, Bindable_t*>::const_iterator bindable = Files.find(event->wd);
if (bindable != Files.end()) {
if (event->mask & (IN_MODIFY | IN_CREATE | IN_DELETE | IN_MOVE)){
(*EventCallback)(bindable->second->GetBinding(), EM_CONNECTION_READ, "modified", 8);
Expand Down
15 changes: 7 additions & 8 deletions ext/em.h
Original file line number Diff line number Diff line change
Expand Up @@ -236,14 +236,13 @@ class EventMachine_t
class Timer_t: public Bindable_t {
};

multimap<uint64_t, Timer_t> Timers;
multimap<uint64_t, EventableDescriptor*> Heartbeats;
map<int, Bindable_t*> Files;
map<int, Bindable_t*> Pids;
vector<EventableDescriptor*> Descriptors;
vector<EventableDescriptor*> NewDescriptors;
vector<EventableDescriptor*> DescriptorsToDelete;
set<EventableDescriptor*> ModifiedDescriptors;
std::multimap<uint64_t, Timer_t> Timers;
std::multimap<uint64_t, EventableDescriptor*> Heartbeats;
std::map<int, Bindable_t*> Files;
std::map<int, Bindable_t*> Pids;
std::vector<EventableDescriptor*> Descriptors;
std::vector<EventableDescriptor*> NewDescriptors;
std::set<EventableDescriptor*> ModifiedDescriptors;

SOCKET LoopBreakerReader;
SOCKET LoopBreakerWriter;
Expand Down
Loading

0 comments on commit 159ad95

Please sign in to comment.