[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH V2 17/22] chardev: socket accept subroutine
From: |
Steve Sistare |
Subject: |
[PATCH V2 17/22] chardev: socket accept subroutine |
Date: |
Tue, 5 Jan 2021 07:42:05 -0800 |
Factor out the post-accept actions into a subroutine that can be used in a
subsequent patch. No functional change.
Signed-off-by: Steve Sistare <steven.sistare@oracle.com>
---
io/channel-socket.c | 43 ++++++++++++++++++++++++-------------------
1 file changed, 24 insertions(+), 19 deletions(-)
diff --git a/io/channel-socket.c b/io/channel-socket.c
index e1b4667..de49880 100644
--- a/io/channel-socket.c
+++ b/io/channel-socket.c
@@ -349,16 +349,34 @@ void qio_channel_socket_dgram_async(QIOChannelSocket *ioc,
context);
}
+static int qio_channel_socket_post_accept(QIOChannelSocket *cioc,
+ Error **errp)
+{
+ cioc->localAddrLen = sizeof(cioc->localAddr);
+ if (getsockname(cioc->fd, (struct sockaddr *)&cioc->localAddr,
+ &cioc->localAddrLen) < 0) {
+ error_setg_errno(errp, errno,
+ "Unable to query local socket address");
+ return 1;
+ }
+
+#ifndef WIN32
+ if (cioc->localAddr.ss_family == AF_UNIX) {
+ QIOChannel *ioc_local = QIO_CHANNEL(cioc);
+ qio_channel_set_feature(ioc_local, QIO_CHANNEL_FEATURE_FD_PASS);
+ }
+#endif /* WIN32 */
+
+ return 0;
+}
QIOChannelSocket *
qio_channel_socket_accept(QIOChannelSocket *ioc,
Error **errp)
{
- QIOChannelSocket *cioc;
+ QIOChannelSocket *cioc = qio_channel_socket_new();
- cioc = qio_channel_socket_new();
cioc->remoteAddrLen = sizeof(ioc->remoteAddr);
- cioc->localAddrLen = sizeof(ioc->localAddr);
retry:
trace_qio_channel_socket_accept(ioc);
@@ -372,24 +390,11 @@ qio_channel_socket_accept(QIOChannelSocket *ioc,
trace_qio_channel_socket_accept_fail(ioc);
goto error;
}
-
- if (getsockname(cioc->fd, (struct sockaddr *)&cioc->localAddr,
- &cioc->localAddrLen) < 0) {
- error_setg_errno(errp, errno,
- "Unable to query local socket address");
- goto error;
+ if (!qio_channel_socket_post_accept(cioc, errp)) {
+ trace_qio_channel_socket_accept_complete(ioc, cioc, cioc->fd);
+ return cioc;
}
-#ifndef WIN32
- if (cioc->localAddr.ss_family == AF_UNIX) {
- QIOChannel *ioc_local = QIO_CHANNEL(cioc);
- qio_channel_set_feature(ioc_local, QIO_CHANNEL_FEATURE_FD_PASS);
- }
-#endif /* WIN32 */
-
- trace_qio_channel_socket_accept_complete(ioc, cioc, cioc->fd);
- return cioc;
-
error:
object_unref(OBJECT(cioc));
return NULL;
--
1.8.3.1
- Re: [PATCH V2 05/22] vl: memfd-alloc option, (continued)
[PATCH V2 12/22] vfio-pci: cpr, Steve Sistare, 2021/01/05
[PATCH V2 16/22] chardev: cpr for pty, Steve Sistare, 2021/01/05
[PATCH V2 18/22] chardev: cpr for sockets, Steve Sistare, 2021/01/05
[PATCH V2 19/22] monitor: cpr support, Steve Sistare, 2021/01/05
[PATCH V2 17/22] chardev: socket accept subroutine,
Steve Sistare <=
[PATCH V2 20/22] cpr: only-cpr-capable option, Steve Sistare, 2021/01/05
[PATCH V2 22/22] simplify savevm, Steve Sistare, 2021/01/05
[PATCH V2 14/22] chardev: cpr framework, Steve Sistare, 2021/01/05
[PATCH V2 21/22] cpr: maintainers, Steve Sistare, 2021/01/05
[PATCH V2 02/22] qemu_ram_volatile, Steve Sistare, 2021/01/05
[PATCH V2 13/22] vhost: reset vhost devices upon cprsave, Steve Sistare, 2021/01/05
[PATCH V2 01/22] as_flat_walk, Steve Sistare, 2021/01/05
[PATCH V2 11/22] vfio-pci: refactor for cpr, Steve Sistare, 2021/01/05
[PATCH V2 15/22] chardev: cpr for simple devices, Steve Sistare, 2021/01/05