diff mbox

[1/4] socket: Rationalise function declarations

Message ID 1261068295-25831-2-git-send-email-ian.molton@collabora.co.uk
State New
Headers show

Commit Message

Ian Molton Dec. 17, 2009, 4:44 p.m. UTC
This patch rationalises the declaration of inet_listen_opts such that
it matches the other inet_{listen,connect}_opts functions.

This change is needed for a patch adding socket reconection support.

Signed-off-by: Ian Molton <ian.molton@collabora.co.uk>
---
 qemu-sockets.c |    9 +++++++--
 qemu_socket.h  |    2 +-
 2 files changed, 8 insertions(+), 3 deletions(-)

Comments

Ian Molton Dec. 27, 2009, 10:29 p.m. UTC | #1
Ian Molton wrote:

Can I get the status of this patchset please ?

Thanks!

> 	This patch rationalises the declaration of inet_listen_opts such that
> it matches the other inet_{listen,connect}_opts functions.
> 
> This change is needed for a patch adding socket reconection support.
> 
> Signed-off-by: Ian Molton <ian.molton@collabora.co.uk>
> ---
>  qemu-sockets.c |    9 +++++++--
>  qemu_socket.h  |    2 +-
>  2 files changed, 8 insertions(+), 3 deletions(-)
> 
> diff --git a/qemu-sockets.c b/qemu-sockets.c
> index 8850516..ea338de 100644
> --- a/qemu-sockets.c
> +++ b/qemu-sockets.c
> @@ -116,7 +116,7 @@ static void inet_print_addrinfo(const char *tag, struct addrinfo *res)
>      }
>  }
>  
> -int inet_listen_opts(QemuOpts *opts, int port_offset)
> +static int do_inet_listen(QemuOpts *opts, int port_offset)
>  {
>      struct addrinfo ai,*res,*e;
>      const char *addr;
> @@ -216,6 +216,11 @@ listen:
>      return slisten;
>  }
>  
> +int inet_listen_opts(QemuOpts *opts)
> +{
> +    return do_inet_listen(opts, 0);
> +}
> +
>  int inet_connect_opts(QemuOpts *opts)
>  {
>      struct addrinfo ai,*res,*e;
> @@ -465,7 +470,7 @@ int inet_listen(const char *str, char *ostr, int olen,
>  
>      opts = qemu_opts_create(&dummy_opts, NULL, 0);
>      if (inet_parse(opts, str) == 0) {
> -        sock = inet_listen_opts(opts, port_offset);
> +        sock = do_inet_listen(opts, port_offset);
>          if (sock != -1 && ostr) {
>              optstr = strchr(str, ',');
>              if (qemu_opt_get_bool(opts, "ipv6", 0)) {
> diff --git a/qemu_socket.h b/qemu_socket.h
> index 86bdbf5..fd8b95b 100644
> --- a/qemu_socket.h
> +++ b/qemu_socket.h
> @@ -38,7 +38,7 @@ void socket_set_nonblock(int fd);
>  int send_all(int fd, const void *buf, int len1);
>  
>  /* New, ipv6-ready socket helper functions, see qemu-sockets.c */
> -int inet_listen_opts(QemuOpts *opts, int port_offset);
> +int inet_listen_opts(QemuOpts *opts);
>  int inet_listen(const char *str, char *ostr, int olen,
>                  int socktype, int port_offset);
>  int inet_connect_opts(QemuOpts *opts);
Anthony Liguori Jan. 4, 2010, 8:53 p.m. UTC | #2
On 12/27/2009 04:29 PM, Ian Molton wrote:
> Ian Molton wrote:
>
> Can I get the status of this patchset please ?

I really dislike the idea of automatically reconnecting a socket. 
Mainly because I'm not sure that you can have sane universal semantics 
for what to do while it's disconnected.

I would prefer a mechanism that allowed a user to manually reconnect a 
character device by basically reconnecting the full character device. 
IOW, reconnecting to tcp:localhost:1025 is the same thing as changing to 
unix:/tmp/foo.sock AFAICT.

Regards,

Anthony Liguori
diff mbox

Patch

diff --git a/qemu-sockets.c b/qemu-sockets.c
index 8850516..ea338de 100644
--- a/qemu-sockets.c
+++ b/qemu-sockets.c
@@ -116,7 +116,7 @@  static void inet_print_addrinfo(const char *tag, struct addrinfo *res)
     }
 }
 
-int inet_listen_opts(QemuOpts *opts, int port_offset)
+static int do_inet_listen(QemuOpts *opts, int port_offset)
 {
     struct addrinfo ai,*res,*e;
     const char *addr;
@@ -216,6 +216,11 @@  listen:
     return slisten;
 }
 
+int inet_listen_opts(QemuOpts *opts)
+{
+    return do_inet_listen(opts, 0);
+}
+
 int inet_connect_opts(QemuOpts *opts)
 {
     struct addrinfo ai,*res,*e;
@@ -465,7 +470,7 @@  int inet_listen(const char *str, char *ostr, int olen,
 
     opts = qemu_opts_create(&dummy_opts, NULL, 0);
     if (inet_parse(opts, str) == 0) {
-        sock = inet_listen_opts(opts, port_offset);
+        sock = do_inet_listen(opts, port_offset);
         if (sock != -1 && ostr) {
             optstr = strchr(str, ',');
             if (qemu_opt_get_bool(opts, "ipv6", 0)) {
diff --git a/qemu_socket.h b/qemu_socket.h
index 86bdbf5..fd8b95b 100644
--- a/qemu_socket.h
+++ b/qemu_socket.h
@@ -38,7 +38,7 @@  void socket_set_nonblock(int fd);
 int send_all(int fd, const void *buf, int len1);
 
 /* New, ipv6-ready socket helper functions, see qemu-sockets.c */
-int inet_listen_opts(QemuOpts *opts, int port_offset);
+int inet_listen_opts(QemuOpts *opts);
 int inet_listen(const char *str, char *ostr, int olen,
                 int socktype, int port_offset);
 int inet_connect_opts(QemuOpts *opts);