ext/apache2/DirectoryMapper.h in passenger-4.0.60 vs ext/apache2/DirectoryMapper.h in passenger-5.0.0.beta1

- old
+ new

@@ -1,8 +1,8 @@ /* * Phusion Passenger - https://www.phusionpassenger.com/ - * Copyright (c) 2010-2013 Phusion + * Copyright (c) 2010-2014 Phusion * * "Phusion Passenger" is a trademark of Hongli Lai & Ninh Bui. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -28,10 +28,11 @@ #include <string> #include <set> #include <cstring> #include <oxt/backtrace.hpp> +#include <boost/thread.hpp> #include "Configuration.hpp" #include <ApplicationPool2/AppTypes.h> #include <Utils.h> #include <Utils/CachedFileStat.hpp> @@ -70,10 +71,11 @@ class DirectoryMapper { private: DirConfig *config; request_rec *r; CachedFileStat *cstat; + boost::mutex *cstatMutex; const char *baseURI; string publicDir; string appRoot; unsigned int throttleRate; PassengerAppType appType: 7; @@ -140,11 +142,11 @@ */ publicDir = docRoot; } UPDATE_TRACE_POINT(); - AppTypeDetector detector(cstat, throttleRate); + AppTypeDetector detector(cstat, cstatMutex, throttleRate); PassengerAppType appType; string appRoot; if (config->appType == NULL) { if (config->appRoot == NULL) { appType = detector.checkDocumentRoot(publicDir, @@ -172,19 +174,22 @@ public: /** * Create a new DirectoryMapper object. * * @param cstat A CachedFileStat object used for statting files. + * @param cstatMutex A mutex for locking CachedFileStat, making its + * usage thread-safe. * @param throttleRate A throttling rate for cstat. * @warning Do not use this object after the destruction of <tt>r</tt>, * <tt>config</tt> or <tt>cstat</tt>. */ - DirectoryMapper(request_rec *r, DirConfig *config, - CachedFileStat *cstat, unsigned int throttleRate) { + DirectoryMapper(request_rec *r, DirConfig *config, CachedFileStat *cstat, + boost::mutex *cstatMutex, unsigned int throttleRate) { this->r = r; this->config = config; this->cstat = cstat; + this->cstatMutex = cstatMutex; this->throttleRate = throttleRate; appType = PAT_NONE; baseURI = NULL; autoDetectionDone = false; } @@ -214,11 +219,11 @@ * @throws FileSystemException An error occured while examening the filesystem. * @throws DocumentRootDeterminationError Unable to query the location of the document root. * @throws TimeRetrievalException * @throws boost::thread_interrupted */ - string getPublicDirectory() { + const string &getPublicDirectory() { autoDetect(); return publicDir; } /** @@ -228,10 +233,10 @@ * @throws FileSystemException An error occured while examening the filesystem. * @throws DocumentRootDeterminationError Unable to query the location of the document root. * @throws TimeRetrievalException * @throws boost::thread_interrupted */ - string getAppRoot() { + const string &getAppRoot() { autoDetect(); return appRoot; } /**