提交 ce33967a 编写于 作者: P Paolo Bonzini

nbd: make refcount interface public

After the next patch, the close callback will have to release its
reference.
Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
上级 a4aab7b4
...@@ -647,12 +647,12 @@ static ssize_t nbd_send_reply(int csock, struct nbd_reply *reply) ...@@ -647,12 +647,12 @@ static ssize_t nbd_send_reply(int csock, struct nbd_reply *reply)
#define MAX_NBD_REQUESTS 16 #define MAX_NBD_REQUESTS 16
static void nbd_client_get(NBDClient *client) void nbd_client_get(NBDClient *client)
{ {
client->refcount++; client->refcount++;
} }
static void nbd_client_put(NBDClient *client) void nbd_client_put(NBDClient *client)
{ {
if (--client->refcount == 0) { if (--client->refcount == 0) {
g_free(client); g_free(client);
......
...@@ -81,7 +81,10 @@ typedef struct NBDClient NBDClient; ...@@ -81,7 +81,10 @@ typedef struct NBDClient NBDClient;
NBDExport *nbd_export_new(BlockDriverState *bs, off_t dev_offset, NBDExport *nbd_export_new(BlockDriverState *bs, off_t dev_offset,
off_t size, uint32_t nbdflags); off_t size, uint32_t nbdflags);
void nbd_export_close(NBDExport *exp); void nbd_export_close(NBDExport *exp);
NBDClient *nbd_client_new(NBDExport *exp, int csock, NBDClient *nbd_client_new(NBDExport *exp, int csock,
void (*close)(NBDClient *)); void (*close)(NBDClient *));
void nbd_client_get(NBDClient *client);
void nbd_client_put(NBDClient *client);
#endif #endif
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册