doc/cxxapi/MessageChannel_8h-source.html in passenger-2.1.3 vs doc/cxxapi/MessageChannel_8h-source.html in passenger-2.2.0
- old
+ new
@@ -1,21 +1,26 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title>Passenger: MessageChannel.h Source File</title>
-<link href="doxygen.css" rel="stylesheet" type="text/css">
<link href="tabs.css" rel="stylesheet" type="text/css">
+<link href="doxygen.css" rel="stylesheet" type="text/css">
</head><body>
-<!-- Generated by Doxygen 1.5.5 -->
+<!-- Generated by Doxygen 1.5.8 -->
<div class="navigation" id="top">
<div class="tabs">
<ul>
<li><a href="main.html"><span>Main Page</span></a></li>
<li><a href="modules.html"><span>Modules</span></a></li>
<li><a href="annotated.html"><span>Classes</span></a></li>
<li class="current"><a href="files.html"><span>Files</span></a></li>
</ul>
</div>
+ <div class="tabs">
+ <ul>
+ <li><a href="files.html"><span>File List</span></a></li>
+ </ul>
+ </div>
<h1>MessageChannel.h</h1><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">/*</span>
<a name="l00002"></a>00002 <span class="comment"> * Phusion Passenger - http://www.modrails.com/</span>
<a name="l00003"></a>00003 <span class="comment"> * Copyright (C) 2008 Phusion</span>
<a name="l00004"></a>00004 <span class="comment"> *</span>
<a name="l00005"></a>00005 <span class="comment"> * Phusion Passenger is a trademark of Hongli Lai & Ninh Bui.</span>
@@ -146,11 +151,11 @@
<a name="l00130"></a>00130 }
<a name="l00131"></a>00131 <span class="comment"></span>
<a name="l00132"></a>00132 <span class="comment"> /**</span>
<a name="l00133"></a>00133 <span class="comment"> * Construct a new MessageChannel with the given file descriptor.</span>
<a name="l00134"></a>00134 <span class="comment"> */</span>
-<a name="l00135"></a><a class="code" href="classPassenger_1_1MessageChannel.html#486b6e74c4d0973eefbcfde65f898ca7">00135</a> <a class="code" href="classPassenger_1_1MessageChannel.html#73e7c9a8e421d29558838176aff02ca4" title="Construct a new MessageChannel with no underlying file descriptor.">MessageChannel</a>(<span class="keywordtype">int</span> fd) {
+<a name="l00135"></a><a class="code" href="classPassenger_1_1MessageChannel.html#486b6e74c4d0973eefbcfde65f898ca7">00135</a> <a class="code" href="classPassenger_1_1MessageChannel.html#486b6e74c4d0973eefbcfde65f898ca7" title="Construct a new MessageChannel with the given file descriptor.">MessageChannel</a>(<span class="keywordtype">int</span> fd) {
<a name="l00136"></a>00136 this->fd = fd;
<a name="l00137"></a>00137 }
<a name="l00138"></a>00138 <span class="comment"></span>
<a name="l00139"></a>00139 <span class="comment"> /**</span>
<a name="l00140"></a>00140 <span class="comment"> * Close the underlying file descriptor. If this method is called multiple</span>
@@ -159,11 +164,11 @@
<a name="l00143"></a>00143 <span class="comment"> * @throw SystemException</span>
<a name="l00144"></a>00144 <span class="comment"> * @throw boost::thread_interrupted</span>
<a name="l00145"></a>00145 <span class="comment"> */</span>
<a name="l00146"></a><a class="code" href="classPassenger_1_1MessageChannel.html#06309e208fc5e10642a2e9bbe0f351eb">00146</a> <span class="keywordtype">void</span> <a class="code" href="classPassenger_1_1MessageChannel.html#06309e208fc5e10642a2e9bbe0f351eb" title="Close the underlying file descriptor.">close</a>() {
<a name="l00147"></a>00147 <span class="keywordflow">if</span> (fd != -1) {
-<a name="l00148"></a>00148 <span class="keywordtype">int</span> ret = syscalls::close(fd);
+<a name="l00148"></a>00148 <span class="keywordtype">int</span> ret = <a class="code" href="classPassenger_1_1MessageChannel.html#06309e208fc5e10642a2e9bbe0f351eb" title="Close the underlying file descriptor.">syscalls::close</a>(fd);
<a name="l00149"></a>00149 <span class="keywordflow">if</span> (ret == -1) {
<a name="l00150"></a>00150 <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 close file descriptor"</span>, errno);
<a name="l00151"></a>00151 }
<a name="l00152"></a>00152 fd = -1;
<a name="l00153"></a>00153 }
@@ -210,11 +215,11 @@
<a name="l00194"></a>00194 <span class="comment"> * @throws SystemException An error occured while writing the data to the file descriptor.</span>
<a name="l00195"></a>00195 <span class="comment"> * @throws boost::thread_interrupted</span>
<a name="l00196"></a>00196 <span class="comment"> * @pre None of the message elements may contain a NUL character (<tt>'\\0'</tt>).</span>
<a name="l00197"></a>00197 <span class="comment"> * @see read(), write(const char *, ...)</span>
<a name="l00198"></a>00198 <span class="comment"> */</span>
-<a name="l00199"></a><a class="code" href="classPassenger_1_1MessageChannel.html#9ad7a978cf8409e01ab2f0a2b6be5a0a">00199</a> <span class="keywordtype">void</span> <a class="code" href="classPassenger_1_1MessageChannel.html#150f68bc47e060dcc6ca35bee047914d" title="Send an array message, which consists of the given elements, over the underlying...">write</a>(<span class="keyword">const</span> list<string> &args) {
+<a name="l00199"></a><a class="code" href="classPassenger_1_1MessageChannel.html#9ad7a978cf8409e01ab2f0a2b6be5a0a">00199</a> <span class="keywordtype">void</span> <a class="code" href="classPassenger_1_1MessageChannel.html#9ad7a978cf8409e01ab2f0a2b6be5a0a" title="Send an array message, which consists of the given elements, over the underlying...">write</a>(<span class="keyword">const</span> list<string> &args) {
<a name="l00200"></a>00200 write<list<string>, list<string>::const_iterator>(args);
<a name="l00201"></a>00201 }
<a name="l00202"></a>00202 <span class="comment"></span>
<a name="l00203"></a>00203 <span class="comment"> /**</span>
<a name="l00204"></a>00204 <span class="comment"> * Send an array message, which consists of the given elements, over the underlying</span>
@@ -224,11 +229,11 @@
<a name="l00208"></a>00208 <span class="comment"> * @throws SystemException An error occured while writing the data to the file descriptor.</span>
<a name="l00209"></a>00209 <span class="comment"> * @throws boost::thread_interrupted</span>
<a name="l00210"></a>00210 <span class="comment"> * @pre None of the message elements may contain a NUL character (<tt>'\\0'</tt>).</span>
<a name="l00211"></a>00211 <span class="comment"> * @see read(), write(const char *, ...)</span>
<a name="l00212"></a>00212 <span class="comment"> */</span>
-<a name="l00213"></a><a class="code" href="classPassenger_1_1MessageChannel.html#6a9bc5d72715cb7ba0e437c8851ef487">00213</a> <span class="keywordtype">void</span> <a class="code" href="classPassenger_1_1MessageChannel.html#150f68bc47e060dcc6ca35bee047914d" title="Send an array message, which consists of the given elements, over the underlying...">write</a>(<span class="keyword">const</span> vector<string> &args) {
+<a name="l00213"></a><a class="code" href="classPassenger_1_1MessageChannel.html#6a9bc5d72715cb7ba0e437c8851ef487">00213</a> <span class="keywordtype">void</span> <a class="code" href="classPassenger_1_1MessageChannel.html#6a9bc5d72715cb7ba0e437c8851ef487" title="Send an array message, which consists of the given elements, over the underlying...">write</a>(<span class="keyword">const</span> vector<string> &args) {
<a name="l00214"></a>00214 write<vector<string>, vector<string>::const_iterator>(args);
<a name="l00215"></a>00215 }
<a name="l00216"></a>00216 <span class="comment"></span>
<a name="l00217"></a>00217 <span class="comment"> /**</span>
<a name="l00218"></a>00218 <span class="comment"> * Send an array message, which consists of the given strings, over the underlying</span>
@@ -240,11 +245,11 @@
<a name="l00224"></a>00224 <span class="comment"> * @throws SystemException An error occured while writing the data to the file descriptor.</span>
<a name="l00225"></a>00225 <span class="comment"> * @throws boost::thread_interrupted</span>
<a name="l00226"></a>00226 <span class="comment"> * @pre None of the message elements may contain a NUL character (<tt>'\\0'</tt>).</span>
<a name="l00227"></a>00227 <span class="comment"> * @see read(), write(const list<string> &)</span>
<a name="l00228"></a>00228 <span class="comment"> */</span>
-<a name="l00229"></a><a class="code" href="classPassenger_1_1MessageChannel.html#12cce3364023eacbe4fe09006cf3d38d">00229</a> <span class="keywordtype">void</span> <a class="code" href="classPassenger_1_1MessageChannel.html#150f68bc47e060dcc6ca35bee047914d" title="Send an array message, which consists of the given elements, over the underlying...">write</a>(<span class="keyword">const</span> <span class="keywordtype">char</span> *name, ...) {
+<a name="l00229"></a><a class="code" href="classPassenger_1_1MessageChannel.html#12cce3364023eacbe4fe09006cf3d38d">00229</a> <span class="keywordtype">void</span> <a class="code" href="classPassenger_1_1MessageChannel.html#12cce3364023eacbe4fe09006cf3d38d" title="Send an array message, which consists of the given strings, over the underlying file...">write</a>(<span class="keyword">const</span> <span class="keywordtype">char</span> *name, ...) {
<a name="l00230"></a>00230 list<string> args;
<a name="l00231"></a>00231 args.push_back(name);
<a name="l00232"></a>00232
<a name="l00233"></a>00233 va_list ap;
<a name="l00234"></a>00234 va_start(ap, name);
@@ -280,11 +285,11 @@
<a name="l00264"></a>00264 <span class="comment"> * @pre <tt>data != NULL</tt></span>
<a name="l00265"></a>00265 <span class="comment"> * @throws SystemException An error occured while writing the data to the file descriptor.</span>
<a name="l00266"></a>00266 <span class="comment"> * @throws boost::thread_interrupted</span>
<a name="l00267"></a>00267 <span class="comment"> * @see readScalar(), writeScalar(const string &)</span>
<a name="l00268"></a>00268 <span class="comment"> */</span>
-<a name="l00269"></a><a class="code" href="classPassenger_1_1MessageChannel.html#80977020ef895f3ea790c5d28a333dda">00269</a> <span class="keywordtype">void</span> <a class="code" href="classPassenger_1_1MessageChannel.html#44e01a783c48abadeea0d915b9893bfb" title="Send a scalar message over the underlying file descriptor.">writeScalar</a>(<span class="keyword">const</span> <span class="keywordtype">char</span> *data, <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> size) {
+<a name="l00269"></a><a class="code" href="classPassenger_1_1MessageChannel.html#80977020ef895f3ea790c5d28a333dda">00269</a> <span class="keywordtype">void</span> <a class="code" href="classPassenger_1_1MessageChannel.html#80977020ef895f3ea790c5d28a333dda" title="Send a scalar message over the underlying file descriptor.">writeScalar</a>(<span class="keyword">const</span> <span class="keywordtype">char</span> *data, <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> size) {
<a name="l00270"></a>00270 uint32_t l = htonl(size);
<a name="l00271"></a>00271 <a class="code" href="classPassenger_1_1MessageChannel.html#069314e4c7e1fe8c8ab36e16d2cc5fef" title="Send a block of data over the underlying file descriptor.">writeRaw</a>((<span class="keyword">const</span> <span class="keywordtype">char</span> *) &l, <span class="keyword">sizeof</span>(uint32_t));
<a name="l00272"></a>00272 <a class="code" href="classPassenger_1_1MessageChannel.html#069314e4c7e1fe8c8ab36e16d2cc5fef" title="Send a block of data over the underlying file descriptor.">writeRaw</a>(data, size);
<a name="l00273"></a>00273 }
<a name="l00274"></a>00274 <span class="comment"></span>
@@ -301,11 +306,11 @@
<a name="l00285"></a>00285 <span class="comment"> */</span>
<a name="l00286"></a><a class="code" href="classPassenger_1_1MessageChannel.html#069314e4c7e1fe8c8ab36e16d2cc5fef">00286</a> <span class="keywordtype">void</span> <a class="code" href="classPassenger_1_1MessageChannel.html#069314e4c7e1fe8c8ab36e16d2cc5fef" title="Send a block of data over the underlying file descriptor.">writeRaw</a>(<span class="keyword">const</span> <span class="keywordtype">char</span> *data, <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> size) {
<a name="l00287"></a>00287 ssize_t ret;
<a name="l00288"></a>00288 <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> written = 0;
<a name="l00289"></a>00289 <span class="keywordflow">do</span> {
-<a name="l00290"></a>00290 ret = syscalls::write(fd, data + written, size - written);
+<a name="l00290"></a>00290 ret = <a class="code" href="classPassenger_1_1MessageChannel.html#150f68bc47e060dcc6ca35bee047914d" title="Send an array message, which consists of the given elements, over the underlying...">syscalls::write</a>(fd, data + written, size - written);
<a name="l00291"></a>00291 <span class="keywordflow">if</span> (ret == -1) {
<a name="l00292"></a>00292 <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">"write() failed"</span>, errno);
<a name="l00293"></a>00293 } <span class="keywordflow">else</span> {
<a name="l00294"></a>00294 written += ret;
<a name="l00295"></a>00295 }
@@ -319,11 +324,11 @@
<a name="l00303"></a>00303 <span class="comment"> * @param data The data to send.</span>
<a name="l00304"></a>00304 <span class="comment"> * @pre <tt>data != NULL</tt></span>
<a name="l00305"></a>00305 <span class="comment"> * @throws SystemException An error occured while writing the data to the file descriptor.</span>
<a name="l00306"></a>00306 <span class="comment"> * @throws boost::thread_interrupted</span>
<a name="l00307"></a>00307 <span class="comment"> */</span>
-<a name="l00308"></a><a class="code" href="classPassenger_1_1MessageChannel.html#cfa38f4f0e22ec16350b8cc159e8e364">00308</a> <span class="keywordtype">void</span> <a class="code" href="classPassenger_1_1MessageChannel.html#069314e4c7e1fe8c8ab36e16d2cc5fef" title="Send a block of data over the underlying file descriptor.">writeRaw</a>(<span class="keyword">const</span> <span class="keywordtype">string</span> &data) {
+<a name="l00308"></a><a class="code" href="classPassenger_1_1MessageChannel.html#cfa38f4f0e22ec16350b8cc159e8e364">00308</a> <span class="keywordtype">void</span> <a class="code" href="classPassenger_1_1MessageChannel.html#cfa38f4f0e22ec16350b8cc159e8e364" title="Send a block of data over the underlying file descriptor.">writeRaw</a>(<span class="keyword">const</span> <span class="keywordtype">string</span> &data) {
<a name="l00309"></a>00309 <a class="code" href="classPassenger_1_1MessageChannel.html#069314e4c7e1fe8c8ab36e16d2cc5fef" title="Send a block of data over the underlying file descriptor.">writeRaw</a>(data.c_str(), data.size());
<a name="l00310"></a>00310 }
<a name="l00311"></a>00311 <span class="comment"></span>
<a name="l00312"></a>00312 <span class="comment"> /**</span>
<a name="l00313"></a>00313 <span class="comment"> * Pass a file descriptor. This only works if the underlying file</span>
@@ -395,11 +400,11 @@
<a name="l00379"></a>00379 uint16_t size;
<a name="l00380"></a>00380 <span class="keywordtype">int</span> ret;
<a name="l00381"></a>00381 <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> alreadyRead = 0;
<a name="l00382"></a>00382
<a name="l00383"></a>00383 <span class="keywordflow">do</span> {
-<a name="l00384"></a>00384 ret = syscalls::read(fd, (<span class="keywordtype">char</span> *) &size + alreadyRead, <span class="keyword">sizeof</span>(size) - alreadyRead);
+<a name="l00384"></a>00384 ret = <a class="code" href="classPassenger_1_1MessageChannel.html#129659b60d1a663337873d2af944431e" title="Read an array message from the underlying file descriptor.">syscalls::read</a>(fd, (<span class="keywordtype">char</span> *) &size + alreadyRead, <span class="keyword">sizeof</span>(size) - alreadyRead);
<a name="l00385"></a>00385 <span class="keywordflow">if</span> (ret == -1) {
<a name="l00386"></a>00386 <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);
<a name="l00387"></a>00387 } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (ret == 0) {
<a name="l00388"></a>00388 <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l00389"></a>00389 }
@@ -410,11 +415,11 @@
<a name="l00394"></a>00394 <span class="keywordtype">string</span> buffer;
<a name="l00395"></a>00395 args.clear();
<a name="l00396"></a>00396 buffer.reserve(size);
<a name="l00397"></a>00397 <span class="keywordflow">while</span> (buffer.size() < size) {
<a name="l00398"></a>00398 <span class="keywordtype">char</span> tmp[1024 * 8];
-<a name="l00399"></a>00399 ret = syscalls::read(fd, tmp, min(size - buffer.size(), <span class="keyword">sizeof</span>(tmp)));
+<a name="l00399"></a>00399 ret = <a class="code" href="classPassenger_1_1MessageChannel.html#129659b60d1a663337873d2af944431e" title="Read an array message from the underlying file descriptor.">syscalls::read</a>(fd, tmp, min(size - buffer.size(), <span class="keyword">sizeof</span>(tmp)));
<a name="l00400"></a>00400 <span class="keywordflow">if</span> (ret == -1) {
<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);
<a name="l00402"></a>00402 } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (ret == 0) {
<a name="l00403"></a>00403 <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l00404"></a>00404 }
@@ -485,11 +490,11 @@
<a name="l00469"></a><a class="code" href="classPassenger_1_1MessageChannel.html#cd1d1bd1cc787784c8b54f5471fff479">00469</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) {
<a name="l00470"></a>00470 ssize_t ret;
<a name="l00471"></a>00471 <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> alreadyRead = 0;
<a name="l00472"></a>00472
<a name="l00473"></a>00473 <span class="keywordflow">while</span> (alreadyRead < size) {
-<a name="l00474"></a>00474 ret = syscalls::read(fd, (<span class="keywordtype">char</span> *) buf + alreadyRead, size - alreadyRead);
+<a name="l00474"></a>00474 ret = <a class="code" href="classPassenger_1_1MessageChannel.html#129659b60d1a663337873d2af944431e" title="Read an array message from the underlying file descriptor.">syscalls::read</a>(fd, (<span class="keywordtype">char</span> *) buf + alreadyRead, size - alreadyRead);
<a name="l00475"></a>00475 <span class="keywordflow">if</span> (ret == -1) {
<a name="l00476"></a>00476 <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);
<a name="l00477"></a>00477 } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (ret == 0) {
<a name="l00478"></a>00478 <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l00479"></a>00479 } <span class="keywordflow">else</span> {
@@ -623,10 +628,10 @@
<a name="l00607"></a>00607
<a name="l00608"></a>00608 } <span class="comment">// namespace Passenger</span>
<a name="l00609"></a>00609
<a name="l00610"></a>00610 <span class="preprocessor">#endif </span><span class="comment">/* _PASSENGER_MESSAGE_CHANNEL_H_ */</span>
</pre></div></div>
-<hr size="1"><address style="text-align: right;"><small>Generated on Tue Mar 31 14:00:28 2009 for Passenger by
+<hr size="1"><address style="text-align: right;"><small>Generated on Wed Apr 8 22:35:10 2009 for Passenger by
<a href="http://www.doxygen.org/index.html">
-<img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5.5 </small></address>
+<img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5.8 </small></address>
</body>
</html>