[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH v2 2/3] Separate inet_connect into inet_connect
From: |
Markus Armbruster |
Subject: |
Re: [Qemu-devel] [PATCH v2 2/3] Separate inet_connect into inet_connect (blocking) and inet_nonblocking_connect |
Date: |
Thu, 13 Sep 2012 14:44:37 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.1 (gnu/linux) |
Orit Wasserman <address@hidden> writes:
> No need to add non blocking parameters to the blocking inet_connect
>
> Signed-off-by: Orit Wasserman <address@hidden>
> ---
> migration-tcp.c | 2 +-
> nbd.c | 2 +-
> qemu-sockets.c | 24 ++++++++++++++++++++----
> qemu_socket.h | 4 +++-
> ui/vnc.c | 2 +-
> 5 files changed, 26 insertions(+), 8 deletions(-)
>
> diff --git a/migration-tcp.c b/migration-tcp.c
> index ac891c3..7f6ad98 100644
> --- a/migration-tcp.c
> +++ b/migration-tcp.c
> @@ -88,7 +88,7 @@ int tcp_start_outgoing_migration(MigrationState *s, const
> char *host_port,
> s->write = socket_write;
> s->close = tcp_close;
>
> - s->fd = inet_connect(host_port, false, &in_progress, errp);
> + s->fd = inet_nonblocking_connect(host_port, &in_progress, errp);
> if (error_is_set(errp)) {
> migrate_fd_error(s);
> return -1;
> diff --git a/nbd.c b/nbd.c
> index 0dd60c5..206f75c 100644
> --- a/nbd.c
> +++ b/nbd.c
> @@ -162,7 +162,7 @@ int tcp_socket_outgoing(const char *address, uint16_t
> port)
>
> int tcp_socket_outgoing_spec(const char *address_and_port)
> {
> - return inet_connect(address_and_port, true, NULL, NULL);
> + return inet_connect(address_and_port, NULL);
> }
>
> int tcp_socket_incoming(const char *address, uint16_t port)
> diff --git a/qemu-sockets.c b/qemu-sockets.c
> index 68e4d30..4f5eca8 100644
> --- a/qemu-sockets.c
> +++ b/qemu-sockets.c
> @@ -518,16 +518,32 @@ int inet_listen(const char *str, char *ostr, int olen,
> return sock;
> }
>
> -int inet_connect(const char *str, bool block, bool *in_progress, Error
> **errp)
> +int inet_connect(const char *str, Error **errp)
> {
> QemuOpts *opts;
> int sock = -1;
>
> opts = qemu_opts_create(&dummy_opts, NULL, 0, NULL);
> if (inet_parse(opts, str) == 0) {
> - if (block) {
> - qemu_opt_set(opts, "block", "on");
> - }
> + qemu_opt_set(opts, "block", "on");
> + sock = inet_connect_opts(opts, NULL, errp);
Let's go one step further: make inet_connect_opts() take a bool block
argument, and drop the stupid QemuOpt "block". That way, opts are again
for user options only.
> + } else {
> + error_set(errp, QERR_SOCKET_CREATE_FAILED);
> + }
> + qemu_opts_del(opts);
> + return sock;
> +}
> +
> +
> +int inet_nonblocking_connect(const char *str, bool *in_progress,
> + Error **errp)
> +{
> + QemuOpts *opts;
> + int sock = -1;
> +
> + opts = qemu_opts_create(&dummy_opts, NULL, 0, NULL);
> + if (inet_parse(opts, str) == 0) {
> + qemu_opt_set(opts, "block", "off");
> sock = inet_connect_opts(opts, in_progress, errp);
> } else {
> error_set(errp, QERR_SOCKET_CREATE_FAILED);
[...]
- Re: [Qemu-devel] [PATCH v2 1/3] Refactor inet_connect_opts function, (continued)
Re: [Qemu-devel] [PATCH v2 1/3] Refactor inet_connect_opts function, Markus Armbruster, 2012/09/13
[Qemu-devel] [PATCH v2 3/3] Fix address handling in inet_nonblocking_connect, Orit Wasserman, 2012/09/12
[Qemu-devel] [PATCH v2 2/3] Separate inet_connect into inet_connect (blocking) and inet_nonblocking_connect, Orit Wasserman, 2012/09/12
- Re: [Qemu-devel] [PATCH v2 2/3] Separate inet_connect into inet_connect (blocking) and inet_nonblocking_connect,
Markus Armbruster <=
Re: [Qemu-devel] [PATCH v2 0/3] nonblocking connect address handling cleanup, Amos Kong, 2012/09/12
Re: [Qemu-devel] [PATCH v2 0/3] nonblocking connect address handling cleanup, Michael S. Tsirkin, 2012/09/12