-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Change behaviour of sendfile(2) on FreeBSD to mimic Linux #18
Conversation
An excerpt from
|
Hi! I thought this project is dead, but got an email from github showing me it's not dead completely. Why this patch is without response for 2 years? |
Lack of time. I plan to go through the pull requests "soon". |
@sionescu any update? |
@shamazmazum are you okay if I submit the patch to FreeBSD ports tree? |
@shiorid Sounds great! |
@sionescu Just checked, you actually closed my PR and pushed some shit which does not fix the problem. What's wrong with you? Spent some time to figure why my shitty HTML server does not work. Turns out my patch just disappeared. @shiorid Are you a maintainer of libfixposix in the ports tree? Can you push my version? Check the manual if in doubt. |
@sionescu If you simply do not have time, I can be a maintainer. But just closing a PR and replacing a fix with something else is not OK. |
@shamazmazum If my change is faulty, please let me know why and I'll fix it. |
Yes, I'm the maintainer and will submit the changes to public review (since I'm not a committer). Any way, I'm not a great C programmer, so could you confirm if the problem on the upstreamed “fix” lives here?
|
I wrote specially about
This is your repository after all, you can do whatever you wish. |
My original patch was:
|
The usual semantics of EAGAIN is that no I/O was performed because the operation would have blocked. You mean that on FreeBSD that's not the case ? |
Exactly. See here or in my second comment. In FreeBSD |
@shamazmazum thank you for the explanation. Since 0.5.0 is not yet released, I'll cherry-pick your fix and bump the revision in ports tree. Thank you for letting me know. |
I've committed cc50634. |
Thanks. I can confirm that it works now. |
Not if I was interested, but are you sure that |
The official man page says so:
|
Oh, OK. Thanks |
BTW, you did it incorrect again. Look at my patch:
and at what you did:
Don't you see a corner case? Hint: look what happens when |
The purpose of lfp_sendfile() is to emulate the semantics of the Linux sendfile(), which are as follows:
In other words, the current treatment of EAGAIN with sbytes==0 is correct, and it's what I meant. Your patch was incorrect. |
OK, I am wrong, sorry. It wasn't clear for me what is considered a successful transfer on Linux (see here):
I thought transfering zero bytes can also be considered successful (it's not clear then, in what cases |
hey, just to make you know, the fix is on ports tree. Cheers! |
@shamazmazum a return of 0 means EOF. |
Hi!
I think it would be a great idea to change
lfp_sendfile
on FreeBSD and derivatives so it returns number of bytes sent, not just 0 or -1. As manual says, this is exactly what Linux'es sendfile does.Also I think there is no need to treat
EAGAIN
as an error because, unlike withwrite
orsend
, it is an usual error code thatsendfile
returns even if a file is partially sent.Finally, I remove obsolete
SF_MNOWAIT
flag.