summaryrefslogtreecommitdiffstats
path: root/server
diff options
context:
space:
mode:
authorAlon Levy <alevy@redhat.com>2010-11-11 11:05:01 +0200
committerAlon Levy <alevy@redhat.com>2011-03-02 17:27:52 +0200
commit17d57613225fe3520b42aaddbab4b5252b9c8b3b (patch)
tree5cefacb39e7a9b84fba2633a0b5c0d035902c881 /server
parent8cd5568c92384490ec20f898d2d8c12009b6bf47 (diff)
downloadspice-17d57613225fe3520b42aaddbab4b5252b9c8b3b.tar.gz
spice-17d57613225fe3520b42aaddbab4b5252b9c8b3b.tar.xz
spice-17d57613225fe3520b42aaddbab4b5252b9c8b3b.zip
server/red_channel: add red_channel_get_first_socket
Use in main_channel. This is just for backward portability later when multiple clients are introduced - needs to be considered (which sockets do we want to export from libspiceserver?)
Diffstat (limited to 'server')
-rw-r--r--server/main_channel.c9
-rw-r--r--server/red_channel.c8
-rw-r--r--server/red_channel.h2
3 files changed, 15 insertions, 4 deletions
diff --git a/server/main_channel.c b/server/main_channel.c
index 75accac7..1f407e23 100644
--- a/server/main_channel.c
+++ b/server/main_channel.c
@@ -823,22 +823,23 @@ int main_channel_getsockname(Channel *channel, struct sockaddr *sa, socklen_t *s
{
MainChannel *main_chan = channel->data;
- return main_chan ? getsockname(main_chan->base.stream->socket, sa, salen) : -1;
+ return main_chan ? getsockname(red_channel_get_first_socket(&main_chan->base), sa, salen) : -1;
}
int main_channel_getpeername(Channel *channel, struct sockaddr *sa, socklen_t *salen)
{
MainChannel *main_chan = channel->data;
- return main_chan ? getpeername(main_chan->base.stream->socket, sa, salen) : -1;
+ return main_chan ? getpeername(red_channel_get_first_socket(&main_chan->base), sa, salen) : -1;
}
void main_channel_close(Channel *channel)
{
MainChannel *main_chan = channel->data;
+ int socketfd;
- if (main_chan && main_chan->base.stream) {
- close(main_chan->base.stream->socket);
+ if (main_chan && (socketfd = red_channel_get_first_socket(&main_chan->base)) != -1) {
+ close(socketfd);
}
}
diff --git a/server/red_channel.c b/server/red_channel.c
index 1b705d67..a1bce119 100644
--- a/server/red_channel.c
+++ b/server/red_channel.c
@@ -711,3 +711,11 @@ RedsStream *red_channel_get_stream(RedChannel *channel)
{
return channel->stream;
}
+
+int red_channel_get_first_socket(RedChannel *channel)
+{
+ if (!channel->stream) {
+ return -1;
+ }
+ return channel->stream->socket;
+}
diff --git a/server/red_channel.h b/server/red_channel.h
index d0f7fb79..9d13dd73 100644
--- a/server/red_channel.h
+++ b/server/red_channel.h
@@ -249,6 +249,8 @@ void red_channel_push_set_ack(RedChannel *channel);
void red_channel_shutdown(RedChannel *channel);
+int red_channel_get_first_socket(RedChannel *channel);
+
// TODO: unstaticed for display/cursor channels. they do some specific pushes not through
// adding elements or on events. but not sure if this is actually required (only result
// should be that they ""try"" a little harder, but if the event system is correct it