From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
To: qemu-block@nongnu.org
Cc: kwolf@redhat.com, vsementsov@virtuozzo.com, berrange@redhat.com,
qemu-devel@nongnu.org, mreitz@redhat.com, kraxel@redhat.com,
den@openvz.org
Subject: [PATCH 1/4] qemu-sockets: refactor inet_connect_addr
Date: Mon, 20 Jul 2020 21:07:12 +0300 [thread overview]
Message-ID: <20200720180715.10521-2-vsementsov@virtuozzo.com> (raw)
In-Reply-To: <20200720180715.10521-1-vsementsov@virtuozzo.com>
We are going to publish inet_connect_addr to be used in separate. Let's
move keep_alive handling to it. Pass the whole InetSocketAddress
pointer, not only keep_alive, so that future external callers will not
care about internals of InetSocketAddress.
While being here, remove redundant inet_connect_addr() declaration.
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
---
util/qemu-sockets.c | 37 ++++++++++++++++---------------------
1 file changed, 16 insertions(+), 21 deletions(-)
diff --git a/util/qemu-sockets.c b/util/qemu-sockets.c
index b37d288866..8ccf4088c2 100644
--- a/util/qemu-sockets.c
+++ b/util/qemu-sockets.c
@@ -354,9 +354,8 @@ listen_ok:
((rc) == -EINPROGRESS)
#endif
-static int inet_connect_addr(struct addrinfo *addr, Error **errp);
-
-static int inet_connect_addr(struct addrinfo *addr, Error **errp)
+static int inet_connect_addr(InetSocketAddress *saddr,
+ struct addrinfo *addr, Error **errp)
{
int sock, rc;
@@ -381,6 +380,18 @@ static int inet_connect_addr(struct addrinfo *addr, Error **errp)
return -1;
}
+ if (saddr->keep_alive) {
+ int val = 1;
+ int ret = qemu_setsockopt(sock, SOL_SOCKET, SO_KEEPALIVE,
+ &val, sizeof(val));
+
+ if (ret < 0) {
+ error_setg_errno(errp, errno, "Unable to set KEEPALIVE");
+ closesocket(sock);
+ return -1;
+ }
+ }
+
return sock;
}
@@ -455,7 +466,7 @@ int inet_connect_saddr(InetSocketAddress *saddr, Error **errp)
for (e = res; e != NULL; e = e->ai_next) {
error_free(local_err);
local_err = NULL;
- sock = inet_connect_addr(e, &local_err);
+ sock = inet_connect_addr(saddr, e, &local_err);
if (sock >= 0) {
break;
}
@@ -463,23 +474,7 @@ int inet_connect_saddr(InetSocketAddress *saddr, Error **errp)
freeaddrinfo(res);
- if (sock < 0) {
- error_propagate(errp, local_err);
- return sock;
- }
-
- if (saddr->keep_alive) {
- int val = 1;
- int ret = qemu_setsockopt(sock, SOL_SOCKET, SO_KEEPALIVE,
- &val, sizeof(val));
-
- if (ret < 0) {
- error_setg_errno(errp, errno, "Unable to set KEEPALIVE");
- close(sock);
- return -1;
- }
- }
-
+ error_propagate(errp, local_err);
return sock;
}
--
2.21.0
next prev parent reply other threads:[~2020-07-20 18:08 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-07-20 18:07 [PATCH for-5.1? 0/4] non-blocking connect Vladimir Sementsov-Ogievskiy
2020-07-20 18:07 ` Vladimir Sementsov-Ogievskiy [this message]
2020-07-20 18:07 ` [PATCH 2/4] qemu-sockets: implement non-blocking connect interface Vladimir Sementsov-Ogievskiy
2020-07-20 18:07 ` [PATCH 3/4] io/channel-socket: implement non-blocking connect Vladimir Sementsov-Ogievskiy
2020-07-20 18:29 ` Daniel P. Berrangé
2020-07-22 11:00 ` Vladimir Sementsov-Ogievskiy
2020-07-22 11:21 ` Daniel P. Berrangé
2020-07-22 12:43 ` Vladimir Sementsov-Ogievskiy
2020-07-22 12:53 ` Daniel P. Berrangé
2020-07-22 13:47 ` Vladimir Sementsov-Ogievskiy
2020-07-22 15:04 ` Vladimir Sementsov-Ogievskiy
2020-07-22 15:21 ` Daniel P. Berrangé
2020-07-22 15:40 ` Vladimir Sementsov-Ogievskiy
2020-07-22 15:43 ` Daniel P. Berrangé
2020-07-22 15:56 ` Vladimir Sementsov-Ogievskiy
2020-07-20 18:07 ` [PATCH 4/4] block/nbd: use non-blocking connect: fix vm hang on connect() Vladimir Sementsov-Ogievskiy
2020-07-23 19:35 ` [PATCH for-5.1? 0/4] non-blocking connect Eric Blake
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200720180715.10521-2-vsementsov@virtuozzo.com \
--to=vsementsov@virtuozzo.com \
--cc=berrange@redhat.com \
--cc=den@openvz.org \
--cc=kraxel@redhat.com \
--cc=kwolf@redhat.com \
--cc=mreitz@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).