diff options
author | Felipe Franciosi <felipe@nutanix.com> | 2016-09-29 08:52:37 -0700 |
---|---|---|
committer | Daniel P. Berrange <berrange@redhat.com> | 2016-10-26 18:19:53 +0200 |
commit | d8d3c7cc672d89b26180a404d6f0b03494160cf5 (patch) | |
tree | 535d38ccf68e12031a5bda318753a145c264428b /io | |
parent | e413ae0c0492c10d9277a1155ecc21fbbf0e2bc7 (diff) |
io: Introduce a qio_channel_set_feature() helper
Testing QIOChannel feature support can be done with a helper called
qio_channel_has_feature(). Setting feature support, however, was
done manually with a logical OR. This patch introduces a new helper
called qio_channel_set_feature() and makes use of it where applicable.
Signed-off-by: Felipe Franciosi <felipe@nutanix.com>
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
Diffstat (limited to 'io')
-rw-r--r-- | io/channel-socket.c | 9 | ||||
-rw-r--r-- | io/channel-tls.c | 2 | ||||
-rw-r--r-- | io/channel-websock.c | 2 | ||||
-rw-r--r-- | io/channel.c | 7 |
4 files changed, 14 insertions, 6 deletions
diff --git a/io/channel-socket.c b/io/channel-socket.c index 8fc6e5aaaa..75cbca3c55 100644 --- a/io/channel-socket.c +++ b/io/channel-socket.c @@ -55,7 +55,7 @@ qio_channel_socket_new(void) sioc->fd = -1; ioc = QIO_CHANNEL(sioc); - ioc->features |= (1 << QIO_CHANNEL_FEATURE_SHUTDOWN); + qio_channel_set_feature(ioc, QIO_CHANNEL_FEATURE_SHUTDOWN); #ifdef WIN32 ioc->event = CreateEvent(NULL, FALSE, FALSE, NULL); @@ -107,12 +107,12 @@ qio_channel_socket_set_fd(QIOChannelSocket *sioc, #ifndef WIN32 if (sioc->localAddr.ss_family == AF_UNIX) { QIOChannel *ioc = QIO_CHANNEL(sioc); - ioc->features |= (1 << QIO_CHANNEL_FEATURE_FD_PASS); + qio_channel_set_feature(ioc, QIO_CHANNEL_FEATURE_FD_PASS); } #endif /* WIN32 */ if (getsockopt(fd, SOL_SOCKET, SO_ACCEPTCONN, &val, &len) == 0 && val) { QIOChannel *ioc = QIO_CHANNEL(sioc); - ioc->features |= (1 << QIO_CHANNEL_FEATURE_LISTEN); + qio_channel_set_feature(ioc, QIO_CHANNEL_FEATURE_LISTEN); } return 0; @@ -380,7 +380,8 @@ qio_channel_socket_accept(QIOChannelSocket *ioc, #ifndef WIN32 if (cioc->localAddr.ss_family == AF_UNIX) { - QIO_CHANNEL(cioc)->features |= (1 << QIO_CHANNEL_FEATURE_FD_PASS); + QIOChannel *ioc_local = QIO_CHANNEL(cioc); + qio_channel_set_feature(ioc_local, QIO_CHANNEL_FEATURE_FD_PASS); } #endif /* WIN32 */ diff --git a/io/channel-tls.c b/io/channel-tls.c index f7bb0e3698..d24dc8c613 100644 --- a/io/channel-tls.c +++ b/io/channel-tls.c @@ -112,7 +112,7 @@ qio_channel_tls_new_client(QIOChannel *master, tioc->master = master; if (qio_channel_has_feature(master, QIO_CHANNEL_FEATURE_SHUTDOWN)) { - ioc->features |= (1 << QIO_CHANNEL_FEATURE_SHUTDOWN); + qio_channel_set_feature(ioc, QIO_CHANNEL_FEATURE_SHUTDOWN); } object_ref(OBJECT(master)); diff --git a/io/channel-websock.c b/io/channel-websock.c index 75df03ef29..f45bced82a 100644 --- a/io/channel-websock.c +++ b/io/channel-websock.c @@ -498,7 +498,7 @@ qio_channel_websock_new_server(QIOChannel *master) wioc->master = master; if (qio_channel_has_feature(master, QIO_CHANNEL_FEATURE_SHUTDOWN)) { - ioc->features |= (1 << QIO_CHANNEL_FEATURE_SHUTDOWN); + qio_channel_set_feature(ioc, QIO_CHANNEL_FEATURE_SHUTDOWN); } object_ref(OBJECT(master)); diff --git a/io/channel.c b/io/channel.c index e50325c3f7..d1f1ae5157 100644 --- a/io/channel.c +++ b/io/channel.c @@ -30,6 +30,13 @@ bool qio_channel_has_feature(QIOChannel *ioc, } +void qio_channel_set_feature(QIOChannel *ioc, + QIOChannelFeature feature) +{ + ioc->features |= (1 << feature); +} + + ssize_t qio_channel_readv_full(QIOChannel *ioc, const struct iovec *iov, size_t niov, |