提交 c7d7aa1c 编写于 作者: D Daniel Veillard

remove dandling domain/net/conn pointers from error data

* 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
Daniel
上级 be03daaa
Mon Mar 31 16:35:47 CEST 2008 Daniel Veillard <veillard@redhat.com>
* 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 <veillard@redhat.com>
* configure.in: small patch from Mike Gerdts to avoid problems with
......
......@@ -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);
......
......@@ -264,6 +264,7 @@ struct _virStorageVol {
* API for error handling *
* *
************************************************************************/
extern virError __lastErr;
void __virRaiseError(virConnectPtr conn,
virDomainPtr dom,
virNetworkPtr net,
......
......@@ -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);
......
......@@ -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;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册