Change in vdsm[master]: netlink: Introduce socket pool

nsoffer at redhat.com nsoffer at redhat.com
Fri Feb 21 12:11:23 UTC 2014


Nir Soffer has posted comments on this change.

Change subject: netlink: Introduce socket pool
......................................................................


Patch Set 5:

(1 comment)

http://gerrit.ovirt.org/#/c/24603/5/lib/vdsm/netlink.py
File lib/vdsm/netlink.py:

Line 100:         with self._semaphore:
Line 101:             try:
Line 102:                 sock = self._sockets.pop()
Line 103:             except KeyError:
Line 104:                 sock = _open_socket()
> Multiple thread can hold _semaphore, so Nir's code is raceful. If len(_sock
Right - my suggestion was wrong.

However, looking at thread safety, we pop and add items using the builtin set object from multiple threads, and this is not thread safe.

So this should be:

In __init__():
    self._lock = Lock()

In socket():

    with self._lock:
        get sock or create one
    try:
        yield sock
    finally:
        with self._lock:
            put sock in pool
Line 105:             try:
Line 106:                 yield sock
Line 107:             finally:
Line 108:                 self._sockets.add(sock)


-- 
To view, visit http://gerrit.ovirt.org/24603
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: comment
Gerrit-Change-Id: I657ac3d3e0c2661ce73bdef9aa807ead888a42eb
Gerrit-PatchSet: 5
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Antoni Segura Puimedon <asegurap at redhat.com>
Gerrit-Reviewer: Adam Litke <alitke at redhat.com>
Gerrit-Reviewer: Antoni Segura Puimedon <asegurap at redhat.com>
Gerrit-Reviewer: Dan Kenigsberg <danken at redhat.com>
Gerrit-Reviewer: Nir Soffer <nsoffer at redhat.com>
Gerrit-Reviewer: oVirt Jenkins CI Server
Gerrit-HasComments: Yes


More information about the vdsm-patches mailing list