diff --git a/ChangeLog b/ChangeLog index 4acfaec5129b61f78420f1361a88d86ba3d9b163..dbc39172cda8c6f19f9277533061b14b26b667e0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +Mon Mar 31 16:35:47 CEST 2008 Daniel Veillard + + * src/hash.c src/internal.h src/virterror.c: remove dandling + domain/net/conn pointers from error data when released. + * src/lxc_driver.c: fix a NULL/0 return error mismatch + Mon Mar 31 14:12:42 CEST 2008 Daniel Veillard * configure.in: small patch from Mike Gerdts to avoid problems with diff --git a/src/hash.c b/src/hash.c index 45d743370def75c9b84fe6951e8b5fdb25a90787..99177bcf12dcbe4cd26c77fcce13fa9313214c5f 100644 --- a/src/hash.c +++ b/src/hash.c @@ -757,6 +757,9 @@ virReleaseConnect(virConnectPtr conn) { virHashFree(conn->storageVols, (virHashDeallocator) virStorageVolFreeName); virResetError(&conn->err); + if (__lastErr.conn == conn) + __lastErr.conn = NULL; + free(conn->name); pthread_mutex_unlock(&conn->lock); @@ -880,6 +883,10 @@ virReleaseDomain(virDomainPtr domain) { virHashError(conn, VIR_ERR_INTERNAL_ERROR, _("domain missing from connection hash table")); + if (conn->err.dom == domain) + conn->err.dom = NULL; + if (__lastErr.dom == domain) + __lastErr.dom = NULL; domain->magic = -1; domain->id = -1; free(domain->name); @@ -1013,6 +1020,11 @@ virReleaseNetwork(virNetworkPtr network) { virHashError(conn, VIR_ERR_INTERNAL_ERROR, _("network missing from connection hash table")); + if (conn->err.net == network) + conn->err.net = NULL; + if (__lastErr.net == network) + __lastErr.net = NULL; + network->magic = -1; free(network->name); free(network); diff --git a/src/internal.h b/src/internal.h index d3a566459a0cec875b6cbc1782f18cdd67fbe6c9..dde673b00f7eae3ac7074bd4cb244542f7552dbb 100644 --- a/src/internal.h +++ b/src/internal.h @@ -264,6 +264,7 @@ struct _virStorageVol { * API for error handling * * * ************************************************************************/ +extern virError __lastErr; void __virRaiseError(virConnectPtr conn, virDomainPtr dom, virNetworkPtr net, diff --git a/src/lxc_driver.c b/src/lxc_driver.c index a9afae6a5b08a6c4e1887e52258117c30a82cbaa..a4e77859fa23e0c37bf48aed2e230ba420d6961b 100644 --- a/src/lxc_driver.c +++ b/src/lxc_driver.c @@ -420,7 +420,7 @@ static void lxcFreeDriver(lxc_driver_t *driver) static int lxcShutdown(void) { if (lxc_driver == NULL) - return(NULL); + return(-1); lxcFreeVMs(lxc_driver->vms); lxc_driver->vms = NULL; lxcFreeDriver(lxc_driver); diff --git a/src/virterror.c b/src/virterror.c index 1e39be40a4e2497bf16e2d6dcec070ccba560e3f..92ccf67d937bc10e84b71734f4eeb447515dc141 100644 --- a/src/virterror.c +++ b/src/virterror.c @@ -18,7 +18,7 @@ #include "libvirt/virterror.h" #include "internal.h" -static virError lastErr = /* the last error */ +virError __lastErr = /* the last error */ { 0, 0, NULL, VIR_ERR_NONE, NULL, NULL, NULL, NULL, NULL, 0, 0, NULL }; static virErrorFunc virErrorHandler = NULL; /* global error handler */ static void *virUserData = NULL; /* associated data */ @@ -72,9 +72,9 @@ static void *virUserData = NULL; /* associated data */ virErrorPtr virGetLastError(void) { - if (lastErr.code == VIR_ERR_OK) + if (__lastErr.code == VIR_ERR_OK) return (NULL); - return (&lastErr); + return (&__lastErr); } /* @@ -92,10 +92,10 @@ virCopyLastError(virErrorPtr to) { if (to == NULL) return (-1); - if (lastErr.code == VIR_ERR_OK) + if (__lastErr.code == VIR_ERR_OK) return (0); - memcpy(to, &lastErr, sizeof(virError)); - return (lastErr.code); + memcpy(to, &__lastErr, sizeof(virError)); + return (__lastErr.code); } /** @@ -124,7 +124,7 @@ virResetError(virErrorPtr err) void virResetLastError(void) { - virResetError(&lastErr); + virResetError(&__lastErr); } /** @@ -347,7 +347,7 @@ __virRaiseError(virConnectPtr conn, virDomainPtr dom, virNetworkPtr net, const char *str1, const char *str2, const char *str3, int int1, int int2, const char *msg, ...) { - virErrorPtr to = &lastErr; + virErrorPtr to = &__lastErr; void *userData = virUserData; virErrorFunc handler = virErrorHandler; char *str;