提交 b41780e4 编写于 作者: D Daniel P. Berrange 提交者: Daniel P. Berrangé

rpc: pass virNetServer to post-exec restart callback in typesafe manner

The virNetServer class is passing a pointer to itself to the
virNetServerClient as a 'void *' pointer. This is presumably due to fact
that the virnetserverclient.h file doesn't see the virNetServerPtr
typedef. The typedef is easily movable though, which lets us get
typesafe parameter passing, removing the confusion of passing two
distinct 'void *' pointers to one method.
Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
上级 2c76fa91
......@@ -540,12 +540,12 @@ virNetServerPtr virNetServerNewPostExecRestart(virJSONValuePtr object,
goto error;
}
if (!(client = virNetServerClientNewPostExecRestart(child,
if (!(client = virNetServerClientNewPostExecRestart(srv,
child,
clientPrivNewPostExecRestart,
clientPrivPreExecRestart,
clientPrivFree,
clientPrivOpaque,
srv)))
clientPrivOpaque)))
goto error;
if (virNetServerAddClient(srv, client) < 0) {
......
......@@ -479,12 +479,12 @@ virNetServerClientPtr virNetServerClientNew(unsigned long long id,
}
virNetServerClientPtr virNetServerClientNewPostExecRestart(virJSONValuePtr object,
virNetServerClientPtr virNetServerClientNewPostExecRestart(virNetServerPtr srv,
virJSONValuePtr object,
virNetServerClientPrivNewPostExecRestart privNew,
virNetServerClientPrivPreExecRestart privPreExecRestart,
virFreeCallback privFree,
void *privOpaque,
void *opaque)
void *privOpaque)
{
virJSONValuePtr child;
virNetServerClientPtr client = NULL;
......@@ -540,12 +540,12 @@ virNetServerClientPtr virNetServerClientNewPostExecRestart(virJSONValuePtr objec
if (!virJSONValueObjectHasKey(object, "id")) {
/* no ID found in, a new one must be generated */
id = virNetServerNextClientID((virNetServerPtr) opaque);
id = virNetServerNextClientID(srv);
} else {
if (virJSONValueObjectGetNumberUlong(object, "id", &id) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Malformed id field in JSON state document"));
return NULL;
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Malformed id field in JSON state document"));
return NULL;
}
}
......
......@@ -30,6 +30,9 @@
# include "virobject.h"
# include "virjson.h"
typedef struct _virNetServer virNetServer;
typedef virNetServer *virNetServerPtr;
typedef struct _virNetServerClient virNetServerClient;
typedef virNetServerClient *virNetServerClientPtr;
......@@ -71,12 +74,12 @@ virNetServerClientPtr virNetServerClientNew(unsigned long long id,
virFreeCallback privFree,
void *privOpaque);
virNetServerClientPtr virNetServerClientNewPostExecRestart(virJSONValuePtr object,
virNetServerClientPtr virNetServerClientNewPostExecRestart(virNetServerPtr srv,
virJSONValuePtr object,
virNetServerClientPrivNewPostExecRestart privNew,
virNetServerClientPrivPreExecRestart privPreExecRestart,
virFreeCallback privFree,
void *privOpaque,
void *opaque);
void *privOpaque);
virJSONValuePtr virNetServerClientPreExecRestart(virNetServerClientPtr client);
......
......@@ -31,9 +31,6 @@
typedef struct _virNetDaemon virNetDaemon;
typedef virNetDaemon *virNetDaemonPtr;
typedef struct _virNetServer virNetServer;
typedef virNetServer *virNetServerPtr;
typedef struct _virNetServerService virNetServerService;
typedef virNetServerService *virNetServerServicePtr;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册