[PATCH 3/3] os: Add AddClientOnOpenFD() to create a new client for an file descriptor

Peter Hutterer peter.hutterer at who-t.net
Wed Mar 19 16:29:18 PDT 2014


On Tue, Mar 18, 2014 at 10:06:00PM -0700, Kristian Høgsberg wrote:
> When the Xwayland server is socket-activated, we need to connect and
> initialize the window manager before the activating client gets to
> proceed with connecting.  We do this by passing a socket file
> descriptor for the window manager connection to the Xwayland server,
> which then uses this new function to set it up as an X client.
> 
> Signed-off-by: Kristian Høgsberg <krh at bitplanet.net>
> ---
>  include/os.h    |  2 ++
>  os/connection.c | 20 ++++++++++++++++++++
>  2 files changed, 22 insertions(+)
> 
> diff --git a/include/os.h b/include/os.h
> index 90229e6..5be3bcc 100644
> --- a/include/os.h
> +++ b/include/os.h
> @@ -168,6 +168,8 @@ extern _X_EXPORT void MakeClientGrabPervious(ClientPtr /*client */ );
>  
>  extern _X_EXPORT void ListenOnOpenFD(int /* fd */ , int /* noxauth */ );
>  
> +extern _X_EXPORT void AddClientOnOpenFD(int /* fd */ );
> +
>  extern _X_EXPORT CARD32 GetTimeInMillis(void);
>  extern _X_EXPORT CARD64 GetTimeInMicros(void);
>  
> diff --git a/os/connection.c b/os/connection.c
> index b50f9e9..f1e7a25 100644
> --- a/os/connection.c
> +++ b/os/connection.c
> @@ -1312,3 +1312,23 @@ ListenOnOpenFD(int fd, int noxauth)
>      XdmcpReset();
>  #endif
>  }
> +
> +/* based on TRANS(SocketUNIXAccept) (XtransConnInfo ciptr, int *status) */
> +void
> +AddClientOnOpenFD(int fd)
> +{
> +    XtransConnInfo ciptr;
> +    CARD32 connect_time;
> +
> +    ciptr = _XSERVTransReopenCOTSServer(5, fd, "@anonymous");
> +
> +    _XSERVTransSetOption(ciptr, TRANS_NONBLOCKING, 1);
> +    ciptr->flags |= TRANS_NOXAUTH;
> +
> +    connect_time = GetTimeInMillis();
> +
> +    if (!AllocNewConnection(ciptr, fd, connect_time)) {
> +        ErrorF(stderr, "failed to create client for wayland server\n");

ErrorF doesn't take a stream, so you can drop the first argument. Plus, a
more generic error message may be good, it's a bit confusing to see wayland
here when the actual function seems generic enough.

Cheers,
   Peter

> +        return;
> +    }
> +}
> -- 
> 1.9.0
> 
> _______________________________________________
> xorg-devel at lists.x.org: X.Org development
> Archives: http://lists.x.org/archives/xorg-devel
> Info: http://lists.x.org/mailman/listinfo/xorg-devel
> 


More information about the xorg-devel mailing list