[CRIU] Re: [PATCH] service-fd: Rework it to use in hight performance code

Pavel Emelyanov xemul at parallels.com
Fri Sep 7 08:57:54 EDT 2012


On 09/07/2012 04:44 PM, Cyrill Gorcunov wrote:
> On Fri, Sep 07, 2012 at 04:38:21PM +0400, Pavel Emelyanov wrote:
>>> +
>>> +int is_service_fd(int fd, int type)
>>> +{
>>> +	if (type > SERVICE_FD_OFF_MIN)
>>> +		return fd == get_service_fd(type);
>>> +
>>> +	return fd > service_fd_rlim_min;
>>
>> int is_service_fd(int fd)
>> {
>> 	return fd > serice_fd_rlim_cur - SERVICE_FD_OFF_MAX;
>> }
>>
> 
> Pavel, this is not enough for my tty restore code. For control
> terminals I need to know that fd _is_ CTL_TTY_OFF, not just arbitrary
> fd from service range. What happen when we need some other service fd
> in file engine?
> 
> Lets do a deal: two helpers
> 
> is_any_service_fd(int fd)
> {
> 	return fd > serice_fd_rlim_cur - SERVICE_FD_OFF_MAX;
> }
> 
> is_service_fd(int fd, int type)
> {
> 	return fd == get_service_fd(type);
> }
> 
> agreed?

No. You want to have an ability to check that fd is any service by
passing 0 into type? Then write a normal comment about it, not some
strange hint about "change this MIN carefully".

And there's no need in TWO global variables _cur and _min.

> .
> 



More information about the CRIU mailing list