-
Notifications
You must be signed in to change notification settings - Fork 247
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
Fixed pid wrapping in sss_cli_check_socket #6616
Conversation
What is the difference with #6608? |
src/sss_client/common.c
Outdated
sss_cli_close_socket(); | ||
} | ||
} | ||
sss_cli_sd = -1; | ||
mypid = getpid(); | ||
ret = lstat("/proc/self/", &selfsb); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi,
you already have all the data in myself_sb
so, not need to call lstat()
again. And I think it would be good if you can to the same with the pid and avoid calling getpid()
twice..
bye,
Sumit
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi,
My issue is: #6592
I do not know the use of mypid
, but mypid
causes this issue. so I imitate the writing method of mypid
and add the selfsb
and myself_sb
to reduce the probability of problems caused by pid loopback.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi,
yes, I understand this. However, currently getpid()
and with your patch lstat()
as well are called twice to get the same information. Since those are system-call both need some time to execute and since the second call is redundant it would help to avoid it.
The getpid()
related code it quite old and at the time it was written it might have even been cheap because glibc had a pid cache which helped to avoid a system-call. But this changed are there is currently also no alternatives, e.g. as a vDSO call, available, see e.g. https://bugzilla.redhat.com/show_bug.cgi?id=1469757 and the links in the ticket for details. I wasn't aware of this until reviewing your patch as well and thought that since your patch touched this area of the code it can be improved as part of your patch.
If @alexey-tikhonov, agrees we can keep your patch as it is but open a new ticket to remove the second getpid() and
lstat()` call in a separate PR. But feel free to do the change yourself.
bye,
Sumit
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice catch. I think at least 2nd lstat()
can be avoided within this patch.
Also I think we should really consider per-transaction sockets, as you proposed in other ticket...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks, I see. The redundant second call will be deleted.
…eck_socket() the second call to getpid() and lstat() is redundant.
Thanks, ACK. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi,
thanks for the update, ACK.
bye,
Sumit
Resolves: #6592