Skip to content

Commit

Permalink
Fix for SIGSEGV crash when using passenger with OOBGC. The least busy
Browse files Browse the repository at this point in the history
process selection method was only suitable for enabled processes, and
not disabling/disabled processes. Closes GH-1469.
  • Loading branch information
Daniel Knoppel (Phusion) committed May 1, 2015
1 parent bb5aba7 commit b70b4fc
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 3 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
Release 5.0.8
-------------

* Fixes a Passenger crash (SIGSEGV) that occurs occasionally when out-of-band garbage collection is enabled. Closes GH-1469.


Release 5.0.7
-------------

Expand Down
28 changes: 25 additions & 3 deletions ext/common/ApplicationPool2/Group.h
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,7 @@ class Group: public boost::enable_shared_from_this<Group> {
RouteResult route(const Options &options) const {
if (OXT_LIKELY(enabledCount > 0)) {
if (options.stickySessionId == 0) {
Process *process = findProcessWithLowestBusyness(enabledProcesses);
Process *process = findEnabledProcessWithLowestBusyness();
if (process->canBeRoutedTo()) {
return RouteResult(process);
} else {
Expand Down Expand Up @@ -496,6 +496,29 @@ class Group: public boost::enable_shared_from_this<Group> {
return NULL;
}

int lowestBusyness = -1;
Process *leastBusyProcess = NULL;
ProcessList::const_iterator it;
ProcessList::const_iterator end = processes.end();
for (it = processes.begin(); it != end; it++) {
Process *process = (*it).get();
int busyness = process->busyness();
if (lowestBusyness == -1 || lowestBusyness > busyness) {
lowestBusyness = busyness;
leastBusyProcess = process;
}
}
return leastBusyProcess;
}

/**
* Cache-optimized version of findProcessWithLowestBusyness() for the common case.
*/
Process *findEnabledProcessWithLowestBusyness() const {
if (enabledProcesses.empty()) {
return NULL;
}

int leastBusyProcessIndex = -1;
int lowestBusyness = 0;
unsigned int i, size = enabledProcessBusynessLevels.size();
Expand Down Expand Up @@ -1006,8 +1029,7 @@ class Group: public boost::enable_shared_from_this<Group> {
assert(m_spawning || restarting() || poolAtFullCapacity());

if (disablingCount > 0 && !restarting()) {
Process *process = findProcessWithLowestBusyness(
disablingProcesses);
Process *process = findProcessWithLowestBusyness(disablingProcesses);
assert(process != NULL);
if (!process->isTotallyBusy()) {
return newSession(process, newOptions.currentTime);
Expand Down

0 comments on commit b70b4fc

Please sign in to comment.