<div dir="ltr"><div><div><div><div>Sujay, <br><br></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><br></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><br></div>do you think is possible to do that on RTEMS ?<br><br></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">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"><span class=""><br>
<br>
On 6/23/2015 12:49 PM, Sujay Raj wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
I am working on porting Monkey HTTP server on rtems.<br>
<br>
Sendfile is not specified in POSIX.1-2001 or other standards and its implementations vary depending on the unix/linux system being used.<br>
<br>
Freebsd has sendfile in its libc.<br>
</blockquote>
<br></span>
FreeBSD has a completely different API for sendfile(). Plus the source<br>
must be a regular file and the destination a socket.<br>
<br>
<a href="https://www.freebsd.org/cgi/man.cgi?query=sendfile&sektion=2" rel="noreferrer" target="_blank">https://www.freebsd.org/cgi/man.cgi?query=sendfile&sektion=2</a><br>
<br>
This is a random discussion of sendfile() on various OSes. It mentions<br>
the assumption that the source must normally be able to be mmap'ed.<br>
Since you can't do that on RTEMS, you are stuck with a loop<br>
implementation. [1]<br>
<br>
<a href="https://groups.google.com/forum/#!topic/comp.unix.programmer/65oDSzpEzx8" rel="noreferrer" target="_blank">https://groups.google.com/forum/#!topic/comp.unix.programmer/65oDSzpEzx8</a><span class=""><br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
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>
</blockquote>
<br></span>
Given that (a) it is not POSIX and (b) there is no agreement between<br>
Linux and FreeBSD, it is highly unlikely newlib would accept an<br>
implementation.<br>
<br>
Given (b), I don't personally see merging it into RTEMS since we<br>
have to pick a winner and loser on the API.<br>
<br>
What's the feeling on having a default implementation in Monkey and<br>
using that as a backup? With [1] as a consideration again.<br>
<br>
<br>
[1] The size of the buffer user for read/write has to be accounted<br>
for. If this is on a thread stack, then it can't be too large or that<br>
imposes a burden on calling sendfile(). I can see an implementation<br>
doing a malloc() of the buffer and then free()'ing it.<div class="HOEnZb"><div class="h5"><br>
<br>
<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
cc to Joel and Eduardo.<br>
<br>
Thanks and Regards,<br>
Sujay Raj<br>
</blockquote>
<br></div></div><span class="HOEnZb"><font color="#888888">
-- <br>
Joel Sherrill, Ph.D. Director of Research & Development<br>
joel.sherrill@OARcorp.com On-Line Applications Research<br>
Ask me about RTEMS: a free RTOS Huntsville AL 35805<br>
Support Available <a href="tel:%28256%29%20722-9985" value="+12567229985" target="_blank">(256) 722-9985</a><br>
</font></span></blockquote></div><br><br clear="all"><br>-- <br><div class="gmail_signature"><div dir="ltr">Eduardo Silva<div>Monkey Software</div></div></div>
</div>