diff options
| author | Daniel P. Berrange <berrange@redhat.com> | 2017-09-04 14:05:05 +0100 |
|---|---|---|
| committer | Daniel P. Berrange <berrange@redhat.com> | 2017-09-06 11:47:11 +0100 |
| commit | 7534c19a71f03b701543cde547972e0870f1135e (patch) | |
| tree | 4a42ea78cb8c472392cca82747be8f1d284aeda1 | |
| parent | 57a160b5248ba47d4e1c9d22d95847dad8e0524f (diff) | |
| download | libvirt-python-7534c19a71f03b701543cde547972e0870f1135e.tar.gz | |
Report an error if registering an event loop twice
The C library will now ignore an attempt to register an event
loop twice. It is unable to report an error in this case though
due to the C API returning 'void'. To improve this we must
manually report an error at the python level.
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
| -rw-r--r-- | libvirt-override.c | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/libvirt-override.c b/libvirt-override.c index a3a0508..9eba4ed 100644 --- a/libvirt-override.c +++ b/libvirt-override.c @@ -5427,13 +5427,12 @@ static PyObject * libvirt_virEventRegisterImpl(PyObject *self ATTRIBUTE_UNUSED, PyObject *args) { - /* Unref the previously-registered impl (if any) */ - Py_XDECREF(addHandleObj); - Py_XDECREF(updateHandleObj); - Py_XDECREF(removeHandleObj); - Py_XDECREF(addTimeoutObj); - Py_XDECREF(updateTimeoutObj); - Py_XDECREF(removeTimeoutObj); + if (addHandleObj || updateHandleObj || removeHandleObj || + addTimeoutObj || updateTimeoutObj || removeTimeoutObj) { + PyErr_SetString(PyExc_RuntimeError, + "Event loop is already registered"); + return NULL; + } /* Parse and check arguments */ if (!PyArg_ParseTuple(args, (char *) "OOOOOO:virEventRegisterImpl", |
