files: Unify clone_service_fd()

Submitted by Kirill Tkhai on Jan. 26, 2017, 9:58 a.m.

Details

Message ID 148542471400.31698.1907433487371395225.stgit@localhost.localdomain
State Accepted
Series "files: Unify clone_service_fd()"
Commit 6786a87869d879f66ac444a6f4af25060928b516
Headers show

Commit Message

Kirill Tkhai Jan. 26, 2017, 9:58 a.m.
Make this function more generic: we want to dup not only
transport socket of parent, but just all service fds, which
were not opened at the moment of clone() in parent. But,
yes, currently it's only transport socket.

Signed-off-by: Kirill Tkhai <ktkhai@virtuozzo.com>
---
 criu/util.c |    5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

Patch hide | download patch | download mbox

diff --git a/criu/util.c b/criu/util.c
index fa1d74965..96b9e95d6 100644
--- a/criu/util.c
+++ b/criu/util.c
@@ -481,11 +481,10 @@  int clone_service_fd(int id)
 		return 0;
 
 	for (i = SERVICE_FD_MIN + 1; i < SERVICE_FD_MAX; i++) {
-		int old = __get_service_fd(i, service_fd_id);
+		int old = get_service_fd(i);
 		int new = __get_service_fd(i, id);
 
-		/* Do not dup parent's transport fd */
-		if (i == TRANSPORT_FD_OFF)
+		if (old < 0)
 			continue;
 		ret = dup2(old, new);
 		if (ret == -1) {

Comments

Andrey Vagin Jan. 30, 2017, 10:23 p.m.
On Thu, Jan 26, 2017 at 12:58:43PM +0300, Kirill Tkhai wrote:
> Make this function more generic: we want to dup not only
> transport socket of parent, but just all service fds, which
> were not opened at the moment of clone() in parent. But,
> yes, currently it's only transport socket.

But, no, ...
Now this function clones all descriptros except a transport socket.

c7eeef23e40cd5038ff69bb91d4b987388e3bfff

> 
> Signed-off-by: Kirill Tkhai <ktkhai@virtuozzo.com>
> ---
>  criu/util.c |    5 ++---
>  1 file changed, 2 insertions(+), 3 deletions(-)
> 
> diff --git a/criu/util.c b/criu/util.c
> index fa1d74965..96b9e95d6 100644
> --- a/criu/util.c
> +++ b/criu/util.c
> @@ -481,11 +481,10 @@ int clone_service_fd(int id)
>  		return 0;
>  
>  	for (i = SERVICE_FD_MIN + 1; i < SERVICE_FD_MAX; i++) {
> -		int old = __get_service_fd(i, service_fd_id);
> +		int old = get_service_fd(i);
>  		int new = __get_service_fd(i, id);
>  
> -		/* Do not dup parent's transport fd */
> -		if (i == TRANSPORT_FD_OFF)
> +		if (old < 0)
>  			continue;
>  		ret = dup2(old, new);
>  		if (ret == -1) {
> 
> _______________________________________________
> CRIU mailing list
> CRIU@openvz.org
> https://lists.openvz.org/mailman/listinfo/criu
Kirill Tkhai Jan. 31, 2017, 9 a.m.
On 31.01.2017 01:23, Andrei Vagin wrote:
> On Thu, Jan 26, 2017 at 12:58:43PM +0300, Kirill Tkhai wrote:
>> Make this function more generic: we want to dup not only
>> transport socket of parent, but just all service fds, which
>> were not opened at the moment of clone() in parent. But,
>> yes, currently it's only transport socket.
> 
> But, no, ...

It's erratum. Should be "we want to do not dup not only transport socket"

> Now this function clones all descriptros except a transport socket.
>
> c7eeef23e40cd5038ff69bb91d4b987388e3bfff


 
>>
>> Signed-off-by: Kirill Tkhai <ktkhai@virtuozzo.com>
>> ---
>>  criu/util.c |    5 ++---
>>  1 file changed, 2 insertions(+), 3 deletions(-)
>>
>> diff --git a/criu/util.c b/criu/util.c
>> index fa1d74965..96b9e95d6 100644
>> --- a/criu/util.c
>> +++ b/criu/util.c
>> @@ -481,11 +481,10 @@ int clone_service_fd(int id)
>>  		return 0;
>>  
>>  	for (i = SERVICE_FD_MIN + 1; i < SERVICE_FD_MAX; i++) {
>> -		int old = __get_service_fd(i, service_fd_id);
>> +		int old = get_service_fd(i);
>>  		int new = __get_service_fd(i, id);
>>  
>> -		/* Do not dup parent's transport fd */
>> -		if (i == TRANSPORT_FD_OFF)
>> +		if (old < 0)
>>  			continue;
>>  		ret = dup2(old, new);
>>  		if (ret == -1) {
>>
>> _______________________________________________
>> CRIU mailing list
>> CRIU@openvz.org
>> https://lists.openvz.org/mailman/listinfo/criu
Pavel Emelianov Feb. 10, 2017, 10:34 a.m.
Applied