What exactly triggers creation of a new client in Wayland server
Zan Dobersek
zandobersek at gmail.com
Tue Jan 25 13:02:59 PST 2011
Thanks for the reply.
The following is what pushed me into researching the problem - I've created
a test application that sets up a display and tries to create a client that
connects to that display, but the client does not connect.
Just as in compositor, I create a wl_display, add a socket to it and run the
wayland event loop (through wl_display_run). I add a timer that sets off in
~2 seconds and sets up the client.
Setting up the client starts as usual, calling wl_display_connect to connect
to the display via socket. Then a listener for events is set up and the
client enters the iteration to get all the events.
The problem is that apparently when server and client are both living in the
same program, socket_data doesn't get called because the client enters the
iteration 'too soon' and then enters an infinite loop in wl_connection_data
where client is waiting for data but it never receives any. Because
socket_data doesn't get called, a client does not get created on server side
and no events are passed onto it.
But if I add another timer that puts off the iteration for one second,
socket_data does get called and a client is created and is capable of
receiving data.
Any ideas?
Regards,
Zan Dobersek
On Tue, Jan 18, 2011 at 10:51 PM, Marty Jack <martyj19 at comcast.net> wrote:
> You have it right.
>
> When a client does a connect on a socket that another process is listening
> to (the listen is at line 692), this makes the other end get a "readable" on
> its end of the socket. You then do an accept, which gives you a new fd for
> your end of the connection. You then have a bidirectional path between the
> client's end and the compositor's end. If you write data down one end, it
> is readable at the other, and vice versa.
>
> In this case it is what is called a "UNIX domain socket", which is
> represented by an entry in the file system.
>
> man 2 listen, man 2 accept, man 7 unix, any tutorial on networking
>
> On 01/18/2011 04:15 PM, Zan Dobersek wrote:
> > Greetings,
> >
> > I'm wondering what exactly sets off the socket_data function in
> wayland/wayland-server.c at approximate line 640. I can see that we add a
> file descriptor object of our socket to the main loop in
> wl_display_add_socket that uses socket_data as the callback function when a
> client connects to that socket. Subsequently, we accept the connection in
> socket_data and create a new client.
> >
> > So, what is it in client's code that causes socket_data to be called? Is
> it just the mere connect() call to establish a connection through that
> socket or is it anything more complex that I have missed?
> >
> > My knowledge of sockets is quite basic, so I would be happy if someone
> would clarify how exactly this bit of code is executed.
> >
> > Regards,
> >
> > Zan Dobersek
> >
> >
> >
> > _______________________________________________
> > wayland-devel mailing list
> > wayland-devel at lists.freedesktop.org
> > http://lists.freedesktop.org/mailman/listinfo/wayland-devel
> _______________________________________________
> wayland-devel mailing list
> wayland-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/wayland-devel
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/wayland-devel/attachments/20110125/bbb97c83/attachment.htm>
More information about the wayland-devel
mailing list