On 03/21/2014 10:22 AM, Michal Privoznik wrote: > On 05.02.2014 03:01, Eric Blake wrote: >> Wrap the new virConnectDomainQemuMonitorEventRegister function >> being added in libvirt 1.2.2. This patch copies heavily from >> network events (commit 6ea5be0) and from event loop callbacks >> in libvirt-override.c, since in the libvirt_qemu module, we >> must expose top-level functions rather than class members. >> >> + LIBVIRT_ENSURE_THREAD_STATE; >> + >> + pyobj_cb = >> libvirt_qemu_lookupPythonFunc("_dispatchQemuMonitorEventCallback"); >> + if (!pyobj_cb) { >> + goto cleanup; >> + } >> + >> + dictKey = libvirt_constcharPtrWrap("conn"); >> + if (!dictKey) >> + return; This return needs to be 'goto cleanup' to restore thread state. >> + pyobj_conn = PyDict_GetItem(pyobj_cbData, dictKey); >> + Py_DECREF(dictKey); >> + >> + /* Create a python instance of this virDomainPtr */ >> + virDomainRef(dom); > > 1: ^^^ > >> + pyobj_dom = libvirt_virDomainPtrWrap(dom); >> + Py_INCREF(pyobj_cbData); >> + >> + /* Call the Callback Dispatcher */ >> + pyobj_ret = PyObject_CallFunction(pyobj_cb, >> + (char *)"OOsLIsO", >> + pyobj_conn, pyobj_dom, event, >> seconds, >> + micros, details, pyobj_cbData); >> + >> + Py_DECREF(pyobj_cbData); >> + Py_DECREF(pyobj_dom); > > I'd expect counterpart of [1] here. If pyobj_dom was successfully created, then the python object cleanup calls virDomainFree of the dom that got wrapped. But you are correct that if libvirt_virDomainPtrWrap fails, then we've leaked a reference. I'll post a v2. -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
Attachment:
signature.asc
Description: OpenPGP digital signature
-- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list