[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH v4 08/47] socket shutdown
From: |
Paolo Bonzini |
Subject: |
Re: [Qemu-devel] [PATCH v4 08/47] socket shutdown |
Date: |
Tue, 07 Oct 2014 13:10:33 +0200 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.1.1 |
Il 07/10/2014 12:00, Dr. David Alan Gilbert ha scritto:
> * Paolo Bonzini (address@hidden) wrote:
>> Il 03/10/2014 19:47, Dr. David Alan Gilbert (git) ha scritto:
>>> +#ifndef WIN32
>>> + if (rd) {
>>> + how = SHUT_RD;
>>> + }
>>> +
>>> + if (wr) {
>>> + how = rd ? SHUT_RDWR : SHUT_WR;
>>> + }
>>> +
>>> +#else
>>> + /* Untested */
>>> + if (rd) {
>>> + how = SD_RECEIVE;
>>> + }
>>> +
>>> + if (wr) {
>>> + how = rd ? SD_BOTH : SD_SEND;
>>> + }
>>> +
>>> +#endif
>>> +
>>
>>
>> These are the same on Windows and non-Windows actually. Just #define
>> SHUT_* to 0/1/2 and avoid the wrapper.
>
> OK, something like this? (the qemu-file.c abstraction is still needed
> to cover QEMUFile's that aren't simple sockets, but I've removed the
> second layer in util/qemu-sockets.c).
Yes. Or just pass SHUT_* directly to socket_shutdown, of course.
Paolo
>
> --- a/include/qemu/sockets.h
> +++ b/include/qemu/sockets.h
> @@ -44,6 +44,13 @@ int socket_set_fast_reuse(int fd);
> int send_all(int fd, const void *buf, int len1);
> int recv_all(int fd, void *buf, int len1, bool single_read);
>
> +#ifdef WIN32
> +/* Windows has different names for the same constants with the same values */
> +#define SHUT_RD 0
> +#define SHUT_WR 1
> +#define SHUT_RDWR 2
> +#endif
> +
> /* callback function for nonblocking connect
> * valid fd on success, negative error code on failure
> */
>
> --- a/qemu-file.c
> +++ b/qemu-file.c
> @@ -90,6 +90,13 @@ static int socket_close(void *opaque)
> return 0;
> }
>
> +static int socket_shutdown(void *opaque, bool rd, bool wr)
> +{
> + QEMUFileSocket *s = opaque;
> +
> + return shutdown(s->fd, rd ? (wr ? SHUT_RDWR : SHUT_RD) : SHUT_WR);
> +}
> +
> static int stdio_get_fd(void *opaque)
> {
> QEMUFileStdio *s = opaque;
> --
> Dr. David Alan Gilbert / address@hidden / Manchester, UK
>
- Re: [Qemu-devel] [PATCH v4 01/47] QEMUSizedBuffer based QEMUFile, (continued)
- [Qemu-devel] [PATCH v4 02/47] Tests: QEMUSizedBuffer/QEMUBuffer, Dr. David Alan Gilbert (git), 2014/10/03
- [Qemu-devel] [PATCH v4 03/47] Start documenting how postcopy works., Dr. David Alan Gilbert (git), 2014/10/03
- [Qemu-devel] [PATCH v4 05/47] improve DPRINTF macros, add to savevm, Dr. David Alan Gilbert (git), 2014/10/03
- [Qemu-devel] [PATCH v4 04/47] qemu_ram_foreach_block: pass up error value, and down the ramblock name, Dr. David Alan Gilbert (git), 2014/10/03
- [Qemu-devel] [PATCH v4 06/47] Add qemu_get_counted_string to read a string prefixed by a count byte, Dr. David Alan Gilbert (git), 2014/10/03
- [Qemu-devel] [PATCH v4 07/47] Create MigrationIncomingState, Dr. David Alan Gilbert (git), 2014/10/03
- [Qemu-devel] [PATCH v4 08/47] socket shutdown, Dr. David Alan Gilbert (git), 2014/10/03
- [Qemu-devel] [PATCH v4 09/47] Provide runtime Target page information, Dr. David Alan Gilbert (git), 2014/10/03
- [Qemu-devel] [PATCH v4 10/47] Return path: Open a return path on QEMUFile for sockets, Dr. David Alan Gilbert (git), 2014/10/03
- [Qemu-devel] [PATCH v4 12/47] Handle bi-directional communication for fd migration, Dr. David Alan Gilbert (git), 2014/10/03
- [Qemu-devel] [PATCH v4 11/47] Return path: socket_writev_buffer: Block even on non-blocking fd's, Dr. David Alan Gilbert (git), 2014/10/03
- [Qemu-devel] [PATCH v4 13/47] Migration commands, Dr. David Alan Gilbert (git), 2014/10/03
- [Qemu-devel] [PATCH v4 14/47] Return path: Control commands, Dr. David Alan Gilbert (git), 2014/10/03
[Qemu-devel] [PATCH v4 16/47] Return path: Source handling of return path, Dr. David Alan Gilbert (git), 2014/10/03