[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Xen-devel] [PATCH v4 05/15] oxenstored: add support for systemd active sockets



On Mon, 2014-05-12 at 11:11 -0700, Luis R. Rodriguez wrote:
> >> +CAMLprim value ocaml_sd_listen_fds(value connect_to)
> >> +{
> >> +     CAMLparam1(connect_to);
> >> +     CAMLlocal1(sock_ret);
> >> +     int n, r;
> >> +     struct xen_systemd_active_socket *active_socket;
> >> +
> >> +     active_socket = get_xen_active_socket((const char *) 
> >> String_val(connect_to));
> >> +     if (!active_socket)
> >> +             caml_failwith("ocaml_sd_listen_fds() got invalid request");
> >
> > The sole purpose of this is to convert the string to an entry in the
> > the table ?  I.e., essentially, just the table index ?
> 
> A few things actually:
> 
>   1. Used to that the path is expected by the program / systemd
>   2. Lets then tell systemd we are ready for that socket
>   3. Verification of the integrity of the socket as we expected it to be set 
> up
>   4. Verification that we only get from systemd the number of sockets expected

I think this should be refactored to be something like:

        /* NB these should also be documented somewhere... */
        #define SOCKET_ACTIVATION_RW_INDEX 3
        #define SOCKET_ACTIVATION_RO_INDEX 4
        
        static int get_handle(int ro)
        {
                if (systemd_active())
                        return get_systemd_handle(ro ?
                                SOCKET_ACTIVATION_RO_INDEX : 
                                SOCKET_ACTIVATION_RW_INDEX);
                else
                        return get_unix_socket_handle(ro ?
                                xs_daemon_socket_ro() :
                                xs_daemon_socket());
        }
        
That's a rough outline and subject to coding style and my not having
looked at the actual naming conventions in that file etc. I suspect the
existing get_handle() needs to be refactored into something which
get_systemd_handle(), get_unix_socket_handle() and the xs_domain_dev()
path can all use.

Ian.


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.