mirror of
https://gitlab.uni-freiburg.de/opensourcevdi/spice
synced 2026-08-18 06:49:18 +00:00
Define and use (un)ref
Avoids g_object_(un)ref. This in preparation to remove GObject. Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
This commit is contained in:
parent
75679dc95d
commit
164a333f99
@ -53,6 +53,8 @@ typedef struct DispatcherPrivate DispatcherPrivate;
|
||||
struct Dispatcher: public GObject
|
||||
{
|
||||
DispatcherPrivate *priv;
|
||||
void ref() { g_object_ref(this); }
|
||||
void unref() { g_object_unref(this); }
|
||||
};
|
||||
|
||||
struct DispatcherClass
|
||||
|
||||
@ -182,7 +182,7 @@ static void main_dispatcher_handle_migrate_complete(void *opaque,
|
||||
MainDispatcherMigrateSeamlessDstCompleteMessage *mig_complete = (MainDispatcherMigrateSeamlessDstCompleteMessage*) payload;
|
||||
|
||||
reds_on_client_seamless_migrate_complete(reds, mig_complete->client);
|
||||
g_object_unref(mig_complete->client);
|
||||
mig_complete->client->unref();
|
||||
}
|
||||
|
||||
static void main_dispatcher_handle_mm_time_latency(void *opaque,
|
||||
@ -191,7 +191,7 @@ static void main_dispatcher_handle_mm_time_latency(void *opaque,
|
||||
RedsState *reds = (RedsState*) opaque;
|
||||
MainDispatcherMmTimeLatencyMessage *msg = (MainDispatcherMmTimeLatencyMessage*) payload;
|
||||
reds_set_client_mm_time_latency(reds, msg->client, msg->latency);
|
||||
g_object_unref(msg->client);
|
||||
msg->client->unref();
|
||||
}
|
||||
|
||||
static void main_dispatcher_handle_client_disconnect(void *opaque,
|
||||
@ -202,7 +202,7 @@ static void main_dispatcher_handle_client_disconnect(void *opaque,
|
||||
|
||||
spice_debug("client=%p", msg->client);
|
||||
reds_client_disconnect(reds, msg->client);
|
||||
g_object_unref(msg->client);
|
||||
msg->client->unref();
|
||||
}
|
||||
|
||||
void main_dispatcher_seamless_migrate_dst_complete(MainDispatcher *self,
|
||||
@ -215,7 +215,7 @@ void main_dispatcher_seamless_migrate_dst_complete(MainDispatcher *self,
|
||||
return;
|
||||
}
|
||||
|
||||
msg.client = (RedClient*) g_object_ref(client);
|
||||
msg.client = red::add_ref(client);
|
||||
dispatcher_send_message(DISPATCHER(self), MAIN_DISPATCHER_MIGRATE_SEAMLESS_DST_COMPLETE,
|
||||
&msg);
|
||||
}
|
||||
@ -229,7 +229,7 @@ void main_dispatcher_set_mm_time_latency(MainDispatcher *self, RedClient *client
|
||||
return;
|
||||
}
|
||||
|
||||
msg.client = (RedClient*) g_object_ref(client);
|
||||
msg.client = red::add_ref(client);
|
||||
msg.latency = latency;
|
||||
dispatcher_send_message(DISPATCHER(self), MAIN_DISPATCHER_SET_MM_TIME_LATENCY,
|
||||
&msg);
|
||||
@ -241,7 +241,7 @@ void main_dispatcher_client_disconnect(MainDispatcher *self, RedClient *client)
|
||||
|
||||
if (!red_client_is_disconnecting(client)) {
|
||||
spice_debug("client %p", client);
|
||||
msg.client = (RedClient*) g_object_ref(client);
|
||||
msg.client = red::add_ref(client);
|
||||
dispatcher_send_message(DISPATCHER(self), MAIN_DISPATCHER_CLIENT_DISCONNECT,
|
||||
&msg);
|
||||
} else {
|
||||
|
||||
@ -26,6 +26,7 @@
|
||||
#include "red-channel-client.h"
|
||||
#include "reds.h"
|
||||
#include "red-stream.h"
|
||||
#include "red-client.h"
|
||||
#include "main-dispatcher.h"
|
||||
#include "utils.h"
|
||||
#include "utils.hpp"
|
||||
@ -71,7 +72,7 @@ struct RedChannelPrivate
|
||||
handle_acks(!!(flags & RedChannel::HandleAcks)),
|
||||
parser(spice_get_client_channel_parser(type, nullptr)),
|
||||
migration_flags(flags & RedChannel::MigrateAll),
|
||||
dispatcher(dispatcher ? (Dispatcher*) g_object_ref(dispatcher) : dispatcher),
|
||||
dispatcher(red::add_ref(dispatcher)),
|
||||
reds(reds)
|
||||
{
|
||||
thread_id = pthread_self();
|
||||
@ -340,7 +341,7 @@ static void handle_dispatcher_connect(void *opaque, void *payload)
|
||||
RedChannel *channel = msg->channel;
|
||||
|
||||
channel->on_connect(msg->client, msg->stream, msg->migration, &msg->caps);
|
||||
g_object_unref(msg->client);
|
||||
msg->client->unref();
|
||||
red_channel_capabilities_reset(&msg->caps);
|
||||
}
|
||||
|
||||
@ -359,7 +360,7 @@ void RedChannel::connect(RedClient *client, RedStream *stream, int migration,
|
||||
// the main thread causing RedClient to be destroyed before using it
|
||||
RedMessageConnect payload = {
|
||||
.channel = this,
|
||||
.client = (RedClient*) g_object_ref(client),
|
||||
.client = red::add_ref(client),
|
||||
.stream = stream,
|
||||
.migration = migration
|
||||
};
|
||||
|
||||
@ -24,28 +24,6 @@
|
||||
#define FOREACH_CHANNEL_CLIENT(_client, _data) \
|
||||
GLIST_FOREACH((_client ? (_client)->channels : NULL), RedChannelClient, _data)
|
||||
|
||||
struct RedClient {
|
||||
GObject parent;
|
||||
RedsState *reds;
|
||||
GList *channels;
|
||||
MainChannelClient *mcc;
|
||||
pthread_mutex_t lock; // different channels can be in different threads
|
||||
|
||||
pthread_t thread_id;
|
||||
|
||||
int disconnecting;
|
||||
/* Note that while semi-seamless migration is conducted by the main thread, seamless migration
|
||||
* involves all channels, and thus the related variables can be accessed from different
|
||||
* threads */
|
||||
/* if seamless=TRUE, migration_target is turned off when all
|
||||
* the clients received their migration data. Otherwise (semi-seamless),
|
||||
* it is turned off, when red_client_semi_seamless_migrate_complete
|
||||
* is called */
|
||||
int during_target_migrate;
|
||||
int seamless_migrate;
|
||||
int num_migrated_channels; /* for seamless - number of channels that wait for migrate data*/
|
||||
};
|
||||
|
||||
struct RedClientClass
|
||||
{
|
||||
GObjectClass parent_class;
|
||||
@ -240,7 +218,7 @@ void red_client_destroy(RedClient *client)
|
||||
pthread_mutex_lock(&client->lock);
|
||||
}
|
||||
pthread_mutex_unlock(&client->lock);
|
||||
g_object_unref(client);
|
||||
client->unref();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -57,6 +57,30 @@ gboolean red_client_is_disconnecting(RedClient *client);
|
||||
void red_client_set_disconnecting(RedClient *client);
|
||||
RedsState* red_client_get_server(RedClient *client);
|
||||
|
||||
struct RedClient: public GObject
|
||||
{
|
||||
RedsState *reds;
|
||||
GList *channels;
|
||||
MainChannelClient *mcc;
|
||||
pthread_mutex_t lock; // different channels can be in different threads
|
||||
|
||||
pthread_t thread_id;
|
||||
|
||||
int disconnecting;
|
||||
/* Note that while semi-seamless migration is conducted by the main thread, seamless migration
|
||||
* involves all channels, and thus the related variables can be accessed from different
|
||||
* threads */
|
||||
/* if seamless=TRUE, migration_target is turned off when all
|
||||
* the clients received their migration data. Otherwise (semi-seamless),
|
||||
* it is turned off, when red_client_semi_seamless_migrate_complete
|
||||
* is called */
|
||||
int during_target_migrate;
|
||||
int seamless_migrate;
|
||||
int num_migrated_channels; /* for seamless - number of channels that wait for migrate data*/
|
||||
void ref() { g_object_ref(this); }
|
||||
void unref() { g_object_unref(this); }
|
||||
};
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* RED_CLIENT_H_ */
|
||||
|
||||
@ -628,7 +628,7 @@ void red_qxl_destroy(QXLInstance *qxl)
|
||||
RED_WORKER_MESSAGE_CLOSE_WORKER,
|
||||
&message);
|
||||
red_worker_free(qxl_state->worker);
|
||||
g_object_unref(qxl_state->dispatcher);
|
||||
qxl_state->dispatcher->unref();
|
||||
/* this must be done after calling red_worker_free */
|
||||
qxl->st = NULL;
|
||||
pthread_mutex_destroy(&qxl_state->scanout_mutex);
|
||||
|
||||
@ -3831,7 +3831,7 @@ SPICE_GNUC_VISIBLE void spice_server_destroy(SpiceServer *reds)
|
||||
}
|
||||
|
||||
if (reds->main_dispatcher) {
|
||||
g_object_unref(reds->main_dispatcher);
|
||||
reds->main_dispatcher->unref();
|
||||
}
|
||||
reds_cleanup_net(reds);
|
||||
if (reds->agent_dev) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user