Branch: Tag:

2010-11-19

2010-11-19 11:21:31 by Henrik Grubbström (Grubba) <grubba@grubba.org>

Added Stdio.File()->{send,receive}_fd().

File descriptors may now be sent and received over UNIX-domain sockets.

937:   </td></tr>   <tr><td><code><code class='key'>PROP_BIDIRECTIONAL</code></code></td><td><p>The resulting pipe is bi-directional.</p>   </td></tr> - <tr><td><code><code class='key'>PROP_SEND_FD</code></code></td><td><p>The resulting pipe might support sending of file descriptors.</p> + <tr><td><code><code class='key'>PROP_SEND_FD</code></code></td><td><p>The resulting pipe might support sending of file descriptors +  (see <code>send_fd()</code> and <code>receive_fd()</code> for details).</p>   </td></tr>   <tr><td><code><code class='key'>PROP_REVERSE</code></code></td><td><p>The resulting pipe supports communication "backwards" (but    not necessarily "forwards", see <code>PROP_BIDIRECTIONAL</code>).</p>
956:    same as calling it with no arguments.</p>   </dd>   <dt class='head--doc'>See also</dt> - <dd class='body--doc'><p><code>Process.create_process()</code>, + <dd class='body--doc'><p><code>Process.create_process()</code>, <code>send_fd()</code>, <code>receive_fd()</code>,    <code>PROP_IPC</code>, <code>PROP_NONBLOCK</code>, <code>PROP_SEND_FD</code>,    <code>PROP_SHUTDOWN</code>, <code>PROP_BUFFERED</code>, <code>PROP_REVERSE</code>,    <code>PROP_BIDIRECTIONAL</code></p>
1214:   <hr />   <dl class='group--doc'>   <dt class='head--type'><span class='homogen--type'>Method</span> + <span class='homogen--name'><b>receive_fd</b></span> + </dt> + <dd><p><code><code class='datatype'>void</code> <b><span class='method'>receive_fd</span>(</b><code class='object unresolved'>Stdio.Fd</code> <code class='argument'>fd</code><b>)</b></code></p></dd> +  + <dt class='head--doc'>Description</dt> + <dd class='body--doc'><p>Remote file descriptor reception handler.</p> + </dd> + <dt class='head--doc'><span id='p-fd'></span>Parameter <code class='parameter'>fd</code></dt> + <dd></dd><dd class='body--doc'><p>File descriptor received from the remote end of a <code>pipe()</code>. +  This object has been created by <code>fd_factory()</code>.</p> + <p> This function is called from <code>read()</code> when a remote file +  descriptor has been received over a <code>PROP_SEND_FD</code> +  capable <code>pipe()</code>.</p> + <p> The default implementation is just a prototype.</p> + <p> Overload this function to enable reception of +  remote file descriptors.</p> + </dd> + <dt class='head--doc'>Note</dt> + <dd class='body--doc'><p>The capability of sending and receiving remote file +  descriptors is only available on some operating systems. +  This capability is indicated by the precence of <code>__HAVE_SEND_FD__</code>.</p> + </dd> + <dt class='head--doc'>See also</dt> + <dd class='body--doc'><p><code>send_fd()</code>, <code>read()</code>, <code>fd_factory()</code>, <code>__HAVE_SEND_FD__</code></p> + </dd></dl> +  +  + <hr /> + <dl class='group--doc'> + <dt class='head--type'><span class='homogen--type'>Method</span>   <span class='homogen--name'><b>release_fd</b></span>   </dt>   <dd><p><code><code class='datatype'>int</code> <b><span class='method'>release_fd</span>(</b><b>)</b></code></p></dd>
1273:   <hr />   <dl class='group--doc'>   <dt class='head--type'><span class='homogen--type'>Method</span> + <span class='homogen--name'><b>send_fd</b></span> + </dt> + <dd><p><code><code class='datatype'>void</code> <b><span class='method'>send_fd</span>(</b><code class='object unresolved'>Stdio.Fd</code> <code class='argument'>fd</code><b>)</b></code></p></dd> +  + <dt class='head--doc'>Description</dt> + <dd class='body--doc'><p>Queues an open file descriptor for sending to the other end of a stream.</p> + </dd> + <dt class='head--doc'>Note</dt> + <dd class='body--doc'><p>The actual sending is performed at the next successful call +  to <code>write()</code>, this is due to limitations in the system calls. +  This means that it isn't possible to send a file descriptor +  without also sending some in-band data.</p> + <p> This operation is only supported on <code>pipe()</code>'s created with +  <code>PROP_SEND_FD</code>.</p> + <p> This function is not available on all operating systems, check +  for <code>__HAVE_SEND_FD__</code>.</p> + <p> The queue is emptied on successful <code>write()</code> and when the +  write direction is <code>close()</code>'d.</p> + </dd> + <dt class='head--doc'>See also</dt> + <dd class='body--doc'><p><code>receive_fd()</code>, <code>write()</code>, <code>pipe()</code>, <code>read()</code>, <code>__HAVE_SEND_FD__</code></p> + </dd></dl> +  +  + <hr /> + <dl class='group--doc'> + <dt class='head--type'><span class='homogen--type'>Method</span> + <span class='homogen--name'><b>send_fd</b></span> + </dt> + <dd><p><code><code class='datatype'>bool</code> <b><span class='method'>send_fd</span>(</b><code class='object unresolved'>File</code>|<code class='object unresolved'>Fd</code> <code class='argument'>file</code><b>)</b></code></p></dd> + </dl> +  +  + <hr /> + <dl class='group--doc'> + <dt class='head--type'><span class='homogen--type'>Method</span>   <span class='homogen--name'><b>set_backend</b></span>   </dt>   <dd><p><code><code class='datatype'>void</code> <b><span class='method'>set_backend</span>(</b><code class='object unresolved'>Pike.Backend</code> <code class='argument'>backend</code><b>)</b></code></p></dd>
1909:   <p> If more than one argument is given, <code>sprintf()</code> is used to format    them using <code>format</code>. If <code>format</code> is an array, the strings in it    are concatenated and the result is used as format string.</p> + <p> If there are any file descriptors that have been queued for sending +  (with <code>send_fd()</code>), they will be sent.</p>   </dd>   <dt class='head--doc'>Note</dt>   <dd class='body--doc'><p>Writing of wide strings is not supported. You have to encode the
1916:    charsets supported by <code>Locale.Charset.encoder</code>.</p>   </dd>   <dt class='head--doc'>See also</dt> - <dd class='body--doc'><p><code>read()</code>, <code>write_oob()</code></p> + <dd class='body--doc'><p><code>read()</code>, <code>write_oob()</code>, <code>send_fd()</code></p>   </dd></dl>      
4447:   <dd><p><code><code class='datatype'>constant</code> <code class='datatype'>int</code> Stdio.<code class='constant'>PROP_SEND_FD</code></code></p></dd>      <dt class='head--doc'>Description</dt> - <dd class='body--doc'><p>The <code>Stdio.File</code> object might support sending of open -  file descriptors.</p> + <dd class='body--doc'><p>The <code>Stdio.File</code> object might support the <code>Stdio.File()-&gt;send_fd()</code> +  operation.</p>   </dd>   <dt class='head--doc'>See also</dt> - <dd class='body--doc'><p><code>Stdio.File()-&gt;pipe()</code></p> + <dd class='body--doc'><p><code>Stdio.File()-&gt;pipe()</code>, <code>Stdio.File()-&gt;send_fd()</code>, +  <code>Stdio.File()-&gt;receive_fd()</code></p>   </dd></dl>      
4555:   <hr />   <dl class='group--doc'>   <dt class='head--type'><span class='homogen--type'>Constant</span> + <span class='homogen--name'><b>__HAVE_SEND_FD__</b></span> + </dt> + <dd><p><code><code class='datatype'>constant</code> Stdio.<code class='constant'>__HAVE_SEND_FD__</code></code></p></dd> +  + <dt class='head--doc'>Description</dt> + <dd class='body--doc'><p>Support for sending of file descriptors over +  <code>Stdio.File()-&gt;pipe()</code> objects with <code>PROP_SEND_FD</code> +  capability is supported.</p> + </dd> + <dt class='head--doc'>See also</dt> + <dd class='body--doc'><p><code>Stdio.File()-&gt;send_fd()</code>, <code>Stdio.File()-&gt;receive_fd()</code>, +  <code>Stdio.File()-&gt;read()</code>, <code>Stdio.File()-&gt;write()</code>, +  <code>Stdio.File()-&gt;pipe()</code></p> + </dd></dl> +  +  + <hr /> + <dl class='group--doc'> + <dt class='head--type'><span class='homogen--type'>Constant</span>   <span class='homogen--name'><b>__OOB__</b></span>   </dt>   <dd><p><code><code class='datatype'>constant</code> Stdio.<code class='constant'>__OOB__</code></code></p></dd>