passenger 2.0.1 → 2.0.2
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of passenger might be problematic. Click here for more details.
- data/Rakefile +2 -1
- data/doc/Security of user switching support.html +1 -1
- data/doc/Users guide.html +1 -1
- data/ext/apache2/ApplicationPoolServerExecutable.cpp +4 -2
- data/ext/apache2/Bucket.cpp +104 -0
- data/ext/apache2/Bucket.h +36 -0
- data/ext/apache2/Configuration.h +1 -1
- data/ext/apache2/Hooks.cpp +2 -5
- data/ext/apache2/Utils.h +1 -1
- data/ext/boost/non_type.hpp +27 -0
- metadata +7 -247
- data/doc/Architectural overview.html +0 -740
- data/doc/cxxapi/ApplicationPoolServer_8h-source.html +0 -677
- data/doc/cxxapi/ApplicationPool_8h-source.html +0 -212
- data/doc/cxxapi/Application_8h-source.html +0 -448
- data/doc/cxxapi/Configuration_8h-source.html +0 -180
- data/doc/cxxapi/DummySpawnManager_8h-source.html +0 -126
- data/doc/cxxapi/Exceptions_8h-source.html +0 -244
- data/doc/cxxapi/Hooks_8h-source.html +0 -63
- data/doc/cxxapi/Logging_8h-source.html +0 -136
- data/doc/cxxapi/MessageChannel_8h-source.html +0 -524
- data/doc/cxxapi/SpawnManager_8h-source.html +0 -593
- data/doc/cxxapi/StandardApplicationPool_8h-source.html +0 -713
- data/doc/cxxapi/System_8h-source.html +0 -251
- data/doc/cxxapi/Utils_8h-source.html +0 -283
- data/doc/cxxapi/annotated.html +0 -59
- data/doc/cxxapi/classClient-members.html +0 -35
- data/doc/cxxapi/classClient.html +0 -117
- data/doc/cxxapi/classDirectoryMapper-members.html +0 -38
- data/doc/cxxapi/classDirectoryMapper.html +0 -203
- data/doc/cxxapi/classHooks-members.html +0 -33
- data/doc/cxxapi/classHooks.html +0 -43
- data/doc/cxxapi/classPassenger_1_1Application-members.html +0 -38
- data/doc/cxxapi/classPassenger_1_1Application.html +0 -229
- data/doc/cxxapi/classPassenger_1_1ApplicationPool-members.html +0 -40
- data/doc/cxxapi/classPassenger_1_1ApplicationPool.html +0 -331
- data/doc/cxxapi/classPassenger_1_1ApplicationPoolServer-members.html +0 -36
- data/doc/cxxapi/classPassenger_1_1ApplicationPoolServer.html +0 -225
- data/doc/cxxapi/classPassenger_1_1ApplicationPool__inherit__graph.map +0 -1
- data/doc/cxxapi/classPassenger_1_1ApplicationPool__inherit__graph.md5 +0 -1
- data/doc/cxxapi/classPassenger_1_1ApplicationPool__inherit__graph.png +0 -0
- data/doc/cxxapi/classPassenger_1_1Application_1_1Session-members.html +0 -43
- data/doc/cxxapi/classPassenger_1_1Application_1_1Session.html +0 -329
- data/doc/cxxapi/classPassenger_1_1BusyException-members.html +0 -33
- data/doc/cxxapi/classPassenger_1_1BusyException.html +0 -47
- data/doc/cxxapi/classPassenger_1_1ConfigurationException-members.html +0 -33
- data/doc/cxxapi/classPassenger_1_1ConfigurationException.html +0 -44
- data/doc/cxxapi/classPassenger_1_1DummySpawnManager-members.html +0 -33
- data/doc/cxxapi/classPassenger_1_1DummySpawnManager.html +0 -51
- data/doc/cxxapi/classPassenger_1_1FileNotFoundException-members.html +0 -33
- data/doc/cxxapi/classPassenger_1_1FileNotFoundException.html +0 -51
- data/doc/cxxapi/classPassenger_1_1FileNotFoundException__inherit__graph.map +0 -1
- data/doc/cxxapi/classPassenger_1_1FileNotFoundException__inherit__graph.md5 +0 -1
- data/doc/cxxapi/classPassenger_1_1FileNotFoundException__inherit__graph.png +0 -0
- data/doc/cxxapi/classPassenger_1_1FileSystemException-members.html +0 -38
- data/doc/cxxapi/classPassenger_1_1FileSystemException.html +0 -61
- data/doc/cxxapi/classPassenger_1_1FileSystemException__inherit__graph.map +0 -1
- data/doc/cxxapi/classPassenger_1_1FileSystemException__inherit__graph.md5 +0 -1
- data/doc/cxxapi/classPassenger_1_1FileSystemException__inherit__graph.png +0 -0
- data/doc/cxxapi/classPassenger_1_1IOException-members.html +0 -33
- data/doc/cxxapi/classPassenger_1_1IOException.html +0 -54
- data/doc/cxxapi/classPassenger_1_1IOException__inherit__graph.map +0 -1
- data/doc/cxxapi/classPassenger_1_1IOException__inherit__graph.md5 +0 -1
- data/doc/cxxapi/classPassenger_1_1IOException__inherit__graph.png +0 -0
- data/doc/cxxapi/classPassenger_1_1MessageChannel-members.html +0 -47
- data/doc/cxxapi/classPassenger_1_1MessageChannel.html +0 -591
- data/doc/cxxapi/classPassenger_1_1SpawnException-members.html +0 -35
- data/doc/cxxapi/classPassenger_1_1SpawnException.html +0 -77
- data/doc/cxxapi/classPassenger_1_1SpawnManager-members.html +0 -37
- data/doc/cxxapi/classPassenger_1_1SpawnManager.html +0 -255
- data/doc/cxxapi/classPassenger_1_1StandardApplicationPool-members.html +0 -42
- data/doc/cxxapi/classPassenger_1_1StandardApplicationPool.html +0 -372
- data/doc/cxxapi/classPassenger_1_1StandardApplicationPool__inherit__graph.map +0 -1
- data/doc/cxxapi/classPassenger_1_1StandardApplicationPool__inherit__graph.md5 +0 -1
- data/doc/cxxapi/classPassenger_1_1StandardApplicationPool__inherit__graph.png +0 -0
- data/doc/cxxapi/classPassenger_1_1SystemException-members.html +0 -37
- data/doc/cxxapi/classPassenger_1_1SystemException.html +0 -154
- data/doc/cxxapi/classPassenger_1_1SystemException__inherit__graph.map +0 -1
- data/doc/cxxapi/classPassenger_1_1SystemException__inherit__graph.md5 +0 -1
- data/doc/cxxapi/classPassenger_1_1SystemException__inherit__graph.png +0 -0
- data/doc/cxxapi/classPassenger_1_1TempFile-members.html +0 -36
- data/doc/cxxapi/classPassenger_1_1TempFile.html +0 -128
- data/doc/cxxapi/classPassenger_1_1Thread-members.html +0 -35
- data/doc/cxxapi/classPassenger_1_1Thread.html +0 -100
- data/doc/cxxapi/classboost_1_1this__thread_1_1disable__syscall__interruption-members.html +0 -33
- data/doc/cxxapi/classboost_1_1this__thread_1_1disable__syscall__interruption.html +0 -46
- data/doc/cxxapi/classboost_1_1this__thread_1_1enable__syscall__interruption-members.html +0 -33
- data/doc/cxxapi/classboost_1_1this__thread_1_1enable__syscall__interruption.html +0 -44
- data/doc/cxxapi/classboost_1_1this__thread_1_1restore__syscall__interruption-members.html +0 -33
- data/doc/cxxapi/classboost_1_1this__thread_1_1restore__syscall__interruption.html +0 -44
- data/doc/cxxapi/definitions_8h-source.html +0 -28
- data/doc/cxxapi/doxygen.css +0 -433
- data/doc/cxxapi/doxygen.png +0 -0
- data/doc/cxxapi/files.html +0 -41
- data/doc/cxxapi/ftv2blank.png +0 -0
- data/doc/cxxapi/ftv2doc.png +0 -0
- data/doc/cxxapi/ftv2folderclosed.png +0 -0
- data/doc/cxxapi/ftv2folderopen.png +0 -0
- data/doc/cxxapi/ftv2lastnode.png +0 -0
- data/doc/cxxapi/ftv2link.png +0 -0
- data/doc/cxxapi/ftv2mlastnode.png +0 -0
- data/doc/cxxapi/ftv2mnode.png +0 -0
- data/doc/cxxapi/ftv2node.png +0 -0
- data/doc/cxxapi/ftv2plastnode.png +0 -0
- data/doc/cxxapi/ftv2pnode.png +0 -0
- data/doc/cxxapi/ftv2vertline.png +0 -0
- data/doc/cxxapi/functions.html +0 -212
- data/doc/cxxapi/functions_func.html +0 -207
- data/doc/cxxapi/functions_type.html +0 -46
- data/doc/cxxapi/functions_vars.html +0 -48
- data/doc/cxxapi/graph_legend.dot +0 -22
- data/doc/cxxapi/graph_legend.html +0 -87
- data/doc/cxxapi/graph_legend.png +0 -0
- data/doc/cxxapi/group__Configuration.html +0 -236
- data/doc/cxxapi/group__Configuration.png +0 -0
- data/doc/cxxapi/group__Core.html +0 -51
- data/doc/cxxapi/group__Core.png +0 -0
- data/doc/cxxapi/group__Exceptions.html +0 -43
- data/doc/cxxapi/group__Hooks.html +0 -46
- data/doc/cxxapi/group__Hooks.png +0 -0
- data/doc/cxxapi/group__Support.html +0 -406
- data/doc/cxxapi/hierarchy.html +0 -67
- data/doc/cxxapi/index.html +0 -11
- data/doc/cxxapi/inherit__graph__0.map +0 -1
- data/doc/cxxapi/inherit__graph__0.md5 +0 -1
- data/doc/cxxapi/inherit__graph__0.png +0 -0
- data/doc/cxxapi/inherit__graph__1.map +0 -1
- data/doc/cxxapi/inherit__graph__1.md5 +0 -1
- data/doc/cxxapi/inherit__graph__1.png +0 -0
- data/doc/cxxapi/inherit__graph__10.map +0 -1
- data/doc/cxxapi/inherit__graph__10.md5 +0 -1
- data/doc/cxxapi/inherit__graph__10.png +0 -0
- data/doc/cxxapi/inherit__graph__11.map +0 -1
- data/doc/cxxapi/inherit__graph__11.md5 +0 -1
- data/doc/cxxapi/inherit__graph__11.png +0 -0
- data/doc/cxxapi/inherit__graph__12.map +0 -1
- data/doc/cxxapi/inherit__graph__12.md5 +0 -1
- data/doc/cxxapi/inherit__graph__12.png +0 -0
- data/doc/cxxapi/inherit__graph__13.map +0 -1
- data/doc/cxxapi/inherit__graph__13.md5 +0 -1
- data/doc/cxxapi/inherit__graph__13.png +0 -0
- data/doc/cxxapi/inherit__graph__14.map +0 -2
- data/doc/cxxapi/inherit__graph__14.md5 +0 -1
- data/doc/cxxapi/inherit__graph__14.png +0 -0
- data/doc/cxxapi/inherit__graph__15.map +0 -1
- data/doc/cxxapi/inherit__graph__15.md5 +0 -1
- data/doc/cxxapi/inherit__graph__15.png +0 -0
- data/doc/cxxapi/inherit__graph__16.map +0 -1
- data/doc/cxxapi/inherit__graph__16.md5 +0 -1
- data/doc/cxxapi/inherit__graph__16.png +0 -0
- data/doc/cxxapi/inherit__graph__17.map +0 -1
- data/doc/cxxapi/inherit__graph__17.md5 +0 -1
- data/doc/cxxapi/inherit__graph__17.png +0 -0
- data/doc/cxxapi/inherit__graph__2.map +0 -1
- data/doc/cxxapi/inherit__graph__2.md5 +0 -1
- data/doc/cxxapi/inherit__graph__2.png +0 -0
- data/doc/cxxapi/inherit__graph__3.map +0 -1
- data/doc/cxxapi/inherit__graph__3.md5 +0 -1
- data/doc/cxxapi/inherit__graph__3.png +0 -0
- data/doc/cxxapi/inherit__graph__4.map +0 -1
- data/doc/cxxapi/inherit__graph__4.md5 +0 -1
- data/doc/cxxapi/inherit__graph__4.png +0 -0
- data/doc/cxxapi/inherit__graph__5.map +0 -1
- data/doc/cxxapi/inherit__graph__5.md5 +0 -1
- data/doc/cxxapi/inherit__graph__5.png +0 -0
- data/doc/cxxapi/inherit__graph__6.map +0 -1
- data/doc/cxxapi/inherit__graph__6.md5 +0 -1
- data/doc/cxxapi/inherit__graph__6.png +0 -0
- data/doc/cxxapi/inherit__graph__7.map +0 -1
- data/doc/cxxapi/inherit__graph__7.md5 +0 -1
- data/doc/cxxapi/inherit__graph__7.png +0 -0
- data/doc/cxxapi/inherit__graph__8.map +0 -1
- data/doc/cxxapi/inherit__graph__8.md5 +0 -1
- data/doc/cxxapi/inherit__graph__8.png +0 -0
- data/doc/cxxapi/inherit__graph__9.map +0 -2
- data/doc/cxxapi/inherit__graph__9.md5 +0 -1
- data/doc/cxxapi/inherit__graph__9.png +0 -0
- data/doc/cxxapi/inherits.html +0 -102
- data/doc/cxxapi/main.html +0 -27
- data/doc/cxxapi/modules.html +0 -34
- data/doc/cxxapi/namespacePassenger.html +0 -208
- data/doc/cxxapi/namespacePassenger_1_1InterruptableCalls.html +0 -43
- data/doc/cxxapi/namespacemembers.html +0 -70
- data/doc/cxxapi/namespacemembers_func.html +0 -66
- data/doc/cxxapi/namespacemembers_type.html +0 -46
- data/doc/cxxapi/namespaces.html +0 -35
- data/doc/cxxapi/structPassenger_1_1AnythingToString-members.html +0 -33
- data/doc/cxxapi/structPassenger_1_1AnythingToString.html +0 -49
- data/doc/cxxapi/structPassenger_1_1AnythingToString_3_01vector_3_01string_01_4_01_4-members.html +0 -33
- data/doc/cxxapi/structPassenger_1_1AnythingToString_3_01vector_3_01string_01_4_01_4.html +0 -49
- data/doc/cxxapi/tab_b.gif +0 -0
- data/doc/cxxapi/tab_l.gif +0 -0
- data/doc/cxxapi/tab_r.gif +0 -0
- data/doc/cxxapi/tabs.css +0 -102
- data/doc/cxxapi/tree.html +0 -166
- data/doc/rdoc/classes/ConditionVariable.html +0 -160
- data/doc/rdoc/classes/Exception.html +0 -120
- data/doc/rdoc/classes/GC.html +0 -113
- data/doc/rdoc/classes/IO.html +0 -150
- data/doc/rdoc/classes/Passenger.html +0 -136
- data/doc/rdoc/classes/Passenger/AbstractRequestHandler.html +0 -401
- data/doc/rdoc/classes/Passenger/AbstractServer.html +0 -649
- data/doc/rdoc/classes/Passenger/AbstractServer/ServerAlreadyStarted.html +0 -97
- data/doc/rdoc/classes/Passenger/AbstractServer/ServerError.html +0 -96
- data/doc/rdoc/classes/Passenger/AbstractServer/ServerNotStarted.html +0 -97
- data/doc/rdoc/classes/Passenger/AbstractServer/UnknownMessage.html +0 -96
- data/doc/rdoc/classes/Passenger/AppInitError.html +0 -137
- data/doc/rdoc/classes/Passenger/Application.html +0 -296
- data/doc/rdoc/classes/Passenger/ConsoleTextTemplate.html +0 -172
- data/doc/rdoc/classes/Passenger/FrameworkInitError.html +0 -143
- data/doc/rdoc/classes/Passenger/HTMLTemplate.html +0 -175
- data/doc/rdoc/classes/Passenger/InitializationError.html +0 -141
- data/doc/rdoc/classes/Passenger/MessageChannel.html +0 -488
- data/doc/rdoc/classes/Passenger/NativeSupport.html +0 -320
- data/doc/rdoc/classes/Passenger/SpawnManager.html +0 -375
- data/doc/rdoc/classes/Passenger/UnknownError.html +0 -125
- data/doc/rdoc/classes/Passenger/Utils.html +0 -580
- data/doc/rdoc/classes/Passenger/VersionNotFound.html +0 -140
- data/doc/rdoc/classes/PlatformInfo.html +0 -292
- data/doc/rdoc/classes/RakeExtensions.html +0 -197
- data/doc/rdoc/created.rid +0 -1
- data/doc/rdoc/files/DEVELOPERS_TXT.html +0 -230
- data/doc/rdoc/files/README.html +0 -150
- data/doc/rdoc/files/ext/passenger/native_support_c.html +0 -92
- data/doc/rdoc/files/lib/passenger/abstract_request_handler_rb.html +0 -125
- data/doc/rdoc/files/lib/passenger/abstract_server_rb.html +0 -127
- data/doc/rdoc/files/lib/passenger/application_rb.html +0 -123
- data/doc/rdoc/files/lib/passenger/console_text_template_rb.html +0 -122
- data/doc/rdoc/files/lib/passenger/constants_rb.html +0 -114
- data/doc/rdoc/files/lib/passenger/dependencies_rb.html +0 -130
- data/doc/rdoc/files/lib/passenger/exceptions_rb.html +0 -118
- data/doc/rdoc/files/lib/passenger/html_template_rb.html +0 -122
- data/doc/rdoc/files/lib/passenger/message_channel_rb.html +0 -118
- data/doc/rdoc/files/lib/passenger/platform_info_rb.html +0 -122
- data/doc/rdoc/files/lib/passenger/simple_benchmarking_rb.html +0 -118
- data/doc/rdoc/files/lib/passenger/spawn_manager_rb.html +0 -139
- data/doc/rdoc/files/lib/passenger/utils_rb.html +0 -130
- data/doc/rdoc/files/lib/rake/extensions_rb.html +0 -122
- data/doc/rdoc/fr_class_index.html +0 -71
- data/doc/rdoc/fr_file_index.html +0 -63
- data/doc/rdoc/fr_method_index.html +0 -120
- data/doc/rdoc/index.html +0 -26
- data/doc/rdoc/rdoc-style.css +0 -187
@@ -1,251 +0,0 @@
|
|
1
|
-
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
2
|
-
<html><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
|
3
|
-
<title>Passenger: System.h Source File</title>
|
4
|
-
<link href="doxygen.css" rel="stylesheet" type="text/css">
|
5
|
-
<link href="tabs.css" rel="stylesheet" type="text/css">
|
6
|
-
</head><body>
|
7
|
-
<!-- Generated by Doxygen 1.5.5 -->
|
8
|
-
<div class="navigation" id="top">
|
9
|
-
<div class="tabs">
|
10
|
-
<ul>
|
11
|
-
<li><a href="main.html"><span>Main Page</span></a></li>
|
12
|
-
<li><a href="modules.html"><span>Modules</span></a></li>
|
13
|
-
<li><a href="namespaces.html"><span>Namespaces</span></a></li>
|
14
|
-
<li><a href="annotated.html"><span>Classes</span></a></li>
|
15
|
-
<li class="current"><a href="files.html"><span>Files</span></a></li>
|
16
|
-
</ul>
|
17
|
-
</div>
|
18
|
-
<h1>System.h</h1><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">/*</span>
|
19
|
-
<a name="l00002"></a>00002 <span class="comment"> * Phusion Passenger - http://www.modrails.com/</span>
|
20
|
-
<a name="l00003"></a>00003 <span class="comment"> * Copyright (C) 2008 Phusion</span>
|
21
|
-
<a name="l00004"></a>00004 <span class="comment"> *</span>
|
22
|
-
<a name="l00005"></a>00005 <span class="comment"> * Phusion Passenger is a trademark of Hongli Lai & Ninh Bui.</span>
|
23
|
-
<a name="l00006"></a>00006 <span class="comment"> *</span>
|
24
|
-
<a name="l00007"></a>00007 <span class="comment"> * This program is free software; you can redistribute it and/or modify</span>
|
25
|
-
<a name="l00008"></a>00008 <span class="comment"> * it under the terms of the GNU General Public License as published by</span>
|
26
|
-
<a name="l00009"></a>00009 <span class="comment"> * the Free Software Foundation; version 2 of the License.</span>
|
27
|
-
<a name="l00010"></a>00010 <span class="comment"> *</span>
|
28
|
-
<a name="l00011"></a>00011 <span class="comment"> * This program is distributed in the hope that it will be useful,</span>
|
29
|
-
<a name="l00012"></a>00012 <span class="comment"> * but WITHOUT ANY WARRANTY; without even the implied warranty of</span>
|
30
|
-
<a name="l00013"></a>00013 <span class="comment"> * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the</span>
|
31
|
-
<a name="l00014"></a>00014 <span class="comment"> * GNU General Public License for more details.</span>
|
32
|
-
<a name="l00015"></a>00015 <span class="comment"> *</span>
|
33
|
-
<a name="l00016"></a>00016 <span class="comment"> * You should have received a copy of the GNU General Public License along</span>
|
34
|
-
<a name="l00017"></a>00017 <span class="comment"> * with this program; if not, write to the Free Software Foundation, Inc.,</span>
|
35
|
-
<a name="l00018"></a>00018 <span class="comment"> * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.</span>
|
36
|
-
<a name="l00019"></a>00019 <span class="comment"> */</span>
|
37
|
-
<a name="l00020"></a>00020 <span class="preprocessor">#ifndef _PASSENGER_SYSTEM_H_</span>
|
38
|
-
<a name="l00021"></a>00021 <span class="preprocessor"></span><span class="preprocessor">#define _PASSENGER_SYSTEM_H_</span>
|
39
|
-
<a name="l00022"></a>00022 <span class="preprocessor"></span>
|
40
|
-
<a name="l00023"></a>00023 <span class="preprocessor">#include <boost/thread.hpp></span>
|
41
|
-
<a name="l00024"></a>00024 <span class="preprocessor">#include <boost/date_time/posix_time/posix_time_types.hpp></span>
|
42
|
-
<a name="l00025"></a>00025 <span class="preprocessor">#include <sys/types.h></span>
|
43
|
-
<a name="l00026"></a>00026 <span class="preprocessor">#include <sys/wait.h></span>
|
44
|
-
<a name="l00027"></a>00027 <span class="preprocessor">#include <sys/socket.h></span>
|
45
|
-
<a name="l00028"></a>00028 <span class="preprocessor">#include <pthread.h></span>
|
46
|
-
<a name="l00029"></a>00029 <span class="preprocessor">#include <unistd.h></span>
|
47
|
-
<a name="l00030"></a>00030 <span class="preprocessor">#include <signal.h></span>
|
48
|
-
<a name="l00031"></a>00031 <span class="preprocessor">#include <cstdio></span>
|
49
|
-
<a name="l00032"></a>00032 <span class="preprocessor">#include <ctime></span>
|
50
|
-
<a name="l00033"></a>00033 <span class="preprocessor">#include <cassert></span>
|
51
|
-
<a name="l00034"></a>00034 <span class="comment"></span>
|
52
|
-
<a name="l00035"></a>00035 <span class="comment">/**</span>
|
53
|
-
<a name="l00036"></a>00036 <span class="comment"> * Support for interruption of blocking system calls and C library calls.</span>
|
54
|
-
<a name="l00037"></a>00037 <span class="comment"> *</span>
|
55
|
-
<a name="l00038"></a>00038 <span class="comment"> * This file provides a framework for writing multithreading code that can</span>
|
56
|
-
<a name="l00039"></a>00039 <span class="comment"> * be interrupted, even when blocked on system calls or C library calls.</span>
|
57
|
-
<a name="l00040"></a>00040 <span class="comment"> *</span>
|
58
|
-
<a name="l00041"></a>00041 <span class="comment"> * One must first call Passenger::setupSysCallInterruptionSupport().</span>
|
59
|
-
<a name="l00042"></a>00042 <span class="comment"> * Then one may use the functions in Passenger::InterruptableCalls</span>
|
60
|
-
<a name="l00043"></a>00043 <span class="comment"> * as drop-in replacements for system calls or C library functions.</span>
|
61
|
-
<a name="l00044"></a>00044 <span class="comment"> * Thread::interrupt() and Thread::interruptAndJoin() should be used</span>
|
62
|
-
<a name="l00045"></a>00045 <span class="comment"> * for interrupting threads.</span>
|
63
|
-
<a name="l00046"></a>00046 <span class="comment"> *</span>
|
64
|
-
<a name="l00047"></a>00047 <span class="comment"> * By default, interruptions are caught.</span>
|
65
|
-
<a name="l00048"></a>00048 <span class="comment"> */</span>
|
66
|
-
<a name="l00049"></a>00049
|
67
|
-
<a name="l00050"></a>00050 <span class="comment">// This is one of the things that Java is good at and C++ sucks at. Sigh...</span>
|
68
|
-
<a name="l00051"></a>00051
|
69
|
-
<a name="l00052"></a>00052 <span class="keyword">namespace </span>Passenger {
|
70
|
-
<a name="l00053"></a>00053
|
71
|
-
<a name="l00054"></a>00054 <span class="keyword">using namespace </span>boost;
|
72
|
-
<a name="l00055"></a>00055
|
73
|
-
<a name="l00056"></a>00056 <span class="keyword">static</span> <span class="keyword">const</span> <span class="keywordtype">int</span> INTERRUPTION_SIGNAL = SIGINT;
|
74
|
-
<a name="l00057"></a>00057 <span class="comment"></span>
|
75
|
-
<a name="l00058"></a>00058 <span class="comment"> /**</span>
|
76
|
-
<a name="l00059"></a>00059 <span class="comment"> * Setup system call interruption support.</span>
|
77
|
-
<a name="l00060"></a>00060 <span class="comment"> * This function may only be called once. It installs a signal handler</span>
|
78
|
-
<a name="l00061"></a>00061 <span class="comment"> * for INTERRUPTION_SIGNAL, so one should not install a different signal</span>
|
79
|
-
<a name="l00062"></a>00062 <span class="comment"> * handler for that signal after calling this function.</span>
|
80
|
-
<a name="l00063"></a>00063 <span class="comment"> */</span>
|
81
|
-
<a name="l00064"></a>00064 <span class="keywordtype">void</span> <a class="code" href="namespacePassenger.html#453b743532b8c3b9877fe2fadb031501" title="Setup system call interruption support.">setupSyscallInterruptionSupport</a>();
|
82
|
-
<a name="l00065"></a>00065 <span class="comment"></span>
|
83
|
-
<a name="l00066"></a>00066 <span class="comment"> /**</span>
|
84
|
-
<a name="l00067"></a>00067 <span class="comment"> * Thread class with system call interruption support.</span>
|
85
|
-
<a name="l00068"></a>00068 <span class="comment"> */</span>
|
86
|
-
<a name="l00069"></a><a class="code" href="classPassenger_1_1Thread.html">00069</a> <span class="keyword">class </span><a class="code" href="classPassenger_1_1Thread.html" title="Thread class with system call interruption support.">Thread</a>: <span class="keyword">public</span> thread {
|
87
|
-
<a name="l00070"></a>00070 <span class="keyword">public</span>:
|
88
|
-
<a name="l00071"></a>00071 <span class="keyword">template</span> <<span class="keyword">class</span> F>
|
89
|
-
<a name="l00072"></a>00072 <span class="keyword">explicit</span> <a class="code" href="classPassenger_1_1Thread.html" title="Thread class with system call interruption support.">Thread</a>(F f, <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> stackSize = 0)
|
90
|
-
<a name="l00073"></a>00073 : thread(f, stackSize) {}
|
91
|
-
<a name="l00074"></a>00074 <span class="comment"></span>
|
92
|
-
<a name="l00075"></a>00075 <span class="comment"> /**</span>
|
93
|
-
<a name="l00076"></a>00076 <span class="comment"> * Interrupt the thread. This method behaves just like</span>
|
94
|
-
<a name="l00077"></a>00077 <span class="comment"> * boost::thread::interrupt(), but will also respect the interruption</span>
|
95
|
-
<a name="l00078"></a>00078 <span class="comment"> * points defined in Passenger::InterruptableCalls.</span>
|
96
|
-
<a name="l00079"></a>00079 <span class="comment"> *</span>
|
97
|
-
<a name="l00080"></a>00080 <span class="comment"> * Note that an interruption request may get lost, depending on the</span>
|
98
|
-
<a name="l00081"></a>00081 <span class="comment"> * current execution point of the thread. Thus, one should call this</span>
|
99
|
-
<a name="l00082"></a>00082 <span class="comment"> * method in a loop, until a certain goal condition has been fulfilled.</span>
|
100
|
-
<a name="l00083"></a>00083 <span class="comment"> * interruptAndJoin() is a convenience method that implements this</span>
|
101
|
-
<a name="l00084"></a>00084 <span class="comment"> * pattern.</span>
|
102
|
-
<a name="l00085"></a>00085 <span class="comment"> */</span>
|
103
|
-
<a name="l00086"></a><a class="code" href="classPassenger_1_1Thread.html#2212f1aee683798318ec2bcd57550407">00086</a> <span class="keywordtype">void</span> <a class="code" href="classPassenger_1_1Thread.html#2212f1aee683798318ec2bcd57550407" title="Interrupt the thread.">interrupt</a>() {
|
104
|
-
<a name="l00087"></a>00087 <span class="keywordtype">int</span> ret;
|
105
|
-
<a name="l00088"></a>00088
|
106
|
-
<a name="l00089"></a>00089 thread::interrupt();
|
107
|
-
<a name="l00090"></a>00090 <span class="keywordflow">do</span> {
|
108
|
-
<a name="l00091"></a>00091 ret = pthread_kill(native_handle(),
|
109
|
-
<a name="l00092"></a>00092 INTERRUPTION_SIGNAL);
|
110
|
-
<a name="l00093"></a>00093 } <span class="keywordflow">while</span> (ret == EINTR);
|
111
|
-
<a name="l00094"></a>00094 }
|
112
|
-
<a name="l00095"></a>00095 <span class="comment"></span>
|
113
|
-
<a name="l00096"></a>00096 <span class="comment"> /**</span>
|
114
|
-
<a name="l00097"></a>00097 <span class="comment"> * Keep interrupting the thread until it's done, then join it.</span>
|
115
|
-
<a name="l00098"></a>00098 <span class="comment"> *</span>
|
116
|
-
<a name="l00099"></a>00099 <span class="comment"> * @throws boost::thread_interrupted</span>
|
117
|
-
<a name="l00100"></a>00100 <span class="comment"> */</span>
|
118
|
-
<a name="l00101"></a><a class="code" href="classPassenger_1_1Thread.html#5bc65d2722d1425e574b3b8a97e60388">00101</a> <span class="keywordtype">void</span> <a class="code" href="classPassenger_1_1Thread.html#5bc65d2722d1425e574b3b8a97e60388" title="Keep interrupting the thread until it&#39;s done, then join it.">interruptAndJoin</a>() {
|
119
|
-
<a name="l00102"></a>00102 <span class="keywordtype">bool</span> done = <span class="keyword">false</span>;
|
120
|
-
<a name="l00103"></a>00103 <span class="keywordflow">while</span> (!done) {
|
121
|
-
<a name="l00104"></a>00104 <a class="code" href="classPassenger_1_1Thread.html#2212f1aee683798318ec2bcd57550407" title="Interrupt the thread.">interrupt</a>();
|
122
|
-
<a name="l00105"></a>00105 done = timed_join(posix_time::millisec(10));
|
123
|
-
<a name="l00106"></a>00106 }
|
124
|
-
<a name="l00107"></a>00107 }
|
125
|
-
<a name="l00108"></a>00108 };
|
126
|
-
<a name="l00109"></a>00109 <span class="comment"></span>
|
127
|
-
<a name="l00110"></a>00110 <span class="comment"> /**</span>
|
128
|
-
<a name="l00111"></a>00111 <span class="comment"> * System call and C library call wrappers with interruption support.</span>
|
129
|
-
<a name="l00112"></a>00112 <span class="comment"> * These functions are interruption points, i.e. they throw boost::thread_interrupted</span>
|
130
|
-
<a name="l00113"></a>00113 <span class="comment"> * whenever the calling thread is interrupted by Thread::interrupt() or</span>
|
131
|
-
<a name="l00114"></a>00114 <span class="comment"> * Thread::interruptAndJoin().</span>
|
132
|
-
<a name="l00115"></a>00115 <span class="comment"> */</span>
|
133
|
-
<a name="l00116"></a><a class="code" href="namespacePassenger_1_1InterruptableCalls.html">00116</a> <span class="keyword">namespace </span>InterruptableCalls {
|
134
|
-
<a name="l00117"></a>00117 ssize_t read(<span class="keywordtype">int</span> fd, <span class="keywordtype">void</span> *buf, <span class="keywordtype">size_t</span> count);
|
135
|
-
<a name="l00118"></a>00118 ssize_t write(<span class="keywordtype">int</span> fd, <span class="keyword">const</span> <span class="keywordtype">void</span> *buf, <span class="keywordtype">size_t</span> count);
|
136
|
-
<a name="l00119"></a>00119 <span class="keywordtype">int</span> close(<span class="keywordtype">int</span> fd);
|
137
|
-
<a name="l00120"></a>00120
|
138
|
-
<a name="l00121"></a>00121 <span class="keywordtype">int</span> socketpair(<span class="keywordtype">int</span> d, <span class="keywordtype">int</span> type, <span class="keywordtype">int</span> protocol, <span class="keywordtype">int</span> sv[2]);
|
139
|
-
<a name="l00122"></a>00122 ssize_t recvmsg(<span class="keywordtype">int</span> s, <span class="keyword">struct</span> msghdr *msg, <span class="keywordtype">int</span> flags);
|
140
|
-
<a name="l00123"></a>00123 ssize_t sendmsg(<span class="keywordtype">int</span> s, <span class="keyword">const</span> <span class="keyword">struct</span> msghdr *msg, <span class="keywordtype">int</span> flags);
|
141
|
-
<a name="l00124"></a>00124 <span class="keywordtype">int</span> shutdown(<span class="keywordtype">int</span> s, <span class="keywordtype">int</span> how);
|
142
|
-
<a name="l00125"></a>00125
|
143
|
-
<a name="l00126"></a>00126 FILE *fopen(<span class="keyword">const</span> <span class="keywordtype">char</span> *path, <span class="keyword">const</span> <span class="keywordtype">char</span> *mode);
|
144
|
-
<a name="l00127"></a>00127 <span class="keywordtype">int</span> fclose(FILE *fp);
|
145
|
-
<a name="l00128"></a>00128
|
146
|
-
<a name="l00129"></a>00129 time_t time(time_t *t);
|
147
|
-
<a name="l00130"></a>00130 <span class="keywordtype">int</span> usleep(useconds_t usec);
|
148
|
-
<a name="l00131"></a>00131 <span class="keywordtype">int</span> nanosleep(<span class="keyword">const</span> <span class="keyword">struct</span> timespec *req, <span class="keyword">struct</span> timespec *rem);
|
149
|
-
<a name="l00132"></a>00132
|
150
|
-
<a name="l00133"></a>00133 pid_t fork();
|
151
|
-
<a name="l00134"></a>00134 <span class="keywordtype">int</span> kill(pid_t pid, <span class="keywordtype">int</span> sig);
|
152
|
-
<a name="l00135"></a>00135 pid_t waitpid(pid_t pid, <span class="keywordtype">int</span> *status, <span class="keywordtype">int</span> options);
|
153
|
-
<a name="l00136"></a>00136 }
|
154
|
-
<a name="l00137"></a>00137
|
155
|
-
<a name="l00138"></a>00138 } <span class="comment">// namespace Passenger</span>
|
156
|
-
<a name="l00139"></a>00139
|
157
|
-
<a name="l00140"></a>00140 <span class="keyword">namespace </span>boost {
|
158
|
-
<a name="l00141"></a>00141 <span class="keyword">namespace </span>this_thread {
|
159
|
-
<a name="l00142"></a>00142 <span class="comment"></span>
|
160
|
-
<a name="l00143"></a>00143 <span class="comment"> /**</span>
|
161
|
-
<a name="l00144"></a>00144 <span class="comment"> * @intern</span>
|
162
|
-
<a name="l00145"></a>00145 <span class="comment"> */</span>
|
163
|
-
<a name="l00146"></a>00146 <span class="keyword">extern</span> thread_specific_ptr<bool> _syscalls_interruptable;
|
164
|
-
<a name="l00147"></a>00147 <span class="comment"></span>
|
165
|
-
<a name="l00148"></a>00148 <span class="comment"> /**</span>
|
166
|
-
<a name="l00149"></a>00149 <span class="comment"> * Check whether system calls should be interruptable in</span>
|
167
|
-
<a name="l00150"></a>00150 <span class="comment"> * the calling thread.</span>
|
168
|
-
<a name="l00151"></a>00151 <span class="comment"> */</span>
|
169
|
-
<a name="l00152"></a>00152 <span class="keywordtype">bool</span> syscalls_interruptable();
|
170
|
-
<a name="l00153"></a>00153
|
171
|
-
<a name="l00154"></a>00154 <span class="keyword">class </span>restore_syscall_interruption;
|
172
|
-
<a name="l00155"></a>00155 <span class="comment"></span>
|
173
|
-
<a name="l00156"></a>00156 <span class="comment"> /**</span>
|
174
|
-
<a name="l00157"></a>00157 <span class="comment"> * Create this struct on the stack to temporarily enable system</span>
|
175
|
-
<a name="l00158"></a>00158 <span class="comment"> * call interruption, until the object goes out of scope.</span>
|
176
|
-
<a name="l00159"></a>00159 <span class="comment"> */</span>
|
177
|
-
<a name="l00160"></a><a class="code" href="classboost_1_1this__thread_1_1enable__syscall__interruption.html">00160</a> <span class="keyword">class </span><a class="code" href="classboost_1_1this__thread_1_1enable__syscall__interruption.html" title="Create this struct on the stack to temporarily enable system call interruption, until...">enable_syscall_interruption</a> {
|
178
|
-
<a name="l00161"></a>00161 <span class="keyword">private</span>:
|
179
|
-
<a name="l00162"></a>00162 <span class="keywordtype">bool</span> lastValue;
|
180
|
-
<a name="l00163"></a>00163 <span class="keyword">public</span>:
|
181
|
-
<a name="l00164"></a>00164 <a class="code" href="classboost_1_1this__thread_1_1enable__syscall__interruption.html" title="Create this struct on the stack to temporarily enable system call interruption, until...">enable_syscall_interruption</a>() {
|
182
|
-
<a name="l00165"></a>00165 <span class="keywordflow">if</span> (_syscalls_interruptable.get() == NULL) {
|
183
|
-
<a name="l00166"></a>00166 lastValue = <span class="keyword">true</span>;
|
184
|
-
<a name="l00167"></a>00167 _syscalls_interruptable.reset(<span class="keyword">new</span> <span class="keywordtype">bool</span>(<span class="keyword">true</span>));
|
185
|
-
<a name="l00168"></a>00168 } <span class="keywordflow">else</span> {
|
186
|
-
<a name="l00169"></a>00169 lastValue = *_syscalls_interruptable;
|
187
|
-
<a name="l00170"></a>00170 *_syscalls_interruptable = <span class="keyword">true</span>;
|
188
|
-
<a name="l00171"></a>00171 }
|
189
|
-
<a name="l00172"></a>00172 }
|
190
|
-
<a name="l00173"></a>00173
|
191
|
-
<a name="l00174"></a>00174 ~<a class="code" href="classboost_1_1this__thread_1_1enable__syscall__interruption.html" title="Create this struct on the stack to temporarily enable system call interruption, until...">enable_syscall_interruption</a>() {
|
192
|
-
<a name="l00175"></a>00175 *_syscalls_interruptable = lastValue;
|
193
|
-
<a name="l00176"></a>00176 }
|
194
|
-
<a name="l00177"></a>00177 };
|
195
|
-
<a name="l00178"></a>00178 <span class="comment"></span>
|
196
|
-
<a name="l00179"></a>00179 <span class="comment"> /**</span>
|
197
|
-
<a name="l00180"></a>00180 <span class="comment"> * Create this struct on the stack to temporarily disable system</span>
|
198
|
-
<a name="l00181"></a>00181 <span class="comment"> * call interruption, until the object goes out of scope.</span>
|
199
|
-
<a name="l00182"></a>00182 <span class="comment"> * While system call interruption is disabled, the functions in</span>
|
200
|
-
<a name="l00183"></a>00183 <span class="comment"> * InterruptableCalls will try until the return code is not EINTR.</span>
|
201
|
-
<a name="l00184"></a>00184 <span class="comment"> */</span>
|
202
|
-
<a name="l00185"></a><a class="code" href="classboost_1_1this__thread_1_1disable__syscall__interruption.html">00185</a> <span class="keyword">class </span><a class="code" href="classboost_1_1this__thread_1_1disable__syscall__interruption.html" title="Create this struct on the stack to temporarily disable system call interruption,...">disable_syscall_interruption</a> {
|
203
|
-
<a name="l00186"></a>00186 <span class="keyword">private</span>:
|
204
|
-
<a name="l00187"></a>00187 <span class="keyword">friend</span> <span class="keyword">class </span><a class="code" href="classboost_1_1this__thread_1_1restore__syscall__interruption.html" title="Creating an object of this class on the stack will restore the system call interruption...">restore_syscall_interruption</a>;
|
205
|
-
<a name="l00188"></a>00188 <span class="keywordtype">bool</span> lastValue;
|
206
|
-
<a name="l00189"></a>00189 <span class="keyword">public</span>:
|
207
|
-
<a name="l00190"></a>00190 <a class="code" href="classboost_1_1this__thread_1_1disable__syscall__interruption.html" title="Create this struct on the stack to temporarily disable system call interruption,...">disable_syscall_interruption</a>() {
|
208
|
-
<a name="l00191"></a>00191 <span class="keywordflow">if</span> (_syscalls_interruptable.get() == NULL) {
|
209
|
-
<a name="l00192"></a>00192 lastValue = <span class="keyword">true</span>;
|
210
|
-
<a name="l00193"></a>00193 _syscalls_interruptable.reset(<span class="keyword">new</span> <span class="keywordtype">bool</span>(<span class="keyword">false</span>));
|
211
|
-
<a name="l00194"></a>00194 } <span class="keywordflow">else</span> {
|
212
|
-
<a name="l00195"></a>00195 lastValue = *_syscalls_interruptable;
|
213
|
-
<a name="l00196"></a>00196 *_syscalls_interruptable = <span class="keyword">false</span>;
|
214
|
-
<a name="l00197"></a>00197 }
|
215
|
-
<a name="l00198"></a>00198 }
|
216
|
-
<a name="l00199"></a>00199
|
217
|
-
<a name="l00200"></a>00200 ~<a class="code" href="classboost_1_1this__thread_1_1disable__syscall__interruption.html" title="Create this struct on the stack to temporarily disable system call interruption,...">disable_syscall_interruption</a>() {
|
218
|
-
<a name="l00201"></a>00201 *_syscalls_interruptable = lastValue;
|
219
|
-
<a name="l00202"></a>00202 }
|
220
|
-
<a name="l00203"></a>00203 };
|
221
|
-
<a name="l00204"></a>00204 <span class="comment"></span>
|
222
|
-
<a name="l00205"></a>00205 <span class="comment"> /**</span>
|
223
|
-
<a name="l00206"></a>00206 <span class="comment"> * Creating an object of this class on the stack will restore the</span>
|
224
|
-
<a name="l00207"></a>00207 <span class="comment"> * system call interruption state to what it was before.</span>
|
225
|
-
<a name="l00208"></a>00208 <span class="comment"> */</span>
|
226
|
-
<a name="l00209"></a><a class="code" href="classboost_1_1this__thread_1_1restore__syscall__interruption.html">00209</a> <span class="keyword">class </span><a class="code" href="classboost_1_1this__thread_1_1restore__syscall__interruption.html" title="Creating an object of this class on the stack will restore the system call interruption...">restore_syscall_interruption</a> {
|
227
|
-
<a name="l00210"></a>00210 <span class="keyword">private</span>:
|
228
|
-
<a name="l00211"></a>00211 <span class="keywordtype">int</span> lastValue;
|
229
|
-
<a name="l00212"></a>00212 <span class="keyword">public</span>:
|
230
|
-
<a name="l00213"></a>00213 <a class="code" href="classboost_1_1this__thread_1_1restore__syscall__interruption.html" title="Creating an object of this class on the stack will restore the system call interruption...">restore_syscall_interruption</a>(<span class="keyword">const</span> <a class="code" href="classboost_1_1this__thread_1_1disable__syscall__interruption.html" title="Create this struct on the stack to temporarily disable system call interruption,...">disable_syscall_interruption</a> &intr) {
|
231
|
-
<a name="l00214"></a>00214 assert(_syscalls_interruptable.get() != NULL);
|
232
|
-
<a name="l00215"></a>00215 lastValue = *_syscalls_interruptable;
|
233
|
-
<a name="l00216"></a>00216 *_syscalls_interruptable = intr.<a class="code" href="classboost_1_1this__thread_1_1disable__syscall__interruption.html#5bc5102c673ea10cc22b93b2eb365a5d">lastValue</a>;
|
234
|
-
<a name="l00217"></a>00217 }
|
235
|
-
<a name="l00218"></a>00218
|
236
|
-
<a name="l00219"></a>00219 ~<a class="code" href="classboost_1_1this__thread_1_1restore__syscall__interruption.html" title="Creating an object of this class on the stack will restore the system call interruption...">restore_syscall_interruption</a>() {
|
237
|
-
<a name="l00220"></a>00220 *_syscalls_interruptable = lastValue;
|
238
|
-
<a name="l00221"></a>00221 }
|
239
|
-
<a name="l00222"></a>00222 };
|
240
|
-
<a name="l00223"></a>00223
|
241
|
-
<a name="l00224"></a>00224 } <span class="comment">// namespace this_thread</span>
|
242
|
-
<a name="l00225"></a>00225 } <span class="comment">// namespace boost</span>
|
243
|
-
<a name="l00226"></a>00226
|
244
|
-
<a name="l00227"></a>00227 <span class="preprocessor">#endif </span><span class="comment">/* _PASSENGER_SYSTEM_H_ */</span>
|
245
|
-
<a name="l00228"></a>00228
|
246
|
-
</pre></div></div>
|
247
|
-
<hr size="1"><address style="text-align: right;"><small>Generated on Tue Jun 24 14:03:42 2008 for Passenger by
|
248
|
-
<a href="http://www.doxygen.org/index.html">
|
249
|
-
<img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5.5 </small></address>
|
250
|
-
</body>
|
251
|
-
</html>
|
@@ -1,283 +0,0 @@
|
|
1
|
-
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
2
|
-
<html><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
|
3
|
-
<title>Passenger: Utils.h Source File</title>
|
4
|
-
<link href="doxygen.css" rel="stylesheet" type="text/css">
|
5
|
-
<link href="tabs.css" rel="stylesheet" type="text/css">
|
6
|
-
</head><body>
|
7
|
-
<!-- Generated by Doxygen 1.5.5 -->
|
8
|
-
<div class="navigation" id="top">
|
9
|
-
<div class="tabs">
|
10
|
-
<ul>
|
11
|
-
<li><a href="main.html"><span>Main Page</span></a></li>
|
12
|
-
<li><a href="modules.html"><span>Modules</span></a></li>
|
13
|
-
<li><a href="namespaces.html"><span>Namespaces</span></a></li>
|
14
|
-
<li><a href="annotated.html"><span>Classes</span></a></li>
|
15
|
-
<li class="current"><a href="files.html"><span>Files</span></a></li>
|
16
|
-
</ul>
|
17
|
-
</div>
|
18
|
-
<h1>Utils.h</h1><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">/*</span>
|
19
|
-
<a name="l00002"></a>00002 <span class="comment"> * Phusion Passenger - http://www.modrails.com/</span>
|
20
|
-
<a name="l00003"></a>00003 <span class="comment"> * Copyright (C) 2008 Phusion</span>
|
21
|
-
<a name="l00004"></a>00004 <span class="comment"> *</span>
|
22
|
-
<a name="l00005"></a>00005 <span class="comment"> * Phusion Passenger is a trademark of Hongli Lai & Ninh Bui.</span>
|
23
|
-
<a name="l00006"></a>00006 <span class="comment"> *</span>
|
24
|
-
<a name="l00007"></a>00007 <span class="comment"> * This program is free software; you can redistribute it and/or modify</span>
|
25
|
-
<a name="l00008"></a>00008 <span class="comment"> * it under the terms of the GNU General Public License as published by</span>
|
26
|
-
<a name="l00009"></a>00009 <span class="comment"> * the Free Software Foundation; version 2 of the License.</span>
|
27
|
-
<a name="l00010"></a>00010 <span class="comment"> *</span>
|
28
|
-
<a name="l00011"></a>00011 <span class="comment"> * This program is distributed in the hope that it will be useful,</span>
|
29
|
-
<a name="l00012"></a>00012 <span class="comment"> * but WITHOUT ANY WARRANTY; without even the implied warranty of</span>
|
30
|
-
<a name="l00013"></a>00013 <span class="comment"> * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the</span>
|
31
|
-
<a name="l00014"></a>00014 <span class="comment"> * GNU General Public License for more details.</span>
|
32
|
-
<a name="l00015"></a>00015 <span class="comment"> *</span>
|
33
|
-
<a name="l00016"></a>00016 <span class="comment"> * You should have received a copy of the GNU General Public License along</span>
|
34
|
-
<a name="l00017"></a>00017 <span class="comment"> * with this program; if not, write to the Free Software Foundation, Inc.,</span>
|
35
|
-
<a name="l00018"></a>00018 <span class="comment"> * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.</span>
|
36
|
-
<a name="l00019"></a>00019 <span class="comment"> */</span>
|
37
|
-
<a name="l00020"></a>00020 <span class="preprocessor">#ifndef _PASSENGER_UTILS_H_</span>
|
38
|
-
<a name="l00021"></a>00021 <span class="preprocessor"></span><span class="preprocessor">#define _PASSENGER_UTILS_H_</span>
|
39
|
-
<a name="l00022"></a>00022 <span class="preprocessor"></span>
|
40
|
-
<a name="l00023"></a>00023 <span class="preprocessor">#include <boost/shared_ptr.hpp></span>
|
41
|
-
<a name="l00024"></a>00024 <span class="preprocessor">#include <sys/types.h></span>
|
42
|
-
<a name="l00025"></a>00025 <span class="preprocessor">#include <sys/stat.h></span>
|
43
|
-
<a name="l00026"></a>00026 <span class="preprocessor">#include <string></span>
|
44
|
-
<a name="l00027"></a>00027 <span class="preprocessor">#include <vector></span>
|
45
|
-
<a name="l00028"></a>00028 <span class="preprocessor">#include <utility></span>
|
46
|
-
<a name="l00029"></a>00029 <span class="preprocessor">#include <sstream></span>
|
47
|
-
<a name="l00030"></a>00030 <span class="preprocessor">#include <cstdio></span>
|
48
|
-
<a name="l00031"></a>00031 <span class="preprocessor">#include <climits></span>
|
49
|
-
<a name="l00032"></a>00032 <span class="preprocessor">#include <cstdlib></span>
|
50
|
-
<a name="l00033"></a>00033 <span class="preprocessor">#include <cstring></span>
|
51
|
-
<a name="l00034"></a>00034 <span class="preprocessor">#include <errno.h></span>
|
52
|
-
<a name="l00035"></a>00035 <span class="preprocessor">#include "Exceptions.h"</span>
|
53
|
-
<a name="l00036"></a>00036
|
54
|
-
<a name="l00037"></a>00037 <span class="keyword">namespace </span>Passenger {
|
55
|
-
<a name="l00038"></a>00038
|
56
|
-
<a name="l00039"></a>00039 <span class="keyword">using namespace </span>std;
|
57
|
-
<a name="l00040"></a>00040 <span class="keyword">using namespace </span>boost;
|
58
|
-
<a name="l00041"></a>00041 <span class="comment"></span>
|
59
|
-
<a name="l00042"></a>00042 <span class="comment">/**</span>
|
60
|
-
<a name="l00043"></a>00043 <span class="comment"> * Convenience shortcut for creating a <tt>shared_ptr</tt>.</span>
|
61
|
-
<a name="l00044"></a>00044 <span class="comment"> * Instead of:</span>
|
62
|
-
<a name="l00045"></a>00045 <span class="comment"> * @code</span>
|
63
|
-
<a name="l00046"></a>00046 <span class="comment"> * shared_ptr<Foo> foo;</span>
|
64
|
-
<a name="l00047"></a>00047 <span class="comment"> * ...</span>
|
65
|
-
<a name="l00048"></a>00048 <span class="comment"> * foo = shared_ptr<Foo>(new Foo());</span>
|
66
|
-
<a name="l00049"></a>00049 <span class="comment"> * @endcode</span>
|
67
|
-
<a name="l00050"></a>00050 <span class="comment"> * one can write:</span>
|
68
|
-
<a name="l00051"></a>00051 <span class="comment"> * @code</span>
|
69
|
-
<a name="l00052"></a>00052 <span class="comment"> * shared_ptr<Foo> foo;</span>
|
70
|
-
<a name="l00053"></a>00053 <span class="comment"> * ...</span>
|
71
|
-
<a name="l00054"></a>00054 <span class="comment"> * foo = ptr(new Foo());</span>
|
72
|
-
<a name="l00055"></a>00055 <span class="comment"> * @endcode</span>
|
73
|
-
<a name="l00056"></a>00056 <span class="comment"> *</span>
|
74
|
-
<a name="l00057"></a>00057 <span class="comment"> * @param pointer The item to put in the shared_ptr object.</span>
|
75
|
-
<a name="l00058"></a>00058 <span class="comment"> * @ingroup Support</span>
|
76
|
-
<a name="l00059"></a>00059 <span class="comment"> */</span>
|
77
|
-
<a name="l00060"></a>00060 <span class="keyword">template</span><<span class="keyword">typename</span> T> shared_ptr<T>
|
78
|
-
<a name="l00061"></a><a class="code" href="group__Support.html#g41b6c4a82fed72531a147de0505a8396">00061</a> <a class="code" href="group__Support.html#g41b6c4a82fed72531a147de0505a8396" title="Convenience shortcut for creating a shared_ptr.">ptr</a>(T *pointer) {
|
79
|
-
<a name="l00062"></a>00062 <span class="keywordflow">return</span> shared_ptr<T>(pointer);
|
80
|
-
<a name="l00063"></a>00063 }
|
81
|
-
<a name="l00064"></a>00064 <span class="comment"></span>
|
82
|
-
<a name="l00065"></a>00065 <span class="comment">/**</span>
|
83
|
-
<a name="l00066"></a>00066 <span class="comment"> * Used internally by toString(). Do not use directly.</span>
|
84
|
-
<a name="l00067"></a>00067 <span class="comment"> *</span>
|
85
|
-
<a name="l00068"></a>00068 <span class="comment"> * @internal</span>
|
86
|
-
<a name="l00069"></a>00069 <span class="comment"> */</span>
|
87
|
-
<a name="l00070"></a>00070 <span class="keyword">template</span><<span class="keyword">typename</span> T>
|
88
|
-
<a name="l00071"></a><a class="code" href="structPassenger_1_1AnythingToString.html">00071</a> <span class="keyword">struct </span><a class="code" href="structPassenger_1_1AnythingToString.html" title="Used internally by toString().">AnythingToString</a> {
|
89
|
-
<a name="l00072"></a>00072 <span class="keywordtype">string</span> operator()(T something) {
|
90
|
-
<a name="l00073"></a>00073 stringstream s;
|
91
|
-
<a name="l00074"></a>00074 s << something;
|
92
|
-
<a name="l00075"></a>00075 <span class="keywordflow">return</span> s.str();
|
93
|
-
<a name="l00076"></a>00076 }
|
94
|
-
<a name="l00077"></a>00077 };
|
95
|
-
<a name="l00078"></a>00078 <span class="comment"></span>
|
96
|
-
<a name="l00079"></a>00079 <span class="comment">/**</span>
|
97
|
-
<a name="l00080"></a>00080 <span class="comment"> * Used internally by toString(). Do not use directly.</span>
|
98
|
-
<a name="l00081"></a>00081 <span class="comment"> *</span>
|
99
|
-
<a name="l00082"></a>00082 <span class="comment"> * @internal</span>
|
100
|
-
<a name="l00083"></a>00083 <span class="comment"> */</span>
|
101
|
-
<a name="l00084"></a>00084 <span class="keyword">template</span><>
|
102
|
-
<a name="l00085"></a><a class="code" href="structPassenger_1_1AnythingToString_3_01vector_3_01string_01_4_01_4.html">00085</a> <span class="keyword">struct </span><a class="code" href="structPassenger_1_1AnythingToString.html" title="Used internally by toString().">AnythingToString</a>< vector<string> > {
|
103
|
-
<a name="l00086"></a>00086 <span class="keywordtype">string</span> operator()(<span class="keyword">const</span> vector<string> &v) {
|
104
|
-
<a name="l00087"></a>00087 <span class="keywordtype">string</span> result(<span class="stringliteral">"["</span>);
|
105
|
-
<a name="l00088"></a>00088 vector<string>::const_iterator it;
|
106
|
-
<a name="l00089"></a>00089 <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> i;
|
107
|
-
<a name="l00090"></a>00090 <span class="keywordflow">for</span> (it = v.begin(), i = 0; it != v.end(); it++, i++) {
|
108
|
-
<a name="l00091"></a>00091 result.append(<span class="stringliteral">"'"</span>);
|
109
|
-
<a name="l00092"></a>00092 result.append(*it);
|
110
|
-
<a name="l00093"></a>00093 <span class="keywordflow">if</span> (i == v.size() - 1) {
|
111
|
-
<a name="l00094"></a>00094 result.append(<span class="stringliteral">"'"</span>);
|
112
|
-
<a name="l00095"></a>00095 } <span class="keywordflow">else</span> {
|
113
|
-
<a name="l00096"></a>00096 result.append(<span class="stringliteral">"', "</span>);
|
114
|
-
<a name="l00097"></a>00097 }
|
115
|
-
<a name="l00098"></a>00098 }
|
116
|
-
<a name="l00099"></a>00099 result.append(<span class="stringliteral">"]"</span>);
|
117
|
-
<a name="l00100"></a>00100 <span class="keywordflow">return</span> result;
|
118
|
-
<a name="l00101"></a>00101 }
|
119
|
-
<a name="l00102"></a>00102 };
|
120
|
-
<a name="l00103"></a>00103 <span class="comment"></span>
|
121
|
-
<a name="l00104"></a>00104 <span class="comment">/**</span>
|
122
|
-
<a name="l00105"></a>00105 <span class="comment"> * Convert anything to a string.</span>
|
123
|
-
<a name="l00106"></a>00106 <span class="comment"> *</span>
|
124
|
-
<a name="l00107"></a>00107 <span class="comment"> * @param something The thing to convert.</span>
|
125
|
-
<a name="l00108"></a>00108 <span class="comment"> * @ingroup Support</span>
|
126
|
-
<a name="l00109"></a>00109 <span class="comment"> */</span>
|
127
|
-
<a name="l00110"></a>00110 <span class="keyword">template</span><<span class="keyword">typename</span> T> <span class="keywordtype">string</span>
|
128
|
-
<a name="l00111"></a><a class="code" href="group__Support.html#gf6fab368d70c18fdf16bf5a24f630407">00111</a> <a class="code" href="group__Support.html#gf6fab368d70c18fdf16bf5a24f630407" title="Convert anything to a string.">toString</a>(T something) {
|
129
|
-
<a name="l00112"></a>00112 <span class="keywordflow">return</span> <a class="code" href="structPassenger_1_1AnythingToString.html" title="Used internally by toString().">AnythingToString<T></a>()(something);
|
130
|
-
<a name="l00113"></a>00113 }
|
131
|
-
<a name="l00114"></a>00114 <span class="comment"></span>
|
132
|
-
<a name="l00115"></a>00115 <span class="comment">/**</span>
|
133
|
-
<a name="l00116"></a>00116 <span class="comment"> * Converts the given string to an integer.</span>
|
134
|
-
<a name="l00117"></a>00117 <span class="comment"> * @ingroup Support</span>
|
135
|
-
<a name="l00118"></a>00118 <span class="comment"> */</span>
|
136
|
-
<a name="l00119"></a>00119 <span class="keywordtype">int</span> <a class="code" href="group__Support.html#g73b17b509ee44938a56bf16cbf82fb48" title="Converts the given string to an integer.">atoi</a>(<span class="keyword">const</span> <span class="keywordtype">string</span> &s);
|
137
|
-
<a name="l00120"></a>00120 <span class="comment"></span>
|
138
|
-
<a name="l00121"></a>00121 <span class="comment">/**</span>
|
139
|
-
<a name="l00122"></a>00122 <span class="comment"> * Split the given string using the given separator.</span>
|
140
|
-
<a name="l00123"></a>00123 <span class="comment"> *</span>
|
141
|
-
<a name="l00124"></a>00124 <span class="comment"> * @param str The string to split.</span>
|
142
|
-
<a name="l00125"></a>00125 <span class="comment"> * @param sep The separator to use.</span>
|
143
|
-
<a name="l00126"></a>00126 <span class="comment"> * @param output The vector to write the output to.</span>
|
144
|
-
<a name="l00127"></a>00127 <span class="comment"> * @ingroup Support</span>
|
145
|
-
<a name="l00128"></a>00128 <span class="comment"> */</span>
|
146
|
-
<a name="l00129"></a>00129 <span class="keywordtype">void</span> <a class="code" href="group__Support.html#g4b8320aedc6a164a535c920234e3d8bf" title="Split the given string using the given separator.">split</a>(<span class="keyword">const</span> <span class="keywordtype">string</span> &str, <span class="keywordtype">char</span> sep, vector<string> &output);
|
147
|
-
<a name="l00130"></a>00130 <span class="comment"></span>
|
148
|
-
<a name="l00131"></a>00131 <span class="comment">/**</span>
|
149
|
-
<a name="l00132"></a>00132 <span class="comment"> * Check whether the specified file exists.</span>
|
150
|
-
<a name="l00133"></a>00133 <span class="comment"> *</span>
|
151
|
-
<a name="l00134"></a>00134 <span class="comment"> * @param filename The filename to check.</span>
|
152
|
-
<a name="l00135"></a>00135 <span class="comment"> * @return Whether the file exists.</span>
|
153
|
-
<a name="l00136"></a>00136 <span class="comment"> * @throws FileSystemException Unable to check because of a filesystem error.</span>
|
154
|
-
<a name="l00137"></a>00137 <span class="comment"> * @ingroup Support</span>
|
155
|
-
<a name="l00138"></a>00138 <span class="comment"> */</span>
|
156
|
-
<a name="l00139"></a>00139 <span class="keywordtype">bool</span> <a class="code" href="group__Support.html#g56199e2a907b6791017eee7e0625e449" title="Check whether the specified file exists.">fileExists</a>(<span class="keyword">const</span> <span class="keywordtype">char</span> *filename);
|
157
|
-
<a name="l00140"></a>00140 <span class="comment"></span>
|
158
|
-
<a name="l00141"></a>00141 <span class="comment">/**</span>
|
159
|
-
<a name="l00142"></a>00142 <span class="comment"> * Find the location of the Passenger spawn server script.</span>
|
160
|
-
<a name="l00143"></a>00143 <span class="comment"> * If passengerRoot is given, t T</span>
|
161
|
-
<a name="l00144"></a>00144 <span class="comment"> *</span>
|
162
|
-
<a name="l00145"></a>00145 <span class="comment"> * @param passengerRoot The Passenger root folder. If NULL is given, then</span>
|
163
|
-
<a name="l00146"></a>00146 <span class="comment"> * the spawn server is found by scanning $PATH. For security reasons,</span>
|
164
|
-
<a name="l00147"></a>00147 <span class="comment"> * only absolute paths are scanned.</span>
|
165
|
-
<a name="l00148"></a>00148 <span class="comment"> * @return An absolute path to the spawn server script, or</span>
|
166
|
-
<a name="l00149"></a>00149 <span class="comment"> * an empty string on error.</span>
|
167
|
-
<a name="l00150"></a>00150 <span class="comment"> * @throws FileSystemException Unable to access parts of the filesystem.</span>
|
168
|
-
<a name="l00151"></a>00151 <span class="comment"> * @ingroup Support</span>
|
169
|
-
<a name="l00152"></a>00152 <span class="comment"> */</span>
|
170
|
-
<a name="l00153"></a>00153 <span class="keywordtype">string</span> <a class="code" href="group__Support.html#g37e1a293fa574748b2393b4801e7b23f" title="Find the location of the Passenger spawn server script.">findSpawnServer</a>(<span class="keyword">const</span> <span class="keywordtype">char</span> *passengerRoot = NULL);
|
171
|
-
<a name="l00154"></a>00154 <span class="comment"></span>
|
172
|
-
<a name="l00155"></a>00155 <span class="comment">/**</span>
|
173
|
-
<a name="l00156"></a>00156 <span class="comment"> * Find the location of the Passenger ApplicationPool server</span>
|
174
|
-
<a name="l00157"></a>00157 <span class="comment"> * executable.</span>
|
175
|
-
<a name="l00158"></a>00158 <span class="comment"> *</span>
|
176
|
-
<a name="l00159"></a>00159 <span class="comment"> * @param passengerRoot The Passenger root folder.</span>
|
177
|
-
<a name="l00160"></a>00160 <span class="comment"> * @return An absolute path to the executable.</span>
|
178
|
-
<a name="l00161"></a>00161 <span class="comment"> * @throws FileSystemException Unable to access parts of the filesystem.</span>
|
179
|
-
<a name="l00162"></a>00162 <span class="comment"> * @pre passengerRoot != NULL</span>
|
180
|
-
<a name="l00163"></a>00163 <span class="comment"> * @ingroup Support</span>
|
181
|
-
<a name="l00164"></a>00164 <span class="comment"> */</span>
|
182
|
-
<a name="l00165"></a>00165 <span class="keywordtype">string</span> <a class="code" href="group__Support.html#g67c03fa133dbb5a4e0de78f51899568e" title="Find the location of the Passenger ApplicationPool server executable.">findApplicationPoolServer</a>(<span class="keyword">const</span> <span class="keywordtype">char</span> *passengerRoot);
|
183
|
-
<a name="l00166"></a>00166 <span class="comment"></span>
|
184
|
-
<a name="l00167"></a>00167 <span class="comment">/**</span>
|
185
|
-
<a name="l00168"></a>00168 <span class="comment"> * Returns a canonical version of the specified path. All symbolic links</span>
|
186
|
-
<a name="l00169"></a>00169 <span class="comment"> * and relative path elements are resolved.</span>
|
187
|
-
<a name="l00170"></a>00170 <span class="comment"> * Returns an empty string if something went wrong.</span>
|
188
|
-
<a name="l00171"></a>00171 <span class="comment"> *</span>
|
189
|
-
<a name="l00172"></a>00172 <span class="comment"> * @ingroup Support</span>
|
190
|
-
<a name="l00173"></a>00173 <span class="comment"> */</span>
|
191
|
-
<a name="l00174"></a>00174 <span class="keywordtype">string</span> <a class="code" href="group__Support.html#gf3b0a483f0a252ae08d9de9f8b267d36" title="Returns a canonical version of the specified path.">canonicalizePath</a>(<span class="keyword">const</span> <span class="keywordtype">string</span> &path);
|
192
|
-
<a name="l00175"></a>00175 <span class="comment"></span>
|
193
|
-
<a name="l00176"></a>00176 <span class="comment">/**</span>
|
194
|
-
<a name="l00177"></a>00177 <span class="comment"> * Check whether the specified directory is a valid Ruby on Rails</span>
|
195
|
-
<a name="l00178"></a>00178 <span class="comment"> * 'public' directory.</span>
|
196
|
-
<a name="l00179"></a>00179 <span class="comment"> *</span>
|
197
|
-
<a name="l00180"></a>00180 <span class="comment"> * @throws FileSystemException Unable to check because of a system error.</span>
|
198
|
-
<a name="l00181"></a>00181 <span class="comment"> * @ingroup Support</span>
|
199
|
-
<a name="l00182"></a>00182 <span class="comment"> */</span>
|
200
|
-
<a name="l00183"></a>00183 <span class="keywordtype">bool</span> <a class="code" href="group__Support.html#g7eac0b3097091d39e348e0c2563630b8" title="Check whether the specified directory is a valid Ruby on Rails &#39;public&#39; directory...">verifyRailsDir</a>(<span class="keyword">const</span> <span class="keywordtype">string</span> &dir);
|
201
|
-
<a name="l00184"></a>00184 <span class="comment"></span>
|
202
|
-
<a name="l00185"></a>00185 <span class="comment">/**</span>
|
203
|
-
<a name="l00186"></a>00186 <span class="comment"> * Check whether the specified directory is a valid Rack 'public'</span>
|
204
|
-
<a name="l00187"></a>00187 <span class="comment"> * directory.</span>
|
205
|
-
<a name="l00188"></a>00188 <span class="comment"> *</span>
|
206
|
-
<a name="l00189"></a>00189 <span class="comment"> * @throws FileSystemException Unable to check because of a filesystem error.</span>
|
207
|
-
<a name="l00190"></a>00190 <span class="comment"> * @ingroup Support</span>
|
208
|
-
<a name="l00191"></a>00191 <span class="comment"> */</span>
|
209
|
-
<a name="l00192"></a>00192 <span class="keywordtype">bool</span> <a class="code" href="group__Support.html#g6c3cf8f963ffa2885081df2da152dfda" title="Check whether the specified directory is a valid Rack &#39;public&#39; directory...">verifyRackDir</a>(<span class="keyword">const</span> <span class="keywordtype">string</span> &dir);
|
210
|
-
<a name="l00193"></a>00193 <span class="comment"></span>
|
211
|
-
<a name="l00194"></a>00194 <span class="comment">/**</span>
|
212
|
-
<a name="l00195"></a>00195 <span class="comment"> * Check whether the specified directory is a valid WSGI 'public'</span>
|
213
|
-
<a name="l00196"></a>00196 <span class="comment"> * directory.</span>
|
214
|
-
<a name="l00197"></a>00197 <span class="comment"> *</span>
|
215
|
-
<a name="l00198"></a>00198 <span class="comment"> * @throws FileSystemException Unable to check because of a filesystem error.</span>
|
216
|
-
<a name="l00199"></a>00199 <span class="comment"> * @ingroup Support</span>
|
217
|
-
<a name="l00200"></a>00200 <span class="comment"> */</span>
|
218
|
-
<a name="l00201"></a>00201 <span class="keywordtype">bool</span> <a class="code" href="group__Support.html#g1d5027f3758e2e5893667f5d66443d9d" title="Check whether the specified directory is a valid WSGI &#39;public&#39; directory...">verifyWSGIDir</a>(<span class="keyword">const</span> <span class="keywordtype">string</span> &dir);
|
219
|
-
<a name="l00202"></a>00202 <span class="comment"></span>
|
220
|
-
<a name="l00203"></a>00203 <span class="comment">/**</span>
|
221
|
-
<a name="l00204"></a>00204 <span class="comment"> * Represents a temporary file. The associated file is automatically</span>
|
222
|
-
<a name="l00205"></a>00205 <span class="comment"> * deleted upon object destruction.</span>
|
223
|
-
<a name="l00206"></a>00206 <span class="comment"> *</span>
|
224
|
-
<a name="l00207"></a>00207 <span class="comment"> * @ingroup Support</span>
|
225
|
-
<a name="l00208"></a>00208 <span class="comment"> */</span>
|
226
|
-
<a name="l00209"></a><a class="code" href="classPassenger_1_1TempFile.html">00209</a> <span class="keyword">class </span><a class="code" href="classPassenger_1_1TempFile.html" title="Represents a temporary file.">TempFile</a> {
|
227
|
-
<a name="l00210"></a>00210 <span class="keyword">public</span>:<span class="comment"></span>
|
228
|
-
<a name="l00211"></a>00211 <span class="comment"> /** The filename. If this temp file is anonymous, then the filename is an empty string. */</span>
|
229
|
-
<a name="l00212"></a><a class="code" href="classPassenger_1_1TempFile.html#5e3ad620abbd79a289e44057e241de6b">00212</a> <span class="keywordtype">string</span> <a class="code" href="classPassenger_1_1TempFile.html#5e3ad620abbd79a289e44057e241de6b" title="The filename.">filename</a>;<span class="comment"></span>
|
230
|
-
<a name="l00213"></a>00213 <span class="comment"> /** The file handle. */</span>
|
231
|
-
<a name="l00214"></a><a class="code" href="classPassenger_1_1TempFile.html#e78d0a63165ed1e5a083c1947db2ea14">00214</a> FILE *<a class="code" href="classPassenger_1_1TempFile.html#e78d0a63165ed1e5a083c1947db2ea14" title="The file handle.">handle</a>;
|
232
|
-
<a name="l00215"></a>00215 <span class="comment"></span>
|
233
|
-
<a name="l00216"></a>00216 <span class="comment"> /**</span>
|
234
|
-
<a name="l00217"></a>00217 <span class="comment"> * Create an empty, temporary file, and open it for reading and writing.</span>
|
235
|
-
<a name="l00218"></a>00218 <span class="comment"> *</span>
|
236
|
-
<a name="l00219"></a>00219 <span class="comment"> * @param anonymous Set to true if this temp file should be unlinked</span>
|
237
|
-
<a name="l00220"></a>00220 <span class="comment"> * immediately. Anonymous temp files are useful if one just wants</span>
|
238
|
-
<a name="l00221"></a>00221 <span class="comment"> * a big not-in-memory buffer to work with.</span>
|
239
|
-
<a name="l00222"></a>00222 <span class="comment"> * @throws SystemException Something went wrong.</span>
|
240
|
-
<a name="l00223"></a>00223 <span class="comment"> */</span>
|
241
|
-
<a name="l00224"></a><a class="code" href="classPassenger_1_1TempFile.html#bbcc818b88393bee71bf0bd8f66c3bd5">00224</a> <a class="code" href="classPassenger_1_1TempFile.html#bbcc818b88393bee71bf0bd8f66c3bd5" title="Create an empty, temporary file, and open it for reading and writing.">TempFile</a>(<span class="keywordtype">bool</span> anonymous = <span class="keyword">true</span>) {
|
242
|
-
<a name="l00225"></a>00225 <span class="keywordtype">char</span> *temp_dir;
|
243
|
-
<a name="l00226"></a>00226 <span class="keywordtype">char</span> templ[PATH_MAX];
|
244
|
-
<a name="l00227"></a>00227 <span class="keywordtype">int</span> fd;
|
245
|
-
<a name="l00228"></a>00228
|
246
|
-
<a name="l00229"></a>00229 temp_dir = getenv(<span class="stringliteral">"TMP"</span>);
|
247
|
-
<a name="l00230"></a>00230 <span class="keywordflow">if</span> (temp_dir == NULL || *temp_dir == <span class="charliteral">'\0'</span>) {
|
248
|
-
<a name="l00231"></a>00231 temp_dir = <span class="stringliteral">"/tmp"</span>;
|
249
|
-
<a name="l00232"></a>00232 }
|
250
|
-
<a name="l00233"></a>00233
|
251
|
-
<a name="l00234"></a>00234 snprintf(templ, <span class="keyword">sizeof</span>(templ), <span class="stringliteral">"%s/passenger.XXXXXX"</span>, temp_dir);
|
252
|
-
<a name="l00235"></a>00235 templ[<span class="keyword">sizeof</span>(templ) - 1] = <span class="charliteral">'\0'</span>;
|
253
|
-
<a name="l00236"></a>00236 fd = mkstemp(templ);
|
254
|
-
<a name="l00237"></a>00237 <span class="keywordflow">if</span> (fd == -1) {
|
255
|
-
<a name="l00238"></a>00238 <span class="keywordflow">throw</span> <a class="code" href="classPassenger_1_1SystemException.html" title="Represents an error returned by a system call or a standard library call.">SystemException</a>(<span class="stringliteral">"Cannot create a temporary file"</span>, errno);
|
256
|
-
<a name="l00239"></a>00239 }
|
257
|
-
<a name="l00240"></a>00240 <span class="keywordflow">if</span> (anonymous) {
|
258
|
-
<a name="l00241"></a>00241 fchmod(fd, 0000);
|
259
|
-
<a name="l00242"></a>00242 unlink(templ);
|
260
|
-
<a name="l00243"></a>00243 } <span class="keywordflow">else</span> {
|
261
|
-
<a name="l00244"></a>00244 <a class="code" href="classPassenger_1_1TempFile.html#5e3ad620abbd79a289e44057e241de6b" title="The filename.">filename</a>.assign(templ);
|
262
|
-
<a name="l00245"></a>00245 }
|
263
|
-
<a name="l00246"></a>00246 <a class="code" href="classPassenger_1_1TempFile.html#e78d0a63165ed1e5a083c1947db2ea14" title="The file handle.">handle</a> = fdopen(fd, <span class="stringliteral">"w+"</span>);
|
264
|
-
<a name="l00247"></a>00247 }
|
265
|
-
<a name="l00248"></a>00248
|
266
|
-
<a name="l00249"></a>00249 ~<a class="code" href="classPassenger_1_1TempFile.html" title="Represents a temporary file.">TempFile</a>() {
|
267
|
-
<a name="l00250"></a>00250 fclose(<a class="code" href="classPassenger_1_1TempFile.html#e78d0a63165ed1e5a083c1947db2ea14" title="The file handle.">handle</a>);
|
268
|
-
<a name="l00251"></a>00251 <span class="keywordflow">if</span> (!<a class="code" href="classPassenger_1_1TempFile.html#5e3ad620abbd79a289e44057e241de6b" title="The filename.">filename</a>.empty()) {
|
269
|
-
<a name="l00252"></a>00252 unlink(<a class="code" href="classPassenger_1_1TempFile.html#5e3ad620abbd79a289e44057e241de6b" title="The filename.">filename</a>.c_str());
|
270
|
-
<a name="l00253"></a>00253 }
|
271
|
-
<a name="l00254"></a>00254 }
|
272
|
-
<a name="l00255"></a>00255 };
|
273
|
-
<a name="l00256"></a>00256
|
274
|
-
<a name="l00257"></a>00257 } <span class="comment">// namespace Passenger</span>
|
275
|
-
<a name="l00258"></a>00258
|
276
|
-
<a name="l00259"></a>00259 <span class="preprocessor">#endif </span><span class="comment">/* _PASSENGER_UTILS_H_ */</span>
|
277
|
-
<a name="l00260"></a>00260
|
278
|
-
</pre></div></div>
|
279
|
-
<hr size="1"><address style="text-align: right;"><small>Generated on Tue Jun 24 14:03:42 2008 for Passenger by
|
280
|
-
<a href="http://www.doxygen.org/index.html">
|
281
|
-
<img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5.5 </small></address>
|
282
|
-
</body>
|
283
|
-
</html>
|