<html><head><style> body {height: 100%; color:#000000; font-size:12pt; font-family:arial,helvetica,sans-serif;}</style></head><body><div>I would use the sendfile system call implementation from FreeBSD and add it to the libbsd. Its not a big win if you use read() and write() to implement sendfile().  This makes only sense if you can use kernel space zero-copy buffers.<br></div><div><br></div><div>----- Eduardo Silva <eduardo@monkey.io> schrieb:<br>></div><div dir="ltr"><div><div><div><div>Sujay, <br><div><br></div></div>Monkey use conditionals for each implementation: Linux, FreeBSD and OSX. My suggestion is that RTEMS may implement a sendfile based on FreeBSD format which can easily be emulated as a read() and further write() for socket operations. That will help not only Monkey, but also other software that requires such interface.<br><div><br></div></div>I am not the best one to talk about RTEMS, but the Kernel always knows better it buffers capacity that the program on the other side.<br><div><br></div></div>do you think is possible to do that on RTEMS ?<br><div><br></div></div>regards, <br></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Jun 23, 2015 at 12:05 PM, Joel Sherrill <span dir="ltr"><<a href="mailto:joel.sherrill@oarcorp.com" target="_blank" data-mce-href="mailto:joel.sherrill@oarcorp.com">joel.sherrill@oarcorp.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin: 0 0 0 .8ex; border-left: 1px #ccc solid; padding-left: 1ex;" data-mce-style="margin: 0 0 0 .8ex; border-left: 1px #ccc solid; padding-left: 1ex;"><span class=""><span class=""><br></span></span><div><br></div><span class=""><span class="">><br></span></span><div><br></div><span class=""><span class="">> On 6/23/2015 12:49 PM, Sujay Raj wrote:<br></span></span><div><br></div><span class=""><span class="">></span></span><blockquote class="gmail_quote" style="margin: 0 0 0 .8ex; border-left: 1px #ccc solid; padding-left: 1ex;" data-mce-style="margin: 0 0 0 .8ex; border-left: 1px #ccc solid; padding-left: 1ex;"><br>> I am working on porting Monkey HTTP server on rtems.<br><div><br></div>><br><div><br></div>> Sendfile is not specified in POSIX.1-2001 or other standards and its implementations vary depending on the unix/linux system being used.<br><div><br></div>><br><div><br></div>> Freebsd has sendfile in its libc.<br><div><br></div>></blockquote><span class=""><br>><br></span><br>> FreeBSD has a completely different API for sendfile(). Plus the source<br><div><br></div>> must be a regular file and the destination a socket.<br><div><br></div>><br><div><br></div>><a href="https://www.freebsd.org/cgi/man.cgi?query=sendfile&sektion=2" rel="noreferrer" target="_blank" data-mce-href="https://www.freebsd.org/cgi/man.cgi?query=sendfile&sektion=2">https://www.freebsd.org/cgi/man.cgi?query=sendfile&sektion=2</a><br><div><br></div>><br><div><br></div>> This is a random discussion of sendfile() on various OSes. It mentions<br><div><br></div>> the assumption that the source must normally be able to be mmap'ed.<br><div><br></div>> Since you can't do that on RTEMS, you are stuck with a loop<br><div><br></div>> implementation. [1]<br><div><br></div>><br><div><br></div>><a href="https://groups.google.com/forum/#!topic/comp.unix.programmer/65oDSzpEzx8" rel="noreferrer" target="_blank" data-mce-href="https://groups.google.com/forum/#!topic/comp.unix.programmer/65oDSzpEzx8">https://groups.google.com/forum/#!topic/comp.unix.programmer/65oDSzpEzx8</a><span class=""><span class=""><br></span></span><div><br></div><span class=""><span class="">><br></span></span><div><br></div><span class=""><span class="">></span></span><blockquote class="gmail_quote" style="margin: 0 0 0 .8ex; border-left: 1px #ccc solid; padding-left: 1ex;" data-mce-style="margin: 0 0 0 .8ex; border-left: 1px #ccc solid; padding-left: 1ex;"><br>> So I opened this thread to discuss how should we proceed with this matter, if we should work on getting sendfile in newlib, or if there is any portable solution that we can use in its place.<br><div><br></div>></blockquote><span class=""><br>><br></span><br>> Given that (a) it is not POSIX and (b) there is no agreement between<br><div><br></div>> Linux and FreeBSD, it is highly unlikely newlib would accept an<br><div><br></div>> implementation.<br><div><br></div>><br><div><br></div>> Given (b), I don't personally see merging it into RTEMS since we<br><div><br></div>> have to pick a winner and loser on the API.<br><div><br></div>><br><div><br></div>> What's the feeling on having a default implementation in Monkey and<br><div><br></div>> using that as a backup? With [1] as a consideration again.<br><div><br></div>><br><div><br></div>><br><div><br></div>> [1] The size of the buffer user for read/write has to be accounted<br><div><br></div>> for. If this is on a thread stack, then it can't be too large or that<br><div><br></div>> imposes a burden on calling sendfile(). I can see an implementation<br><div><br></div>> doing a malloc() of the buffer and then free()'ing it.<div class="HOEnZb"><div class="h5"><br><div><br></div>><br><div><br></div>><br><div><br></div>>  <br><div><br></div>><blockquote class="gmail_quote" style="margin: 0 0 0 .8ex; border-left: 1px #ccc solid; padding-left: 1ex;" data-mce-style="margin: 0 0 0 .8ex; border-left: 1px #ccc solid; padding-left: 1ex;"><br>> cc to Joel and Eduardo.<br><div><br></div>><br><div><br></div>> Thanks and Regards,<br><div><br></div>> Sujay Raj<br><div><br></div>></blockquote><br>><br></div></div><span class="HOEnZb"><span class="HOEnZb"><span style="color: #888888;" data-mce-style="color: #888888;" color="#888888"><br>> -- <br></span></span></span><div><br></div><span class="HOEnZb"><span class="HOEnZb"><span style="color: #888888;" data-mce-style="color: #888888;" color="#888888">> Joel Sherrill, Ph.D.             Director of Research & Development<br></span></span></span><div><br></div><span class="HOEnZb"><span class="HOEnZb"><span style="color: #888888;" data-mce-style="color: #888888;" color="#888888">> joel.sherrill@OARcorp.com        On-Line Applications Research<br></span></span></span><div><br></div><span class="HOEnZb"><span class="HOEnZb"><span style="color: #888888;" data-mce-style="color: #888888;" color="#888888">> Ask me about RTEMS: a free RTOS  Huntsville AL 35805<br></span></span></span><div><br></div><span class="HOEnZb"><span class="HOEnZb"><span style="color: #888888;" data-mce-style="color: #888888;" color="#888888">> Support Available                <a href="tel:%28256%29%20722-9985" target="_blank" data-mce-href="tel:%28256%29%20722-9985">(256) 722-9985</a><br></span></span></span><div><br></div><span class="HOEnZb"><span style="color: #888888;" data-mce-style="color: #888888;" color="#888888">></span></span></blockquote></div><br><br clear="all"><br>-- <br><div class="gmail_signature"><div dir="ltr">Eduardo Silva<div>Monkey Software</div></div></div><br>></div><div><br></div><div><br></div><div>-- <br></div><div><pre>Sebastian Huber, embedded brains GmbH<br></pre><div><br></div><pre>Address : Dornierstr. 4, D-82178 Puchheim, Germany<br>Phone   : +49 89 189 47 41-16<br>Fax     : +49 89 189 47 41-09<br>E-Mail  : <a href="http://lists.rtems.org/mailman/listinfo/devel" data-mce-href="http://lists.rtems.org/mailman/listinfo/devel">sebastian.huber at embedded-brains.de</a><br>PGP     : Public key available on request.<br></pre><div><br></div><pre>Diese Nachricht ist keine geschäftliche Mitteilung im Sinne des EHUG.</pre></div></body></html>