[Spice-devel] [PATCH 16/18] Add RedsState member to RedLinkInfo
Frediano Ziglio
fziglio at redhat.com
Tue Feb 2 17:06:05 CET 2016
From: Jonathon Jongsma <jjongsma at redhat.com>
This allows us to use local 'reds' variables in all of the various async
callbacks rather than using the global 'reds' variable.
---
server/reds.c | 15 +++++++++++++--
1 file changed, 13 insertions(+), 2 deletions(-)
diff --git a/server/reds.c b/server/reds.c
index 8b2dab5..b6fe1ae 100644
--- a/server/reds.c
+++ b/server/reds.c
@@ -148,6 +148,7 @@ static long *lock_count;
RedsState *reds = NULL;
typedef struct RedLinkInfo {
+ RedsState *reds;
RedsStream *stream;
SpiceLinkHeader link_header;
SpiceLinkMess *link_mess;
@@ -1893,6 +1894,7 @@ static void reds_handle_link(RedsState *reds, RedLinkInfo *link)
static void reds_handle_ticket(void *opaque)
{
RedLinkInfo *link = (RedLinkInfo *)opaque;
+ RedsState *reds = link->reds;
char *password;
time_t ltime;
int password_size;
@@ -1977,6 +1979,7 @@ static void reds_handle_auth_sasl_steplen(void *opaque);
static void reds_handle_auth_sasl_step(void *opaque)
{
RedLinkInfo *link = (RedLinkInfo *)opaque;
+ RedsState *reds = link->reds;
RedsSaslError status;
status = reds_sasl_handle_auth_step(link->stream, reds_handle_auth_sasl_steplen, link);
@@ -2017,6 +2020,7 @@ static void reds_handle_auth_sasl_steplen(void *opaque)
static void reds_handle_auth_sasl_start(void *opaque)
{
RedLinkInfo *link = (RedLinkInfo *)opaque;
+ RedsState *reds = link->reds;
RedsSaslError status;
status = reds_sasl_handle_auth_start(link->stream, reds_handle_auth_sasl_steplen, link);
@@ -2081,6 +2085,7 @@ static void reds_start_auth_sasl(RedLinkInfo *link)
static void reds_handle_auth_mechanism(void *opaque)
{
RedLinkInfo *link = (RedLinkInfo *)opaque;
+ RedsState *reds = link->reds;
spice_info("Auth method: %d", link->auth_mechanism.auth_mechanism);
@@ -2106,6 +2111,7 @@ static void reds_handle_auth_mechanism(void *opaque)
static int reds_security_check(RedLinkInfo *link)
{
+ RedsState *reds = link->reds;
ChannelSecurityOptions *security_option = reds_find_channel_security(reds, link->link_mess->channel_type);
uint32_t security = security_option ? security_option->options : reds->default_channel_security;
return (reds_stream_is_ssl(link->stream) && (security & SPICE_CHANNEL_SECURITY_SSL)) ||
@@ -2115,6 +2121,7 @@ static int reds_security_check(RedLinkInfo *link)
static void reds_handle_read_link_done(void *opaque)
{
RedLinkInfo *link = (RedLinkInfo *)opaque;
+ RedsState *reds = link->reds;
SpiceLinkMess *link_mess = link->link_mess;
uint32_t num_caps;
uint32_t *caps;
@@ -2194,6 +2201,7 @@ static void reds_handle_link_error(void *opaque, int err)
static void reds_handle_read_header_done(void *opaque)
{
RedLinkInfo *link = (RedLinkInfo *)opaque;
+ RedsState *reds = link->reds;
SpiceLinkHeader *header = &link->link_header;
header->major_version = GUINT32_FROM_LE(header->major_version);
@@ -2247,6 +2255,7 @@ static void reds_handle_new_link(RedLinkInfo *link)
static void reds_handle_ssl_accept(int fd, int event, void *data)
{
RedLinkInfo *link = (RedLinkInfo *)data;
+ RedsState *reds = link->reds;
int return_code = reds_stream_ssl_accept(link->stream);
switch (return_code) {
@@ -2303,6 +2312,7 @@ static RedLinkInfo *reds_init_client_connection(RedsState *reds, int socket)
}
link = spice_new0(RedLinkInfo, 1);
+ link->reds = reds;
link->stream = reds_stream_new(socket);
/* gather info + send event */
@@ -2372,6 +2382,7 @@ static void reds_accept_ssl_connection(int fd, int event, void *data)
static void reds_accept(int fd, int event, void *data)
{
+ RedsState *reds = data;
int socket;
if ((socket = accept(reds->listen_socket, NULL, 0)) == -1) {
@@ -2535,7 +2546,7 @@ static int reds_init_net(RedsState *reds)
}
reds->listen_watch = reds->core->watch_add(reds->core, reds->listen_socket,
SPICE_WATCH_EVENT_READ,
- reds_accept, NULL);
+ reds_accept, reds);
if (reds->listen_watch == NULL) {
spice_warning("set fd handle failed");
return -1;
@@ -2561,7 +2572,7 @@ static int reds_init_net(RedsState *reds)
reds->listen_socket = reds->spice_listen_socket_fd;
reds->listen_watch = reds->core->watch_add(reds->core, reds->listen_socket,
SPICE_WATCH_EVENT_READ,
- reds_accept, NULL);
+ reds_accept, reds);
if (reds->listen_watch == NULL) {
spice_warning("set fd handle failed");
return -1;
--
2.4.3
More information about the Spice-devel
mailing list