passenger 1.0.3 → 1.0.4

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.

Files changed (76) hide show
  1. data/Rakefile +1 -1
  2. data/doc/Users guide.html +3 -1
  3. data/doc/Users guide.txt +4 -0
  4. data/doc/cxxapi/ApplicationPoolClientServer_8h-source.html +1 -1
  5. data/doc/cxxapi/ApplicationPool_8h-source.html +1 -1
  6. data/doc/cxxapi/Application_8h-source.html +1 -1
  7. data/doc/cxxapi/Configuration_8h-source.html +2 -2
  8. data/doc/cxxapi/DummySpawnManager_8h-source.html +1 -1
  9. data/doc/cxxapi/Exceptions_8h-source.html +1 -1
  10. data/doc/cxxapi/Hooks_8h-source.html +1 -1
  11. data/doc/cxxapi/Logging_8h-source.html +1 -1
  12. data/doc/cxxapi/MessageChannel_8h-source.html +201 -210
  13. data/doc/cxxapi/SpawnManager_8h-source.html +1 -1
  14. data/doc/cxxapi/StandardApplicationPool_8h-source.html +1 -1
  15. data/doc/cxxapi/Utils_8h-source.html +1 -1
  16. data/doc/cxxapi/annotated.html +1 -1
  17. data/doc/cxxapi/classPassenger_1_1Application-members.html +1 -1
  18. data/doc/cxxapi/classPassenger_1_1Application.html +1 -1
  19. data/doc/cxxapi/classPassenger_1_1ApplicationPool-members.html +1 -1
  20. data/doc/cxxapi/classPassenger_1_1ApplicationPool.html +1 -1
  21. data/doc/cxxapi/classPassenger_1_1ApplicationPoolServer-members.html +1 -1
  22. data/doc/cxxapi/classPassenger_1_1ApplicationPoolServer.html +1 -1
  23. data/doc/cxxapi/classPassenger_1_1Application_1_1Session-members.html +1 -1
  24. data/doc/cxxapi/classPassenger_1_1Application_1_1Session.html +1 -1
  25. data/doc/cxxapi/classPassenger_1_1DummySpawnManager-members.html +1 -1
  26. data/doc/cxxapi/classPassenger_1_1DummySpawnManager.html +1 -1
  27. data/doc/cxxapi/classPassenger_1_1FileNotFoundException-members.html +1 -1
  28. data/doc/cxxapi/classPassenger_1_1FileNotFoundException.html +1 -1
  29. data/doc/cxxapi/classPassenger_1_1IOException-members.html +1 -1
  30. data/doc/cxxapi/classPassenger_1_1IOException.html +1 -1
  31. data/doc/cxxapi/classPassenger_1_1MessageChannel-members.html +1 -1
  32. data/doc/cxxapi/classPassenger_1_1MessageChannel.html +1 -1
  33. data/doc/cxxapi/classPassenger_1_1SpawnException-members.html +1 -1
  34. data/doc/cxxapi/classPassenger_1_1SpawnException.html +1 -1
  35. data/doc/cxxapi/classPassenger_1_1SpawnManager-members.html +1 -1
  36. data/doc/cxxapi/classPassenger_1_1SpawnManager.html +1 -1
  37. data/doc/cxxapi/classPassenger_1_1StandardApplicationPool-members.html +1 -1
  38. data/doc/cxxapi/classPassenger_1_1StandardApplicationPool.html +1 -1
  39. data/doc/cxxapi/classPassenger_1_1SystemException-members.html +1 -1
  40. data/doc/cxxapi/classPassenger_1_1SystemException.html +1 -1
  41. data/doc/cxxapi/definitions_8h-source.html +1 -1
  42. data/doc/cxxapi/files.html +1 -1
  43. data/doc/cxxapi/functions.html +1 -1
  44. data/doc/cxxapi/functions_func.html +1 -1
  45. data/doc/cxxapi/functions_type.html +1 -1
  46. data/doc/cxxapi/graph_legend.html +1 -1
  47. data/doc/cxxapi/graph_legend.png +0 -0
  48. data/doc/cxxapi/group__Configuration.html +3 -3
  49. data/doc/cxxapi/group__Configuration.png +0 -0
  50. data/doc/cxxapi/group__Core.html +1 -1
  51. data/doc/cxxapi/group__Core.png +0 -0
  52. data/doc/cxxapi/group__Exceptions.html +1 -1
  53. data/doc/cxxapi/group__Hooks.html +1 -1
  54. data/doc/cxxapi/group__Hooks.png +0 -0
  55. data/doc/cxxapi/group__Support.html +1 -1
  56. data/doc/cxxapi/hierarchy.html +1 -1
  57. data/doc/cxxapi/inherits.html +1 -1
  58. data/doc/cxxapi/main.html +1 -1
  59. data/doc/cxxapi/modules.html +1 -1
  60. data/doc/cxxapi/structPassenger_1_1AnythingToString-members.html +1 -1
  61. data/doc/cxxapi/structPassenger_1_1AnythingToString.html +1 -1
  62. data/doc/cxxapi/structPassenger_1_1AnythingToString_3_01vector_3_01string_01_4_01_4-members.html +1 -1
  63. data/doc/cxxapi/structPassenger_1_1AnythingToString_3_01vector_3_01string_01_4_01_4.html +1 -1
  64. data/doc/rdoc/created.rid +1 -1
  65. data/doc/rdoc/files/DEVELOPERS_TXT.html +1 -1
  66. data/doc/rdoc/files/ext/passenger/native_support_c.html +1 -1
  67. data/doc/rdoc/files/lib/passenger/application_spawner_rb.html +1 -1
  68. data/doc/rdoc/files/lib/passenger/dependencies_rb.html +1 -1
  69. data/doc/rdoc/files/lib/passenger/request_handler_rb.html +1 -1
  70. data/doc/rdoc/files/lib/passenger/spawn_manager_rb.html +1 -1
  71. data/ext/apache2/Configuration.h +1 -1
  72. data/ext/apache2/Hooks.cpp +57 -71
  73. data/ext/apache2/MessageChannel.h +25 -34
  74. data/ext/passenger/native_support.c +25 -32
  75. data/test/stub/apache2/httpd.conf +3 -0
  76. metadata +2 -2
data/Rakefile CHANGED
@@ -27,7 +27,7 @@ require 'passenger/platform_info'
27
27
  ##### Configuration
28
28
 
29
29
  # Don't forget to edit Configuration.h too
30
- PACKAGE_VERSION = "1.0.3"
30
+ PACKAGE_VERSION = "1.0.4"
31
31
 
32
32
  include PlatformInfo
33
33
  APXS2.nil? and raise "Could not find 'apxs' or 'apxs2'."
@@ -1320,6 +1320,8 @@ please note that you will have to delete Rails applications' default .htaccess
1320
1320
  file, or add rewrite rules to negate its effects.</p></div>
1321
1321
  <h4 id="_mod_userdir">5.4.2. mod_userdir</h4>
1322
1322
  <div class="para"><p><em>mod_userdir</em> is not compatible with Phusion Passenger at the moment.</p></div>
1323
+ <h4 id="_virtualdocumentroot">5.4.3. VirtualDocumentRoot</h4>
1324
+ <div class="para"><p>VirtualDocumentRoot is not compatible with Phusion Passenger at the moment.</p></div>
1323
1325
  </div>
1324
1326
  <h2 id="_tips_and_notes">6. Tips and notes</h2>
1325
1327
  <div class="sectionbody">
