WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

Re: [Xen-devel] remover edundant call of socket.close()

To: James Song <jsong@xxxxxxxxxx>, "xen-devel@xxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxx>
Subject: Re: [Xen-devel] remover edundant call of socket.close()
From: Keir Fraser <keir.fraser@xxxxxxxxxxxxx>
Date: Mon, 07 Sep 2009 08:17:22 +0100
Cc:
Delivery-date: Mon, 07 Sep 2009 00:17:51 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
In-reply-to: <4AA502C0020000200006BDE7@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx>
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
Thread-index: AcovZr5SpgJ9h3JtS9uHZJ+HlJ3VdgAJH+mo
Thread-topic: [Xen-devel] remover edundant call of socket.close()
User-agent: Microsoft-Entourage/12.20.0.090605
Socket.SHUT_RDWR is not available in Python 2.3. Sock.close() should free
the underlying socket fd, which sock.shutdown() will not do (if these
methods behave as their underlying Unix equivalents).

 -- Keir

On 07/09/2009 03:55, "James Song" <jsong@xxxxxxxxxx> wrote:

> Hi,
>     After shutdown read and write side, sock needn't call close().  Moreover,
> use socket.SHUT_RDWR instead of 2 would enhace the readability of the code.
> 
> Signed-off-by: James Song <jsong@xxxxxxxxxx>
> 
> diff -r ead107bc25cb tools/python/xen/xend/XendDomain.py
> --- a/tools/python/xen/xend/XendDomain.py       Fri Sep 04 08:43:05 2009 +0100
> +++ b/tools/python/xen/xend/XendDomain.py       Mon Sep 07 10:33:40 2009 +0800
> @@ -1353,8 +1353,7 @@
>                  XendCheckpoint.save(p2cwrite, dominfo, True, live, dst,
>                                      node=node)
>              finally:
> -                sock.shutdown(2)
> -                sock.close()
> +                sock.shutdown(socket.SHUT_RDWR)
> 
>              os.close(p2cread)
>              os.close(p2cwrite)
> @@ -1379,8 +1378,7 @@
>                  XendCheckpoint.save(sock.fileno(), dominfo, True, live,
>                                      dst, node=node)
>              finally:
> -                sock.shutdown(2)
> -                sock.close()
> +                sock.shutdown(socket.SHUT_RDWR)
> 
>      def domain_save(self, domid, dst, checkpoint=False):
>          """Start saving a domain to file.
> 
> 



_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel

<Prev in Thread] Current Thread [Next in Thread>