-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
handle EINTR when using read()/write() #729
base: devel
Are you sure you want to change the base?
Conversation
I think the caller should be responsible for the while loop. its just a wrapper. |
For now g_file_read/g_file_write callers do not handle EINTR/EAGAIN. I agree that EAGAIN should be handled by caller, but EINTR must be handled every time, so less code if it moved to wrapper. |
It makes sense keeping |
May be, but in some way it must be handled. I would have a case in web server where EINTR occurred even when we do not send any signals to process (may be some daemon do). So its real danger not to handle EINTR. |
@speidy What do you think of #729 (comment)? |
Any update on it? I look how it handled in FreeRDP. It uses BIO_read functions from openssl winch handles EINTR and several other errors in BIO_fd_should_retry->BIO_fd_non_fatal_error. So I think it's normal to handle it in wrapper. |
I'll make some change based on your commit. |
These functions are for read and write to a file. This has nothing to do with openssl read and write for the socket. |
Yeah, |
BIO interface is universal, it supports regular files in bss_fd.c and bss_file.c. So, not a big difference about wrapper discussion. About why it helps #728, seems file IO error somewhere leads to something that reflects on ssl stream handling. |
@jsorg71 it's OK for you to merge this as-is? |
Note that there can be more places without handled EINTR, not only for read()\write() for example, but for other syscalls like open(). Closer look needed. |
One example of how handling EINTR in os_calls.c can be undesired is if a file read is blocking forever and someone sends a term signal to xrdp. Currently, the read would break, that thread loop would go around, see that is_term is set, and process would exit. If we handle EINTR is os_calls.c, xrdp would not close down when receiving the term signal until the read is done, which might be never. |
coughNFScough |
Yes, its a problem. For correct SIGTERM we must handle EINTR in every use place and make correct thread shutdown chain. Or possible solution for this is to handle SIGTERM in main thread (and do not use blocking calls from it), and handle possible "unclean" shutdown of stuck threads (or create separate watchdog thread, so main thread can use blocking IO). Btw openssl BIO stuck forever too in this case, so, it may stuck in 3rd party libs anyway. |
Code which uses g_file_read/g_file_write do not handle EINTR. To make code signal safe we need handle it within them.