@@ -1433,7 +1435,7 @@ Attribution-Share Alike 3.0 Unported License</a>.</p></div>
1433
1435
  </div>
1434
1436
  <div id="footer">
1435
1437
  <div id="footer-text">
1436
- Last updated 2008-04-29 15:25:34 CEST
1438
+ Last updated 2008-05-01 20:10:22 CEST
1437
1439
  </div>
1438
1440
  </div>
1439
1441
  </body>
@@ -703,6 +703,10 @@ file, or add rewrite rules to negate its effects.
703
703
 
704
704
  'mod_userdir' is not compatible with Phusion Passenger at the moment.
705
705
 
706
+ ==== VirtualDocumentRoot ====
707
+
708
+ VirtualDocumentRoot is not compatible with Phusion Passenger at the moment.
709
+
706
710
 
707
711
  == Tips and notes ==
708
712
 
@@ -666,7 +666,7 @@
666
666
  <a name="l00651"></a>00651 } <span class="comment">// namespace Passenger</span>
667
667
  <a name="l00652"></a>00652
668
668
  <a name="l00653"></a>00653 <span class="preprocessor">#endif </span><span class="comment">/* _PASSENGER_APPLICATION_POOL_CLIENT_SERVER_H_ */</span>
669
- </pre></div><hr size="1"><address style="text-align: right;"><small>Generated on Wed Apr 30 00:07:01 2008 for Passenger by&nbsp;
669
+ </pre></div><hr size="1"><address style="text-align: right;"><small>Generated on Thu May 1 20:23:46 2008 for Passenger by&nbsp;
670
670
  <a href="http://www.doxygen.org/index.html">
671
671
  <img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5.3 </small></address>
672
672
  </body>
@@ -182,7 +182,7 @@
182
182
  <a name="l00167"></a>00167 }; <span class="comment">// namespace Passenger</span>
183
183
  <a name="l00168"></a>00168
184
184
  <a name="l00169"></a>00169 <span class="preprocessor">#endif </span><span class="comment">/* _PASSENGER_APPLICATION_POOL_H_ */</span>
185
- </pre></div><hr size="1"><address style="text-align: right;"><small>Generated on Wed Apr 30 00:07:01 2008 for Passenger by&nbsp;
185
+ </pre></div><hr size="1"><address style="text-align: right;"><small>Generated on Thu May 1 20:23:46 2008 for Passenger by&nbsp;
186
186
  <a href="http://www.doxygen.org/index.html">
187
187
  <img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5.3 </small></address>
188
188
  </body>
@@ -395,7 +395,7 @@
395
395
  <a name="l00380"></a>00380 } <span class="comment">// namespace Passenger</span>
396
396
  <a name="l00381"></a>00381
397
397
  <a name="l00382"></a>00382 <span class="preprocessor">#endif </span><span class="comment">/* _PASSENGER_APPLICATION_H_ */</span>
398
- </pre></div><hr size="1"><address style="text-align: right;"><small>Generated on Wed Apr 30 00:07:01 2008 for Passenger by&nbsp;
398
+ </pre></div><hr size="1"><address style="text-align: right;"><small>Generated on Thu May 1 20:23:46 2008 for Passenger by&nbsp;
399
399
  <a href="http://www.doxygen.org/index.html">
400
400
  <img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5.3 </small></address>
401
401
  </body>
@@ -44,7 +44,7 @@
44
44
  <a name="l00029"></a>00029 <span class="comment"> */</span>
45
45
  <a name="l00030"></a>00030 <span class="comment"></span>
46
46
  <a name="l00031"></a>00031 <span class="comment">/** Module version number. */</span>
47
- <a name="l00032"></a><a class="code" href="group__Configuration.html#ga19398896775408d6ab7fd8ce2acd992">00032</a> <span class="preprocessor">#define PASSENGER_VERSION "1.0.3"</span>
47
+ <a name="l00032"></a><a class="code" href="group__Configuration.html#ga19398896775408d6ab7fd8ce2acd992">00032</a> <span class="preprocessor">#define PASSENGER_VERSION "1.0.4"</span>
48
48
  <a name="l00033"></a>00033 <span class="preprocessor"></span>
49
49
  <a name="l00034"></a>00034 <span class="preprocessor">#ifdef __cplusplus</span>
50
50
  <a name="l00035"></a>00035 <span class="preprocessor"></span><span class="preprocessor"> #include &lt;set&gt;</span>
@@ -138,7 +138,7 @@
138
138
  <a name="l00123"></a>00123 <span class="comment"> */</span>
139
139
  <a name="l00124"></a>00124
140
140
  <a name="l00125"></a>00125 <span class="preprocessor">#endif </span><span class="comment">/* _PASSENGER_CONFIGURATION_H_ */</span>
141
- </pre></div><hr size="1"><address style="text-align: right;"><small>Generated on Wed Apr 30 00:07:01 2008 for Passenger by&nbsp;
141
+ </pre></div><hr size="1"><address style="text-align: right;"><small>Generated on Thu May 1 20:23:46 2008 for Passenger by&nbsp;
142
142
  <a href="http://www.doxygen.org/index.html">
143
143
  <img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5.3 </small></address>
144
144
  </body>
@@ -114,7 +114,7 @@
114
114
  <a name="l00099"></a>00099 } <span class="comment">// namespace Passenger</span>
115
115
  <a name="l00100"></a>00100
116
116
  <a name="l00101"></a>00101 <span class="preprocessor">#endif </span><span class="comment">/* _PASSENGER_DUMMY_SPAWN_MANAGER_H_ */</span>
117
- </pre></div><hr size="1"><address style="text-align: right;"><small>Generated on Wed Apr 30 00:07:01 2008 for Passenger by&nbsp;
117
+ </pre></div><hr size="1"><address style="text-align: right;"><small>Generated on Thu May 1 20:23:46 2008 for Passenger by&nbsp;
118
118
  <a href="http://www.doxygen.org/index.html">
119
119
  <img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5.3 </small></address>
120
120
  </body>
@@ -181,7 +181,7 @@
181
181
  <a name="l00166"></a>00166 } <span class="comment">// namespace Passenger</span>
182
182
  <a name="l00167"></a>00167
183
183
  <a name="l00168"></a>00168 <span class="preprocessor">#endif </span><span class="comment">/* _PASSENGER_EXCEPTIONS_H_ */</span>
184
- </pre></div><hr size="1"><address style="text-align: right;"><small>Generated on Wed Apr 30 00:07:01 2008 for Passenger by&nbsp;
184
+ </pre></div><hr size="1"><address style="text-align: right;"><small>Generated on Thu May 1 20:23:46 2008 for Passenger by&nbsp;
185
185
  <a href="http://www.doxygen.org/index.html">
186
186
  <img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5.3 </small></address>
187
187
  </body>
@@ -51,7 +51,7 @@
51
51
  <a name="l00036"></a>00036 <span class="preprocessor">#endif</span>
52
52
  <a name="l00037"></a>00037 <span class="preprocessor"></span>
53
53
  <a name="l00038"></a>00038 <span class="preprocessor">#endif </span><span class="comment">/* _PASSENGER_HOOKS_H_ */</span>
54
- </pre></div><hr size="1"><address style="text-align: right;"><small>Generated on Wed Apr 30 00:07:01 2008 for Passenger by&nbsp;
54
+ </pre></div><hr size="1"><address style="text-align: right;"><small>Generated on Thu May 1 20:23:46 2008 for Passenger by&nbsp;
55
55
  <a href="http://www.doxygen.org/index.html">
