summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJonathon Jongsma <jjongsma@redhat.com>2015-01-27 16:51:03 -0600
committerFabiano FidĂȘncio <fidencio@redhat.com>2015-02-23 23:00:45 +0100
commit1194fae687addae6e1c8399a1f42c6f57538f535 (patch)
treec6346166bf1f0493ea57b5317e1fef9c3fe35668
parent4a113c19be6954514c0d73b425176009de9ca4f1 (diff)
downloadspice-1194fae687addae6e1c8399a1f42c6f57538f535.tar.gz
spice-1194fae687addae6e1c8399a1f42c6f57538f535.tar.xz
spice-1194fae687addae6e1c8399a1f42c6f57538f535.zip
Add RedsState member to RedLinkInfo
This allows us to use local 'reds' variables in all of the various async callbacks rather than using the global 'reds' variable.
-rw-r--r--server/reds.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/server/reds.c b/server/reds.c
index e676088b..9bf0e947 100644
--- a/server/reds.c
+++ b/server/reds.c
@@ -93,6 +93,7 @@ static long *lock_count;
RedsState *reds = NULL;
typedef struct RedLinkInfo {
+ RedsState *reds;
RedsStream *stream;
SpiceLinkHeader link_header;
SpiceLinkMess *link_mess;
@@ -1825,6 +1826,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;
@@ -1909,6 +1911,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);
@@ -1949,6 +1952,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);
@@ -2013,6 +2017,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);
@@ -2037,6 +2042,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)) ||
@@ -2046,6 +2052,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 = link_mess->num_common_caps + link_mess->num_channel_caps;
int auth_selection;
@@ -2112,6 +2119,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;
if (header->magic != SPICE_MAGIC) {
@@ -2161,6 +2169,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) {
@@ -2202,6 +2211,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 */
@@ -2271,6 +2281,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) {
@@ -2414,7 +2425,7 @@ static int reds_init_net(RedsState *reds)
}
reds->listen_watch = reds->core->watch_add(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;
@@ -2440,7 +2451,7 @@ static int reds_init_net(RedsState *reds)
reds->listen_socket = reds->spice_listen_socket_fd;
reds->listen_watch = reds->core->watch_add(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;