[Spice-devel] [PATCH 4/6] Add APIs for injecting a client connection socket

Marc-André Lureau marcandre.lureau at gmail.com
Wed Oct 26 06:30:03 PDT 2011


Hi

To avoid duplication, it would be nice to make internal code use
spice_server_add_client(), in reds_accept() for example.

On Fri, Oct 21, 2011 at 5:11 PM, Daniel P. Berrange <berrange at redhat.com> wrote:
> +
> +int spice_server_add_client(SpiceServer *s, int socket)

Missing SPICE_GNUC_VISIBLE, coming in following patch

> +{
> +    RedLinkInfo *link;
> +    RedsStream *stream;
> +
> +    if (!(link = reds_init_client_connection(socket))) {
> +        red_printf("accept failed");
> +        return -1;
> +    }
> +
> +    stream = link->stream;
> +    stream->read = stream_read_cb;
> +    stream->write = stream_write_cb;
> +    stream->writev = stream_writev_cb;

This should move to reds_init_client_connection(), as proposed earlier.

> +
> +    reds_handle_new_link(link);
> +    return 0;
> +}
> +
> +
> +int spice_server_add_ssl_client(SpiceServer *s, int socket)
> +{
> +    RedLinkInfo *link;
> +
> +    if (!(link = reds_init_client_ssl_connection(socket))) {
> +        return -1;
> +    }
> +    return 0;
> +}
> +
> +
>  static int reds_init_socket(const char *addr, int portnr, int family)
>  {
>     static const int on=1, off=0;
> diff --git a/server/spice-server.syms b/server/spice-server.syms
> index f1374bd..c34ff86 100644
> --- a/server/spice-server.syms
> +++ b/server/spice-server.syms
> @@ -89,5 +89,7 @@ global:
>     spice_server_record_set_mute;
>     spice_server_record_set_volume;
>     spice_server_get_num_clients;
> +    spice_server_add_client;
> +    spice_server_add_ssl_client;
>  } SPICE_SERVER_0.8.2;
>
> diff --git a/server/spice.h b/server/spice.h
> index 74f9fdb..25c9278 100644
> --- a/server/spice.h
> +++ b/server/spice.h
> @@ -425,6 +425,9 @@ int spice_server_set_tls(SpiceServer *s, int port,
>                          const char *private_key_file, const char *key_passwd,
>                          const char *dh_key_file, const char *ciphersuite);
>
> +int spice_server_add_client(SpiceServer *s, int socket);
> +int spice_server_add_ssl_client(SpiceServer *s, int socket);
> +
>  int spice_server_add_interface(SpiceServer *s,
>                                SpiceBaseInstance *sin);
>  int spice_server_remove_interface(SpiceBaseInstance *sin);
> --
> 1.7.6.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