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?)
This commit is contained in:
Alon Levy 2010-11-11 11:05:01 +02:00
parent 8cd5568c92
commit 17d5761322
3 changed files with 15 additions and 4 deletions

View File

@ -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);
}
}

View File

@ -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;
}

View File

@ -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