* Paolo Bonzini (pbonz...@redhat.com) 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). --- 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 / dgilb...@redhat.com / Manchester, UK