[Spice-devel] [PATCH 10/26] server/red_channel: add red_channel_get_first_socket
Alon Levy
alevy at redhat.com
Sat Feb 19 11:00:16 PST 2011
On Tue, Feb 15, 2011 at 02:40:37AM +0100, Marc-André Lureau wrote:
> okay, (tiny) ack.. since you have done the rest of the multi-client
> patches, perhaps you could tell here what's the future design going to
> be like? thanks!
Sorry for answering in reverse chronological order - see the later thread
for (some) design.
Fact is my current multiclient solution is working but crashes occationally,
so in fact it is still buggy. This patch is never elaborated - it means that
the information supplied actually becomes partial (only first socket instead
of all sockets). I need to fix this.
>
> On Fri, Feb 11, 2011 at 6:48 PM, Alon Levy <alevy at redhat.com> wrote:
> > 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?)
> > ---
> > server/main_channel.c | 9 +++++----
> > server/red_channel.c | 8 ++++++++
> > server/red_channel.h | 2 ++
> > 3 files changed, 15 insertions(+), 4 deletions(-)
> >
> > diff --git a/server/main_channel.c b/server/main_channel.c
> > index 21e0156..9809fc8 100644
> > --- a/server/main_channel.c
> > +++ b/server/main_channel.c
> > @@ -822,22 +822,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.peer->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.peer->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.peer) {
> > - close(main_chan->base.peer->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 2aa5f83..44dd99e 100644
> > --- a/server/red_channel.c
> > +++ b/server/red_channel.c
> > @@ -704,3 +704,11 @@ void red_channel_set_shut(RedChannel *channel)
> > channel->incoming.shut = TRUE;
> > }
> >
> > +int red_channel_get_first_socket(RedChannel *channel)
> > +{
> > + if (!channel->peer) {
> > + return -1;
> > + }
> > + return channel->peer->socket;
> > +}
> > +
> > diff --git a/server/red_channel.h b/server/red_channel.h
> > index 713056f..e3f4f8e 100644
> > --- a/server/red_channel.h
> > +++ b/server/red_channel.h
> > @@ -250,6 +250,8 @@ void red_channel_push_set_ack(RedChannel *channel);
> >
> > void red_channel_set_shut(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
> > --
> > 1.7.4
> >
> > _______________________________________________
> > Spice-devel mailing list
> > Spice-devel at lists.freedesktop.org
> > http://lists.freedesktop.org/mailman/listinfo/spice-devel
> >
>
>
>
> --
> Marc-André Lureau
More information about the Spice-devel
mailing list