Add reference to server in RedClient

Allows client methods to not use global 'reds' variable

Acked-by: Frediano Ziglio <fziglio@redhat.com>
This commit is contained in:
Jonathon Jongsma 2015-01-29 16:43:55 -06:00 committed by Frediano Ziglio
parent 451ac31a7a
commit 2dfcf9c6e3
3 changed files with 8 additions and 4 deletions

View File

@ -2046,11 +2046,12 @@ void red_channel_client_pipe_remove_and_release(RedChannelClient *rcc,
* pretty tied together.
*/
RedClient *red_client_new(int migrated)
RedClient *red_client_new(RedsState *reds, int migrated)
{
RedClient *client;
client = spice_malloc0(sizeof(RedClient));
client->reds = reds;
ring_init(&client->channels);
pthread_mutex_init(&client->lock, NULL);
client->thread_id = pthread_self();
@ -2212,7 +2213,7 @@ void red_client_semi_seamless_migrate_complete(RedClient *client)
}
}
pthread_mutex_unlock(&client->lock);
reds_on_client_semi_seamless_migrate_complete(reds, client);
reds_on_client_semi_seamless_migrate_complete(client->reds, client);
}
/* should be called only from the main thread */

View File

@ -563,7 +563,10 @@ typedef void (*channel_client_callback)(RedChannelClient *rcc);
typedef void (*channel_client_callback_data)(RedChannelClient *rcc, void *data);
void red_channel_apply_clients(RedChannel *channel, channel_client_callback v);
struct RedsState;
struct RedClient {
struct RedsState *reds;
RingItem link;
Ring channels;
int channels_num;
@ -585,7 +588,7 @@ struct RedClient {
int refs;
};
RedClient *red_client_new(int migrated);
RedClient *red_client_new(struct RedsState *reds, int migrated);
/*
* disconnects all the client's channels (should be called from the client's thread)

View File

@ -1648,7 +1648,7 @@ static void reds_handle_main_link(RedsState *reds, RedLinkInfo *link)
link->link_mess = NULL;
reds_link_free(link);
caps = (uint32_t *)((uint8_t *)link_mess + link_mess->caps_offset);
client = red_client_new(mig_target);
client = red_client_new(reds, mig_target);
ring_add(&reds->clients, &client->link);
reds->num_clients++;
mcc = main_channel_link(reds->main_channel, client,