We got nominated! Help us out and vote for GitHub as Best Bootstrapped Startup of 2008. (You can vote once a day.) [ hide ]

public
Description: Phusion Passenger (mod_rails)
Homepage: http://www.modrails.com/
Clone URL: git://github.com/FooBarWidget/passenger.git
Click here to lend your support to: passenger and make a donation at www.pledgie.com !
Fix a possible invariant violation in the application pool algorithm.
Hongli Lai (Phusion) (author)
Thu Nov 20 05:07:03 -0800 2008
commit  f50d427a7e408065d47f2829b78c99bb2994ef11
tree    261e49e7982882e4ea6159fca0a72c65d4d4c293
parent  7d6bbf6a21ade4153cf050e69c422b9c185132d1
...
282
283
284
285
286
287
288
289
290
291
 
 
 
 
 
 
 
 
 
292
293
294
...
282
283
284
 
 
 
 
 
 
 
285
286
287
288
289
290
291
292
293
294
295
296
0
@@ -282,13 +282,15 @@ function spawn_or_use_existing(app_root, options):
0
       count++
0
       active++
0
   else:
0
- # There are no apps for this app root.
0
- wait until (active < max)
0
- # FIXME: there's a possible concurrency issue here. After
0
- # waiting and having reacquired the lock, the state might have
0
- # been completely changed, and there may now exist an instance
0
- # of this application domain.
0
- if count == max:
0
+ # There are no apps for this app root. Wait until there's at
0
+ # least 1 idle instance, or until there's an empty slot in the
0
+ # pool, then restart this function. Restarting is necessary,
0
+ # because after waiting and reacquiring the lack, some other
0
+ # thread might already have spawned instances for this app root.
0
+ if (active >= max):
0
+ wait until _active_ has changed
0
+ goto beginning of functions
0
+ elsif count == max:
0
       # Here we are in a though situation. There are several
0
       # apps which are inactive, and none of them have
0
       # application root _app_root_, so we must kill one of
...
518
519
520
521
 
522
523
524
 
 
525
526
527
...
518
519
520
 
521
522
 
 
523
524
525
526
527
0
@@ -518,10 +518,10 @@ private:
0
           activeOrMaxChanged.notify_all();
0
         }
0
       } else {
0
- while (!(active < max)) {
0
+ if (active >= max) {
0
           activeOrMaxChanged.wait(l);
0
- }
0
- if (count == max) {
0
+ goto beginning_of_function;
0
+ } else if (count == max) {
0
           container = inactiveApps.front();
0
           inactiveApps.pop_front();
0
           domain = domains[container->app->getAppRoot()].get();

Comments

    No one has commented yet.