56
56
  <img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5.3 </small></address>
57
57
  </body>
@@ -96,7 +96,7 @@
96
96
  <a name="l00081"></a>00081
97
97
  <a name="l00082"></a>00082 <span class="preprocessor">#endif </span><span class="comment">/* _PASSENGER_LOGGING_H_ */</span>
98
98
  <a name="l00083"></a>00083
99
- </pre></div><hr size="1"><address style="text-align: right;"><small>Generated on Wed Apr 30 00:07:01 2008 for Passenger by&nbsp;
99
+ </pre></div><hr size="1"><address style="text-align: right;"><small>Generated on Thu May 1 20:23:46 2008 for Passenger by&nbsp;
100
100
  <a href="http://www.doxygen.org/index.html">
101
101
  <img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5.3 </small></address>
102
102
  </body>
@@ -271,217 +271,208 @@
271
271
  <a name="l00256"></a>00256 <span class="comment"> * @see readFileDescriptor()</span>
272
272
  <a name="l00257"></a>00257 <span class="comment"> */</span>
273
273
  <a name="l00258"></a><a class="code" href="classPassenger_1_1MessageChannel.html#73e3f3cda384c085a2af0e820ccd3e98">00258</a> <span class="keywordtype">void</span> <a class="code" href="classPassenger_1_1MessageChannel.html#73e3f3cda384c085a2af0e820ccd3e98" title="Pass a file descriptor.">writeFileDescriptor</a>(<span class="keywordtype">int</span> fileDescriptor) {
274
- <a name="l00259"></a>00259 <span class="keyword">struct </span>{
275
- <a name="l00260"></a>00260 <span class="keyword">struct </span>cmsghdr header;
276
- <a name="l00261"></a>00261 <span class="keywordtype">int</span> fd;
277
- <a name="l00262"></a>00262 } control;
278
- <a name="l00263"></a>00263
279
- <a name="l00264"></a>00264 control.header.cmsg_len = <span class="keyword">sizeof</span>(control);
280
- <a name="l00265"></a>00265 control.header.cmsg_level = SOL_SOCKET;
281
- <a name="l00266"></a>00266 control.header.cmsg_type = SCM_RIGHTS;
282
- <a name="l00267"></a>00267 control.fd = fileDescriptor;
283
- <a name="l00268"></a>00268
284
- <a name="l00269"></a>00269 <span class="keyword">struct </span>msghdr msg;
285
- <a name="l00270"></a>00270 <span class="keyword">struct </span>iovec vec;
286
- <a name="l00271"></a>00271 <span class="keywordtype">char</span> dummy[1];
287
- <a name="l00272"></a>00272
288
- <a name="l00273"></a>00273 msg.msg_name = NULL;
289
- <a name="l00274"></a>00274 msg.msg_namelen = 0;
290
- <a name="l00275"></a>00275
291
- <a name="l00276"></a>00276 <span class="comment">/* Linux and Solaris require msg_iov to be non-NULL.. */</span>
292
- <a name="l00277"></a>00277 dummy[0] = <span class="charliteral">'\0'</span>;
293
- <a name="l00278"></a>00278 vec.iov_base = dummy;
294
- <a name="l00279"></a>00279 vec.iov_len = <span class="keyword">sizeof</span>(dummy);
295
- <a name="l00280"></a>00280 msg.msg_iov = &amp;vec;
296
- <a name="l00281"></a>00281 msg.msg_iovlen = 1;
297
- <a name="l00282"></a>00282
298
- <a name="l00283"></a>00283 msg.msg_control = (caddr_t) &amp;control;
299
- <a name="l00284"></a>00284 msg.msg_controllen = <span class="keyword">sizeof</span>(control);
300
- <a name="l00285"></a>00285 msg.msg_flags = 0;
301
- <a name="l00286"></a>00286
302
- <a name="l00287"></a>00287 <span class="keywordflow">if</span> (sendmsg(fd, &amp;msg, 0) == -1) {
303
- <a name="l00288"></a>00288 <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 send file descriptor with sendmsg()"</span>, errno);
304
- <a name="l00289"></a>00289 }
305
- <a name="l00290"></a>00290 }
306
- <a name="l00291"></a>00291 <span class="comment"></span>
307
- <a name="l00292"></a>00292 <span class="comment"> /**</span>
308
- <a name="l00293"></a>00293 <span class="comment"> * Read an array message from the underlying file descriptor.</span>
309
- <a name="l00294"></a>00294 <span class="comment"> *</span>
310
- <a name="l00295"></a>00295 <span class="comment"> * @param args The message will be put in this variable.</span>
311
- <a name="l00296"></a>00296 <span class="comment"> * @return Whether end-of-file has been reached. If so, then the contents</span>
312
- <a name="l00297"></a>00297 <span class="comment"> * of &lt;tt&gt;args&lt;/tt&gt; will be undefined.</span>
313
- <a name="l00298"></a>00298 <span class="comment"> * @throws SystemException If an error occured while receiving the message.</span>
314
- <a name="l00299"></a>00299 <span class="comment"> * @see write()</span>
315
- <a name="l00300"></a>00300 <span class="comment"> */</span>
316
- <a name="l00301"></a><a class="code" href="classPassenger_1_1MessageChannel.html#129659b60d1a663337873d2af944431e">00301</a> <span class="keywordtype">bool</span> <a class="code" href="classPassenger_1_1MessageChannel.html#129659b60d1a663337873d2af944431e" title="Read an array message from the underlying file descriptor.">read</a>(vector&lt;string&gt; &amp;args) {
317
- <a name="l00302"></a>00302 uint16_t size;
318
- <a name="l00303"></a>00303 <span class="keywordtype">int</span> ret;
319
- <a name="l00304"></a>00304 <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> alreadyRead = 0;
320
- <a name="l00305"></a>00305
321
- <a name="l00306"></a>00306 <span class="keywordflow">do</span> {
322
- <a name="l00307"></a>00307 <span class="keywordflow">do</span> {
323
- <a name="l00308"></a>00308 ret =<a class="code" href="classPassenger_1_1MessageChannel.html#129659b60d1a663337873d2af944431e" title="Read an array message from the underlying file descriptor."> ::read</a>(fd, (<span class="keywordtype">char</span> *) &amp;size + alreadyRead, <span class="keyword">sizeof</span>(size) - alreadyRead);
324
- <a name="l00309"></a>00309 } <span class="keywordflow">while</span> (ret == -1 &amp;&amp; errno == EINTR);
325
- <a name="l00310"></a>00310 <span class="keywordflow">if</span> (ret == -1) {
326
- <a name="l00311"></a>00311 <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">"read() failed"</span>, errno);
327
- <a name="l00312"></a>00312 } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (ret == 0) {
328
- <a name="l00313"></a>00313 <span class="keywordflow">return</span> <span class="keyword">false</span>;
329
- <a name="l00314"></a>00314 }
330
- <a name="l00315"></a>00315 alreadyRead += ret;
331
- <a name="l00316"></a>00316 } <span class="keywordflow">while</span> (alreadyRead &lt; <span class="keyword">sizeof</span>(size));
332
- <a name="l00317"></a>00317 size = ntohs(size);
333
- <a name="l00318"></a>00318
334
- <a name="l00319"></a>00319 <span class="keywordtype">string</span> buffer;
335
- <a name="l00320"></a>00320 args.clear();
336
- <a name="l00321"></a>00321 buffer.reserve(size);
337
- <a name="l00322"></a>00322 <span class="keywordflow">while</span> (buffer.size() &lt; size) {
338
- <a name="l00323"></a>00323 <span class="keywordtype">char</span> tmp[1024 * 8];
339
- <a name="l00324"></a>00324 <span class="keywordflow">do</span> {
340
- <a name="l00325"></a>00325 ret =<a class="code" href="classPassenger_1_1MessageChannel.html#129659b60d1a663337873d2af944431e" title="Read an array message from the underlying file descriptor."> ::read</a>(fd, tmp, min(size - buffer.size(), <span class="keyword">sizeof</span>(tmp)));
341
- <a name="l00326"></a>00326 } <span class="keywordflow">while</span> (ret == -1 &amp;&amp; errno == EINTR);
342
- <a name="l00327"></a>00327 <span class="keywordflow">if</span> (ret == -1) {
343
- <a name="l00328"></a>00328 <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">"read() failed"</span>, errno);
344
- <a name="l00329"></a>00329 } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (ret == 0) {
345
- <a name="l00330"></a>00330 <span class="keywordflow">return</span> <span class="keyword">false</span>;
346
- <a name="l00331"></a>00331 }
347
- <a name="l00332"></a>00332 buffer.append(tmp, ret);
348
- <a name="l00333"></a>00333 }
349
- <a name="l00334"></a>00334
350
- <a name="l00335"></a>00335 <span class="keywordflow">if</span> (!buffer.empty()) {
351
- <a name="l00336"></a>00336 string::size_type start = 0, pos;
352
- <a name="l00337"></a>00337 <span class="keyword">const</span> <span class="keywordtype">string</span> &amp;const_buffer(buffer);
353
- <a name="l00338"></a>00338 <span class="keywordflow">while</span> ((pos = const_buffer.find(<span class="charliteral">'\0'</span>, start)) != string::npos) {
354
- <a name="l00339"></a>00339 args.push_back(const_buffer.substr(start, pos - start));
355
- <a name="l00340"></a>00340 start = pos + 1;
356
- <a name="l00341"></a>00341 }
357
- <a name="l00342"></a>00342 }
358
- <a name="l00343"></a>00343 <span class="keywordflow">return</span> <span class="keyword">true</span>;
359
- <a name="l00344"></a>00344 }
360
- <a name="l00345"></a>00345 <span class="comment"></span>
361
- <a name="l00346"></a>00346 <span class="comment"> /**</span>
362
- <a name="l00347"></a>00347 <span class="comment"> * Read a scalar message from the underlying file descriptor.</span>
363
- <a name="l00348"></a>00348 <span class="comment"> *</span>
364
- <a name="l00349"></a>00349 <span class="comment"> * @param output The message will be put in here.</span>
365
- <a name="l00350"></a>00350 <span class="comment"> * @returns Whether end-of-file was reached during reading.</span>
366
- <a name="l00351"></a>00351 <span class="comment"> * @throws SystemException An error occured while writing the data to the file descriptor.</span>
367
- <a name="l00352"></a>00352 <span class="comment"> * @see writeScalar()</span>
368
- <a name="l00353"></a>00353 <span class="comment"> */</span>
369
- <a name="l00354"></a><a class="code" href="classPassenger_1_1MessageChannel.html#4ce6a0e751b5e3563bee583c231569bc">00354</a> <span class="keywordtype">bool</span> <a class="code" href="classPassenger_1_1MessageChannel.html#4ce6a0e751b5e3563bee583c231569bc" title="Read a scalar message from the underlying file descriptor.">readScalar</a>(<span class="keywordtype">string</span> &amp;output) {
370
- <a name="l00355"></a>00355 uint32_t size;
371
- <a name="l00356"></a>00356 <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> remaining;
372
- <a name="l00357"></a>00357
373
- <a name="l00358"></a>00358 <span class="keywordflow">if</span> (!<a class="code" href="classPassenger_1_1MessageChannel.html#cd1d1bd1cc787784c8b54f5471fff479" title="Read exactly size bytes of data from the underlying file descriptor, and put the...">readRaw</a>(&amp;size, <span class="keyword">sizeof</span>(uint32_t))) {
374
- <a name="l00359"></a>00359 <span class="keywordflow">return</span> <span class="keyword">false</span>;
375
- <a name="l00360"></a>00360 }
376
- <a name="l00361"></a>00361 size = ntohl(size);
377
- <a name="l00362"></a>00362
378
- <a name="l00363"></a>00363 output.clear();
379
- <a name="l00364"></a>00364 output.reserve(size);
380
- <a name="l00365"></a>00365 remaining = size;
381
- <a name="l00366"></a>00366 <span class="keywordflow">while</span> (remaining &gt; 0) {
382
- <a name="l00367"></a>00367 <span class="keywordtype">char</span> buf[1024 * 32];
383
- <a name="l00368"></a>00368 <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> blockSize = min((<span class="keywordtype">unsigned</span> <span class="keywordtype">int</span>) <span class="keyword">sizeof</span>(buf), remaining);
384
- <a name="l00369"></a>00369
385
- <a name="l00370"></a>00370 <span class="keywordflow">if</span> (!<a class="code" href="classPassenger_1_1MessageChannel.html#cd1d1bd1cc787784c8b54f5471fff479" title="Read exactly size bytes of data from the underlying file descriptor, and put the...">readRaw</a>(buf, blockSize)) {
386
- <a name="l00371"></a>00371 <span class="keywordflow">return</span> <span class="keyword">false</span>;
387
- <a name="l00372"></a>00372 }
388
- <a name="l00373"></a>00373 output.append(buf, blockSize);
389
- <a name="l00374"></a>00374 remaining -= blockSize;
390
- <a name="l00375"></a>00375 }
391
- <a name="l00376"></a>00376 <span class="keywordflow">return</span> <span class="keyword">true</span>;
392
- <a name="l00377"></a>00377 }
393
- <a name="l00378"></a>00378 <span class="comment"></span>
394
- <a name="l00379"></a>00379 <span class="comment"> /**</span>
395
- <a name="l00380"></a>00380 <span class="comment"> * Read exactly &lt;tt&gt;size&lt;/tt&gt; bytes of data from the underlying file descriptor,</span>
396
- <a name="l00381"></a>00381 <span class="comment"> * and put the result in &lt;tt&gt;buf&lt;/tt&gt;. If end-of-file has been reached, or if</span>
397
- <a name="l00382"></a>00382 <span class="comment"> * end-of-file was encountered before &lt;tt&gt;size&lt;/tt&gt; bytes have been read, then</span>
398
- <a name="l00383"></a>00383 <span class="comment"> * &lt;tt&gt;false&lt;/tt&gt; will be returned. Otherwise (i.e. if the read was successful),</span>
399
- <a name="l00384"></a>00384 <span class="comment"> * &lt;tt&gt;true&lt;/tt&gt; will be returned.</span>
400
- <a name="l00385"></a>00385 <span class="comment"> *</span>
401
- <a name="l00386"></a>00386 <span class="comment"> * @param buf The buffer to place the read data in. This buffer must be at least</span>
402
- <a name="l00387"></a>00387 <span class="comment"> * &lt;tt&gt;size&lt;/tt&gt; bytes long.</span>
403
- <a name="l00388"></a>00388 <span class="comment"> * @param size The number of bytes to read.</span>
404
- <a name="l00389"></a>00389 <span class="comment"> * @return Whether reading was successful or whether EOF was reached.</span>
405
- <a name="l00390"></a>00390 <span class="comment"> * @pre buf != NULL</span>
406
- <a name="l00391"></a>00391 <span class="comment"> * @throws SystemException Something went wrong during reading.</span>
407
- <a name="l00392"></a>00392 <span class="comment"> * @see writeRaw()</span>
408
- <a name="l00393"></a>00393 <span class="comment"> */</span>
409
- <a name="l00394"></a><a class="code" href="classPassenger_1_1MessageChannel.html#cd1d1bd1cc787784c8b54f5471fff479">00394</a> <span class="keywordtype">bool</span> <a class="code" href="classPassenger_1_1MessageChannel.html#cd1d1bd1cc787784c8b54f5471fff479" title="Read exactly size bytes of data from the underlying file descriptor, and put the...">readRaw</a>(<span class="keywordtype">void</span> *buf, <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> size) {
410
- <a name="l00395"></a>00395 ssize_t ret;
411
- <a name="l00396"></a>00396 <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> alreadyRead = 0;
412
- <a name="l00397"></a>00397
413
- <a name="l00398"></a>00398 <span class="keywordflow">while</span> (alreadyRead &lt; size) {
414
- <a name="l00399"></a>00399 <span class="keywordflow">do</span> {
415
- <a name="l00400"></a>00400 ret =<a class="code" href="classPassenger_1_1MessageChannel.html#129659b60d1a663337873d2af944431e" title="Read an array message from the underlying file descriptor."> ::read</a>(fd, (<span class="keywordtype">char</span> *) buf + alreadyRead, size - alreadyRead);
416
- <a name="l00401"></a>00401 } <span class="keywordflow">while</span> (ret == -1 &amp;&amp; errno == EINTR);
417
- <a name="l00402"></a>00402 <span class="keywordflow">if</span> (ret == -1) {
418
- <a name="l00403"></a>00403 <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">"read() failed"</span>, errno);
419
- <a name="l00404"></a>00404 } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (ret == 0) {
420
- <a name="l00405"></a>00405 <span class="keywordflow">return</span> <span class="keyword">false</span>;
421
- <a name="l00406"></a>00406 } <span class="keywordflow">else</span> {
422
- <a name="l00407"></a>00407 alreadyRead += ret;
423
- <a name="l00408"></a>00408 }
424
- <a name="l00409"></a>00409 }
425
- <a name="l00410"></a>00410 <span class="keywordflow">return</span> <span class="keyword">true</span>;
426
- <a name="l00411"></a>00411 }
427
- <a name="l00412"></a>00412 <span class="comment"></span>
428
- <a name="l00413"></a>00413 <span class="comment"> /**</span>
429
- <a name="l00414"></a>00414 <span class="comment"> * Receive a file descriptor, which had been passed over the underlying</span>
430
- <a name="l00415"></a>00415 <span class="comment"> * file descriptor.</span>
431
- <a name="l00416"></a>00416 <span class="comment"> *</span>
432
- <a name="l00417"></a>00417 <span class="comment"> * @return The passed file descriptor.</span>
433
- <a name="l00418"></a>00418 <span class="comment"> * @throws SystemException If something went wrong during the</span>
434
- <a name="l00419"></a>00419 <span class="comment"> * receiving of a file descriptor. Perhaps the underlying</span>
435
- <a name="l00420"></a>00420 <span class="comment"> * file descriptor isn't a Unix socket.</span>
436
- <a name="l00421"></a>00421 <span class="comment"> * @throws IOException Whatever was received doesn't seem to be a</span>
437
- <a name="l00422"></a>00422 <span class="comment"> * file descriptor.</span>
438
- <a name="l00423"></a>00423 <span class="comment"> */</span>
439
- <a name="l00424"></a><a class="code" href="classPassenger_1_1MessageChannel.html#1561b7e4a0f4d39ea431f456e5655488">00424</a> <span class="keywordtype">int</span> <a class="code" href="classPassenger_1_1MessageChannel.html#1561b7e4a0f4d39ea431f456e5655488" title="Receive a file descriptor, which had been passed over the underlying file descriptor...">readFileDescriptor</a>() {
440
- <a name="l00425"></a>00425 <span class="keyword">struct </span>{
441
- <a name="l00426"></a>00426 <span class="keyword">struct </span>cmsghdr header;
442
- <a name="l00427"></a>00427 <span class="keywordtype">int</span> fd;
443
- <a name="l00428"></a>00428 } control;
444
- <a name="l00429"></a>00429
445
- <a name="l00430"></a>00430 control.header.cmsg_len = <span class="keyword">sizeof</span>(control);
446
- <a name="l00431"></a>00431 control.header.cmsg_level = SOL_SOCKET;
447
- <a name="l00432"></a>00432 control.header.cmsg_type = SCM_RIGHTS;
448
- <a name="l00433"></a>00433 control.fd = -1;
449
- <a name="l00434"></a>00434
450
- <a name="l00435"></a>00435 <span class="keyword">struct </span>msghdr msg;
451
- <a name="l00436"></a>00436 <span class="keyword">struct </span>iovec vec;
452
- <a name="l00437"></a>00437 <span class="keywordtype">char</span> dummy[1];
453
- <a name="l00438"></a>00438
454
- <a name="l00439"></a>00439 msg.msg_name = NULL;
455
- <a name="l00440"></a>00440 msg.msg_namelen = 0;
274
+ <a name="l00259"></a>00259 <span class="keyword">struct </span>msghdr msg;
275
+ <a name="l00260"></a>00260 <span class="keyword">struct </span>iovec vec;
276
+ <a name="l00261"></a>00261 <span class="keywordtype">char</span> dummy[1];
277
+ <a name="l00262"></a>00262 <span class="keywordtype">char</span> control_data[CMSG_SPACE(<span class="keyword">sizeof</span>(<span class="keywordtype">int</span>))];
278
+ <a name="l00263"></a>00263 <span class="keyword">struct </span>cmsghdr *control_header;
279
+ <a name="l00264"></a>00264
280
+ <a name="l00265"></a>00265 msg.msg_name = NULL;
281
+ <a name="l00266"></a>00266 msg.msg_namelen = 0;
282
+ <a name="l00267"></a>00267
283
+ <a name="l00268"></a>00268 <span class="comment">/* Linux and Solaris require msg_iov to be non-NULL. */</span>
284
+ <a name="l00269"></a>00269 dummy[0] = <span class="charliteral">'\0'</span>;
285
+ <a name="l00270"></a>00270 vec.iov_base = dummy;
286
+ <a name="l00271"></a>00271 vec.iov_len = <span class="keyword">sizeof</span>(dummy);
287
+ <a name="l00272"></a>00272 msg.msg_iov = &amp;vec;
288
+ <a name="l00273"></a>00273 msg.msg_iovlen = 1;
289
+ <a name="l00274"></a>00274
290
+ <a name="l00275"></a>00275 msg.msg_control = (caddr_t) control_data;
291
+ <a name="l00276"></a>00276 msg.msg_controllen = <span class="keyword">sizeof</span>(control_data);
292
+ <a name="l00277"></a>00277 msg.msg_flags = 0;
293
+ <a name="l00278"></a>00278
294
+ <a name="l00279"></a>00279 control_header = CMSG_FIRSTHDR(&amp;msg);
295
+ <a name="l00280"></a>00280 control_header-&gt;cmsg_len = CMSG_LEN(<span class="keyword">sizeof</span>(<span class="keywordtype">int</span>));
296
+ <a name="l00281"></a>00281 control_header-&gt;cmsg_level = SOL_SOCKET;
297
+ <a name="l00282"></a>00282 control_header-&gt;cmsg_type = SCM_RIGHTS;
298
+ <a name="l00283"></a>00283 memcpy(CMSG_DATA(control_header), &amp;fileDescriptor, <span class="keyword">sizeof</span>(<span class="keywordtype">int</span>));
299
+ <a name="l00284"></a>00284
300
+ <a name="l00285"></a>00285 <span class="keywordflow">if</span> (sendmsg(fd, &amp;msg, 0) == -1) {
301
+ <a name="l00286"></a>00286 <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 send file descriptor with sendmsg()"</span>, errno);
302
+ <a name="l00287"></a>00287 }
303
+ <a name="l00288"></a>00288 }
304
+ <a name="l00289"></a>00289 <span class="comment"></span>
305
+ <a name="l00290"></a>00290 <span class="comment"> /**</span>
306
+ <a name="l00291"></a>00291 <span class="comment"> * Read an array message from the underlying file descriptor.</span>
307
+ <a name="l00292"></a>00292 <span class="comment"> *</span>
308
+ <a name="l00293"></a>00293 <span class="comment"> * @param args The message will be put in this variable.</span>
309
+ <a name="l00294"></a>00294 <span class="comment"> * @return Whether end-of-file has been reached. If so, then the contents</span>
310
+ <a name="l00295"></a>00295 <span class="comment"> * of &lt;tt&gt;args&lt;/tt&gt; will be undefined.</span>
311
+ <a name="l00296"></a>00296 <span class="comment"> * @throws SystemException If an error occured while receiving the message.</span>
312
+ <a name="l00297"></a>00297 <span class="comment"> * @see write()</span>
313
+ <a name="l00298"></a>00298 <span class="comment"> */</span>
314
+ <a name="l00299"></a><a class="code" href="classPassenger_1_1MessageChannel.html#129659b60d1a663337873d2af944431e">00299</a> <span class="keywordtype">bool</span> <a class="code" href="classPassenger_1_1MessageChannel.html#129659b60d1a663337873d2af944431e" title="Read an array message from the underlying file descriptor.">read</a>(vector&lt;string&gt; &amp;args) {
315
+ <a name="l00300"></a>00300 uint16_t size;
316
+ <a name="l00301"></a>00301 <span class="keywordtype">int</span> ret;
317
+ <a name="l00302"></a>00302 <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> alreadyRead = 0;
318
+ <a name="l00303"></a>00303
319
+ <a name="l00304"></a>00304 <span class="keywordflow">do</span> {
320
+ <a name="l00305"></a>00305 <span class="keywordflow">do</span> {
321
+ <a name="l00306"></a>00306 ret =<a class="code" href="classPassenger_1_1MessageChannel.html#129659b60d1a663337873d2af944431e" title="Read an array message from the underlying file descriptor."> ::read</a>(fd, (<span class="keywordtype">char</span> *) &amp;size + alreadyRead, <span class="keyword">sizeof</span>(size) - alreadyRead);
322
+ <a name="l00307"></a>00307 } <span class="keywordflow">while</span> (ret == -1 &amp;&amp; errno == EINTR);
323
+ <a name="l00308"></a>00308 <span class="keywordflow">if</span> (ret == -1) {
324
+ <a name="l00309"></a>00309 <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">"read() failed"</span>, errno);
325
+ <a name="l00310"></a>00310 } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (ret == 0) {
326
+ <a name="l00311"></a>00311 <span class="keywordflow">return</span> <span class="keyword">false</span>;
327
+ <a name="l00312"></a>00312 }
328
+ <a name="l00313"></a>00313 alreadyRead += ret;
329
+ <a name="l00314"></a>00314 } <span class="keywordflow">while</span> (alreadyRead &lt; <span class="keyword">sizeof</span>(size));
330
+ <a name="l00315"></a>00315 size = ntohs(size);
331
+ <a name="l00316"></a>00316
332
+ <a name="l00317"></a>00317 <span class="keywordtype">string</span> buffer;
333
+ <a name="l00318"></a>00318 args.clear();
334
+ <a name="l00319"></a>00319 buffer.reserve(size);
335
+ <a name="l00320"></a>00320 <span class="keywordflow">while</span> (buffer.size() &lt; size) {
336
+ <a name="l00321"></a>00321 <span class="keywordtype">char</span> tmp[1024 * 8];
337
+ <a name="l00322"></a>00322 <span class="keywordflow">do</span> {
338
+ <a name="l00323"></a>00323 ret =<a class="code" href="classPassenger_1_1MessageChannel.html#129659b60d1a663337873d2af944431e" title="Read an array message from the underlying file descriptor."> ::read</a>(fd, tmp, min(size - buffer.size(), <span class="keyword">sizeof</span>(tmp)));
339
+ <a name="l00324"></a>00324 } <span class="keywordflow">while</span> (ret == -1 &amp;&amp; errno == EINTR);
340
+ <a name="l00325"></a>00325 <span class="keywordflow">if</span> (ret == -1) {
341
+ <a name="l00326"></a>00326 <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">"read() failed"</span>, errno);
342
+ <a name="l00327"></a>00327 } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (ret == 0) {
343
+ <a name="l00328"></a>00328 <span class="keywordflow">return</span> <span class="keyword">false</span>;
344
+ <a name="l00329"></a>00329 }
345
+ <a name="l00330"></a>00330 buffer.append(tmp, ret);
346
+ <a name="l00331"></a>00331 }
347
+ <a name="l00332"></a>00332
348
+ <a name="l00333"></a>00333 <span class="keywordflow">if</span> (!buffer.empty()) {
349
+ <a name="l00334"></a>00334 string::size_type start = 0, pos;
350
+ <a name="l00335"></a>00335 <span class="keyword">const</span> <span class="keywordtype">string</span> &amp;const_buffer(buffer);
351
+ <a name="l00336"></a>00336 <span class="keywordflow">while</span> ((pos = const_buffer.find(<span class="charliteral">'\0'</span>, start)) != string::npos) {
352
+ <a name="l00337"></a>00337 args.push_back(const_buffer.substr(start, pos - start));
353
+ <a name="l00338"></a>00338 start = pos + 1;
354
+ <a name="l00339"></a>00339 }
355
+ <a name="l00340"></a>00340 }
356
+ <a name="l00341"></a>00341 <span class="keywordflow">return</span> <span class="keyword">true</span>;
357
+ <a name="l00342"></a>00342 }
358
+ <a name="l00343"></a>00343 <span class="comment"></span>
359
+ <a name="l00344"></a>00344 <span class="comment"> /**</span>
360
+ <a name="l00345"></a>00345 <span class="comment"> * Read a scalar message from the underlying file descriptor.</span>
361
+ <a name="l00346"></a>00346 <span class="comment"> *</span>
362
+ <a name="l00347"></a>00347 <span class="comment"> * @param output The message will be put in here.</span>
363
+ <a name="l00348"></a>00348 <span class="comment"> * @returns Whether end-of-file was reached during reading.</span>
364
+ <a name="l00349"></a>00349 <span class="comment"> * @throws SystemException An error occured while writing the data to the file descriptor.</span>
365
+ <a name="l00350"></a>00350 <span class="comment"> * @see writeScalar()</span>
366
+ <a name="l00351"></a>00351 <span class="comment"> */</span>
367
+ <a name="l00352"></a><a class="code" href="classPassenger_1_1MessageChannel.html#4ce6a0e751b5e3563bee583c231569bc">00352</a> <span class="keywordtype">bool</span> <a class="code" href="classPassenger_1_1MessageChannel.html#4ce6a0e751b5e3563bee583c231569bc" title="Read a scalar message from the underlying file descriptor.">readScalar</a>(<span class="keywordtype">string</span> &amp;output) {
368
+ <a name="l00353"></a>00353 uint32_t size;
369
+ <a name="l00354"></a>00354 <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> remaining;
370
+ <a name="l00355"></a>00355
371
+ <a name="l00356"></a>00356 <span class="keywordflow">if</span> (!<a class="code" href="classPassenger_1_1MessageChannel.html#cd1d1bd1cc787784c8b54f5471fff479" title="Read exactly size bytes of data from the underlying file descriptor, and put the...">readRaw</a>(&amp;size, <span class="keyword">sizeof</span>(uint32_t))) {
372
+ <a name="l00357"></a>00357 <span class="keywordflow">return</span> <span class="keyword">false</span>;
373
+ <a name="l00358"></a>00358 }
374
+ <a name="l00359"></a>00359 size = ntohl(size);
375
+ <a name="l00360"></a>00360
376
+ <a name="l00361"></a>00361 output.clear();
377
+ <a name="l00362"></a>00362 output.reserve(size);
378
+ <a name="l00363"></a>00363 remaining = size;
379
+ <a name="l00364"></a>00364 <span class="keywordflow">while</span> (remaining &gt; 0) {
380
+ <a name="l00365"></a>00365 <span class="keywordtype">char</span> buf[1024 * 32];
381
+ <a name="l00366"></a>00366 <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> blockSize = min((<span class="keywordtype">unsigned</span> <span class="keywordtype">int</span>) <span class="keyword">sizeof</span>(buf), remaining);
382
+ <a name="l00367"></a>00367
383
+ <a name="l00368"></a>00368 <span class="keywordflow">if</span> (!<a class="code" href="classPassenger_1_1MessageChannel.html#cd1d1bd1cc787784c8b54f5471fff479" title="Read exactly size bytes of data from the underlying file descriptor, and put the...">readRaw</a>(buf, blockSize)) {
384
+ <a name="l00369"></a>00369 <span class="keywordflow">return</span> <span class="keyword">false</span>;
385
+ <a name="l00370"></a>00370 }
386
+ <a name="l00371"></a>00371 output.append(buf, blockSize);
387
+ <a name="l00372"></a>00372 remaining -= blockSize;
388
+ <a name="l00373"></a>00373 }
389
+ <a name="l00374"></a>00374 <span class="keywordflow">return</span> <span class="keyword">true</span>;
390
+ <a name="l00375"></a>00375 }
391
+ <a name="l00376"></a>00376 <span class="comment"></span>
392
+ <a name="l00377"></a>00377 <span class="comment"> /**</span>
393
+ <a name="l00378"></a>00378 <span class="comment"> * Read exactly &lt;tt&gt;size&lt;/tt&gt; bytes of data from the underlying file descriptor,</span>
394
+ <a name="l00379"></a>00379 <span class="comment"> * and put the result in &lt;tt&gt;buf&lt;/tt&gt;. If end-of-file has been reached, or if</span>
395
+ <a name="l00380"></a>00380 <span class="comment"> * end-of-file was encountered before &lt;tt&gt;size&lt;/tt&gt; bytes have been read, then</span>
396
+ <a name="l00381"></a>00381 <span class="comment"> * &lt;tt&gt;false&lt;/tt&gt; will be returned. Otherwise (i.e. if the read was successful),</span>
397
+ <a name="l00382"></a>00382 <span class="comment"> * &lt;tt&gt;true&lt;/tt&gt; will be returned.</span>
398
+ <a name="l00383"></a>00383 <span class="comment"> *</span>
399
+ <a name="l00384"></a>00384 <span class="comment"> * @param buf The buffer to place the read data in. This buffer must be at least</span>
400
+ <a name="l00385"></a>00385 <span class="comment"> * &lt;tt&gt;size&lt;/tt&gt; bytes long.</span>
401
+ <a name="l00386"></a>00386 <span class="comment"> * @param size The number of bytes to read.</span>
402
+ <a name="l00387"></a>00387 <span class="comment"> * @return Whether reading was successful or whether EOF was reached.</span>
403
+ <a name="l00388"></a>00388 <span class="comment"> * @pre buf != NULL</span>
404
+ <a name="l00389"></a>00389 <span class="comment"> * @throws SystemException Something went wrong during reading.</span>
405
+ <a name="l00390"></a>00390 <span class="comment"> * @see writeRaw()</span>
406
+ <a name="l00391"></a>00391 <span class="comment"> */</span>
407
+ <a name="l00392"></a><a class="code" href="classPassenger_1_1MessageChannel.html#cd1d1bd1cc787784c8b54f5471fff479">00392</a> <span class="keywordtype">bool</span> <a class="code" href="classPassenger_1_1MessageChannel.html#cd1d1bd1cc787784c8b54f5471fff479" title="Read exactly size bytes of data from the underlying file descriptor, and put the...">readRaw</a>(<span class="keywordtype">void</span> *buf, <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> size) {
408
+ <a name="l00393"></a>00393 ssize_t ret;
409
+ <a name="l00394"></a>00394 <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> alreadyRead = 0;
410
+ <a name="l00395"></a>00395
411
+ <a name="l00396"></a>00396 <span class="keywordflow">while</span> (alreadyRead &lt; size) {
412
+ <a name="l00397"></a>00397 <span class="keywordflow">do</span> {
413
+ <a name="l00398"></a>00398 ret =<a class="code" href="classPassenger_1_1MessageChannel.html#129659b60d1a663337873d2af944431e" title="Read an array message from the underlying file descriptor."> ::read</a>(fd, (<span class="keywordtype">char</span> *) buf + alreadyRead, size - alreadyRead);
414
+ <a name="l00399"></a>00399 } <span class="keywordflow">while</span> (ret == -1 &amp;&amp; errno == EINTR);
415
+ <a name="l00400"></a>00400 <span class="keywordflow">if</span> (ret == -1) {
416
+ <a name="l00401"></a>00401 <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">"read() failed"</span>, errno);
417
+ <a name="l00402"></a>00402 } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (ret == 0) {
418
+ <a name="l00403"></a>00403 <span class="keywordflow">return</span> <span class="keyword">false</span>;
419
+ <a name="l00404"></a>00404 } <span class="keywordflow">else</span> {
420
+ <a name="l00405"></a>00405 alreadyRead += ret;
421
+ <a name="l00406"></a>00406 }
422
+ <a name="l00407"></a>00407 }
423
+ <a name="l00408"></a>00408 <span class="keywordflow">return</span> <span class="keyword">true</span>;
424
+ <a name="l00409"></a>00409 }
425
+ <a name="l00410"></a>00410 <span class="comment"></span>
426
+ <a name="l00411"></a>00411 <span class="comment"> /**</span>
427
+ <a name="l00412"></a>00412 <span class="comment"> * Receive a file descriptor, which had been passed over the underlying</span>
428
+ <a name="l00413"></a>00413 <span class="comment"> * file descriptor.</span>
429
+ <a name="l00414"></a>00414 <span class="comment"> *</span>
430
+ <a name="l00415"></a>00415 <span class="comment"> * @return The passed file descriptor.</span>
431
+ <a name="l00416"></a>00416 <span class="comment"> * @throws SystemException If something went wrong during the</span>
432
+ <a name="l00417"></a>00417 <span class="comment"> * receiving of a file descriptor. Perhaps the underlying</span>
433
+ <a name="l00418"></a>00418 <span class="comment"> * file descriptor isn't a Unix socket.</span>
434
+ <a name="l00419"></a>00419 <span class="comment"> * @throws IOException Whatever was received doesn't seem to be a</span>
435
+ <a name="l00420"></a>00420 <span class="comment"> * file descriptor.</span>
436
+ <a name="l00421"></a>00421 <span class="comment"> */</span>
437
+ <a name="l00422"></a><a class="code" href="classPassenger_1_1MessageChannel.html#1561b7e4a0f4d39ea431f456e5655488">00422</a> <span class="keywordtype">int</span> <a class="code" href="classPassenger_1_1MessageChannel.html#1561b7e4a0f4d39ea431f456e5655488" title="Receive a file descriptor, which had been passed over the underlying file descriptor...">readFileDescriptor</a>() {
438
+ <a name="l00423"></a>00423 <span class="keyword">struct </span>msghdr msg;
439
+ <a name="l00424"></a>00424 <span class="keyword">struct </span>iovec vec;
440
+ <a name="l00425"></a>00425 <span class="keywordtype">char</span> dummy[1];
441
+ <a name="l00426"></a>00426 <span class="keywordtype">char</span> control_data[CMSG_SPACE(<span class="keyword">sizeof</span>(<span class="keywordtype">int</span>))];
442
+ <a name="l00427"></a>00427 <span class="keyword">struct </span>cmsghdr *control_header;
443
+ <a name="l00428"></a>00428
444
+ <a name="l00429"></a>00429 msg.msg_name = NULL;
445
+ <a name="l00430"></a>00430 msg.msg_namelen = 0;
446
+ <a name="l00431"></a>00431
447
+ <a name="l00432"></a>00432 dummy[0] = <span class="charliteral">'\0'</span>;
448
+ <a name="l00433"></a>00433 vec.iov_base = dummy;
449
+ <a name="l00434"></a>00434 vec.iov_len = <span class="keyword">sizeof</span>(dummy);
450
+ <a name="l00435"></a>00435 msg.msg_iov = &amp;vec;
451
+ <a name="l00436"></a>00436 msg.msg_iovlen = 1;
452
+ <a name="l00437"></a>00437
453
+ <a name="l00438"></a>00438 msg.msg_control = (caddr_t) control_data;
454
+ <a name="l00439"></a>00439 msg.msg_controllen = <span class="keyword">sizeof</span>(control_data);
455
+ <a name="l00440"></a>00440 msg.msg_flags = 0;
456
456
  <a name="l00441"></a>00441
457
- <a name="l00442"></a>00442 dummy[0] = <span class="charliteral">'\0'</span>;
458
- <a name="l00443"></a>00443 vec.iov_base = dummy;
459
- <a name="l00444"></a>00444 vec.iov_len = <span class="keyword">sizeof</span>(dummy);
460
- <a name="l00445"></a>00445 msg.msg_iov = &amp;vec;
461
- <a name="l00446"></a>00446 msg.msg_iovlen = 1;
462
- <a name="l00447"></a>00447
463
- <a name="l00448"></a>00448 msg.msg_control = (caddr_t) &amp;control;
464
- <a name="l00449"></a>00449 msg.msg_controllen = <span class="keyword">sizeof</span>(control);
465
- <a name="l00450"></a>00450 msg.msg_flags = 0;
466
- <a name="l00451"></a>00451
467
- <a name="l00452"></a>00452 <span class="keywordflow">if</span> (recvmsg(fd, &amp;msg, 0) == -1) {
468
- <a name="l00453"></a>00453 <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 read file descriptor with recvmsg()"</span>, errno);
469
- <a name="l00454"></a>00454 }
470
- <a name="l00455"></a>00455
471
- <a name="l00456"></a>00456 <span class="keywordflow">if</span> (msg.msg_controllen != <span class="keyword">sizeof</span>(control)
472
- <a name="l00457"></a>00457 || control.header.cmsg_len != <span class="keyword">sizeof</span>(control)
473
- <a name="l00458"></a>00458 || control.header.cmsg_level != SOL_SOCKET
474
- <a name="l00459"></a>00459 || control.header.cmsg_type != SCM_RIGHTS) {
475
- <a name="l00460"></a>00460 <span class="keywordflow">throw</span> <a class="code" href="classPassenger_1_1IOException.html" title="Represents an error that occured during an I/O operation.">IOException</a>(<span class="stringliteral">"No valid file descriptor received."</span>);
476
- <a name="l00461"></a>00461 }
477
- <a name="l00462"></a>00462 <span class="keywordflow">return</span> control.fd;
478
- <a name="l00463"></a>00463 }
479
- <a name="l00464"></a>00464 };
480
- <a name="l00465"></a>00465
481
- <a name="l00466"></a>00466 } <span class="comment">// namespace Passenger</span>
482
- <a name="l00467"></a>00467
483
- <a name="l00468"></a>00468 <span class="preprocessor">#endif </span><span class="comment">/* _PASSENGER_MESSAGE_CHANNEL_H_ */</span>
484
- </pre></div><hr size="1"><address style="text-align: right;"><small>Generated on Wed Apr 30 00:07:01 2008 for Passenger by&nbsp;
457
+ <a name="l00442"></a>00442 <span class="keywordflow">if</span> (recvmsg(fd, &amp;msg, 0) == -1) {
458
+ <a name="l00443"></a>00443 <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 read file descriptor with recvmsg()"</span>, errno);
459
+ <a name="l00444"></a>00444 }
460
+ <a name="l00445"></a>00445
461
+ <a name="l00446"></a>00446 control_header = CMSG_FIRSTHDR(&amp;msg);
462
+ <a name="l00447"></a>00447 <span class="keywordflow">if</span> (msg.msg_controllen != <span class="keyword">sizeof</span>(control_data)
463
+ <a name="l00448"></a>00448 || control_header-&gt;cmsg_len != CMSG_LEN(<span class="keyword">sizeof</span>(<span class="keywordtype">int</span>))
464
+ <a name="l00449"></a>00449 || control_header-&gt;cmsg_level != SOL_SOCKET
465
+ <a name="l00450"></a>00450 || control_header-&gt;cmsg_type != SCM_RIGHTS) {
466
+ <a name="l00451"></a>00451 <span class="keywordflow">throw</span> <a class="code" href="classPassenger_1_1IOException.html" title="Represents an error that occured during an I/O operation.">IOException</a>(<span class="stringliteral">"No valid file descriptor received."</span>);
467
+ <a name="l00452"></a>00452 }
468
+ <a name="l00453"></a>00453 <span class="keywordflow">return</span> *((<span class="keywordtype">int</span> *) CMSG_DATA(control_header));
469
+ <a name="l00454"></a>00454 }
470
+ <a name="l00455"></a>00455 };
471
+ <a name="l00456"></a>00456
472
+ <a name="l00457"></a>00457 } <span class="comment">// namespace Passenger</span>
473
+ <a name="l00458"></a>00458
474
+ <a name="l00459"></a>00459 <span class="preprocessor">#endif </span><span class="comment">/* _PASSENGER_MESSAGE_CHANNEL_H_ */</span>
475
+ </pre></div><hr size="1"><address style="text-align: right;"><small>Generated on Thu May 1 20:23:46 2008 for Passenger by&nbsp;
485
476
  <a href="http://www.doxygen.org/index.html">
486
477
  <img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5.3 </small></address>
487
478
  </body>