io/channel-socket: rework qio_channel_socket_copy_fds()
We want to switch from qemu_socket_set_block() to newer qemu_set_blocking(), which provides return status of operation, to handle errors. Still, we want to keep qio_channel_socket_readv() interface clean, as currently it allocate @fds only on success. So, in case of error, we should close all incoming fds and keep user's @fds untouched or zero. Let's make separate functions qio_channel_handle_fds() and qio_channel_cleanup_fds(), to achieve what we want. Reviewed-by: Daniel P. Berrangé <berrange@redhat.com> Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru> Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
This commit is contained in:
parent
09759245cf
commit
d14c8cc69d
2 changed files with 61 additions and 26 deletions
|
|
@ -124,8 +124,8 @@ struct QIOChannelClass {
|
|||
* incoming fds are set BLOCKING (unless
|
||||
* QIO_CHANNEL_READ_FLAG_FD_PRESERVE_BLOCKING flag is set) and
|
||||
* CLOEXEC (if available).
|
||||
* @fds and @nfds are set only on success path, and untouched
|
||||
* in case of errors.
|
||||
* @fds and @nfds are set only on success path. Still, setting
|
||||
* @fds and @nfds to zero is acceptable on failure path.
|
||||
*/
|
||||
ssize_t (*io_readv)(QIOChannel *ioc,
|
||||
const struct iovec *iov,
|
||||
|
|
@ -246,8 +246,8 @@ void qio_channel_set_name(QIOChannel *ioc,
|
|||
* to call close() on each file descriptor and to
|
||||
* call g_free() on the array pointer in @fds.
|
||||
* @fds allocated and set (and @nfds is set too)
|
||||
* _only_ on success path. These parameters are
|
||||
* untouched in case of errors.
|
||||
* _only_ on success path. Still, @fds and @nfds
|
||||
* may be set to zero on failure path.
|
||||
* qio_channel_readv_full() guarantees that all
|
||||
* incoming fds are set BLOCKING (unless
|
||||
* QIO_CHANNEL_READ_FLAG_FD_PRESERVE_BLOCKING flag
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue