-
Notifications
You must be signed in to change notification settings - Fork 298
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
Bug-Fix for invalid file descriptor validation and missing timeout in unix socket poll #281
Conversation
I am wondering a bit about this. Why is it needed? And I assume you mean UNIX/VSOCK and not TCP sockets...? (Just happened to notice this pr and thought I would ask, since I added VSOCK support recently. I also change the timeout to be -1 unconditionally in #268 .) |
Also note that timeout is (500 * 10^(6-3) / 3600)s ~= 138.8h for FIFOs, so effectively might as well have -1. So it is not really needed for FIFO:s either? |
I do mean UNIX/VSOCK. We had an issue on qnx where not setting this timeout would lead to blocking the thread in certain situations which lead to missing logs. |
Can we make sure that a poll is returning if a connection is gone on all supported systems like qnx and linux or is it better to set a reasonable timeout for example for 1s to make sure this always returns? |
Hum, I wonder what could make it "block" here and lead to missing messages. Messages are all received on the fd that is I noticed #253 a while back. Perhaps there is a race here and the wrong fd ends up being polled? |
The poll timeout was only set for fifo. TCP connections require this timeout as well. dlt_user_log_check_user_message also validated the file descriptor to be greater 0. Because 0 is a valid file descriptor this check has been changed to greater or equal 0. poll receives a timeout in milliseconds. The given paramter was in nanoseconds. An additional define takes adds the delay in miliseconds. Signed-off-by: Alexander Mohr <[email protected]>
Some functions validated file descriptor to be greater 0. If a process is started without stdin, stdout and stderr the first file descriptor allocated by the process will be 0. This also will be the case if the above mentioned file descriptors will be closed on purpose. As 0 is a valid fd, some methods had to be changed to reflect this. Signed-off-by: Alexander Mohr <[email protected]>
1f1e544
to
5a73b99
Compare
I've changed the timeout to 1s for now. I'm trying to find out if we can omit this timeout in general. I'll get back to as soon as I know more. |
Let's assume the following scenario: Setting this timeout makes sure we always exit from this method and retry after the sleep in the housekeeper thread for example. What's your argument to omit this timeout? |
@alexander-mohr @martin-ejdestig I assume you're correct; some timeout value needs to be set on poll. |
Sounds great. We are also using a timeout of 500ms which seems kind of reasonable. But it's great that you are doing measurements to find the correct timeout. |
Ah, |
@alexander-mohr After our performance measurement, I suppose setting to 500msec looks good. So prefer the changes you made before to use DLT_USER_RECEIVE_MDELAY. If you agree, can you update as such? Thanks. |
Changed the poll timeout to 500ms after performance measurements resulted this as a good compromise. Introduced a define which is used in poll. Signed-off-by: Alexander Mohr <[email protected]>
I've changed the code accordingly. Sorry for the late reply due to Christmas and new year. |
The changes were merged to master branch manually. Closing this PR. |
The poll timeout was only set for fifo.
TCP connections require this timeout as well.
Poll receives a timeout in milliseconds.
The given paramter was in nanoseconds.
An additional define adds the delay in miliseconds.
Some functions validated file descriptor to be greater 0.
If a process is started without stdin, stdout and stderr
the first file descriptor allocated by the process will be 0.
This also will be the case if the above mentioned file descriptors
will be closed on purpose.
As 0 is a valid fd, some methods had to be changed to reflect this.
The program was tested solely for our own use cases, which might differ from yours.
Licensed under Mozilla Public License Version 2.0
Alexander Mohr, [email protected], Daimler TSS GmbH, imprint