From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:54947) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RXwxD-0002WD-Ev for qemu-devel@nongnu.org; Tue, 06 Dec 2011 10:29:17 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RXwwx-0000V8-No for qemu-devel@nongnu.org; Tue, 06 Dec 2011 10:29:01 -0500 Received: from mail-iy0-f173.google.com ([209.85.210.173]:40617) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RXwwx-0000A8-KU for qemu-devel@nongnu.org; Tue, 06 Dec 2011 10:28:55 -0500 Received: by mail-iy0-f173.google.com with SMTP id j26so193361iaf.4 for ; Tue, 06 Dec 2011 07:28:55 -0800 (PST) Sender: Paolo Bonzini From: Paolo Bonzini Date: Tue, 6 Dec 2011 16:27:40 +0100 Message-Id: <1323185272-2610-14-git-send-email-pbonzini@redhat.com> In-Reply-To: <1323185272-2610-1-git-send-email-pbonzini@redhat.com> References: <1323185272-2610-1-git-send-email-pbonzini@redhat.com> Subject: [Qemu-devel] [PATCH 13/25] move corking functions to osdep.c List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Signed-off-by: Paolo Bonzini --- block/sheepdog.c | 20 ++------------------ osdep.c | 9 +++++++++ qemu_socket.h | 1 + 3 files changed, 12 insertions(+), 18 deletions(-) diff --git a/block/sheepdog.c b/block/sheepdog.c index 00ea5a0..17a79be 100644 --- a/block/sheepdog.c +++ b/block/sheepdog.c @@ -702,22 +702,6 @@ static int aio_flush_request(void *opaque) return !QLIST_EMPTY(&s->outstanding_aio_head); } -#if !defined(SOL_TCP) || !defined(TCP_CORK) - -static int set_cork(int fd, int v) -{ - return 0; -} - -#else - -static int set_cork(int fd, int v) -{ - return setsockopt(fd, SOL_TCP, TCP_CORK, &v, sizeof(v)); -} - -#endif - static int set_nodelay(int fd) { int ret, opt; @@ -923,7 +907,7 @@ static int coroutine_fn add_aio_request(BDRVSheepdogState *s, AIOReq *aio_req, s->co_send = qemu_coroutine_self(); qemu_aio_set_fd_handler(s->fd, co_read_response, co_write_request, aio_flush_request, NULL, s); - set_cork(s->fd, 1); + socket_set_cork(s->fd, 1); /* send a header */ ret = qemu_co_send(s->fd, &hdr, sizeof(hdr)); @@ -942,7 +926,7 @@ static int coroutine_fn add_aio_request(BDRVSheepdogState *s, AIOReq *aio_req, } } - set_cork(s->fd, 0); + socket_set_cork(s->fd, 0); qemu_aio_set_fd_handler(s->fd, co_read_response, NULL, aio_flush_request, NULL, s); qemu_co_mutex_unlock(&s->lock); diff --git a/osdep.c b/osdep.c index 70bad27..3e6bada 100644 --- a/osdep.c +++ b/osdep.c @@ -48,6 +48,15 @@ extern int madvise(caddr_t, size_t, int); #include "trace.h" #include "qemu_socket.h" +int socket_set_cork(int fd, int v) +{ +#if defined(SOL_TCP) && defined(TCP_CORK) + return setsockopt(fd, SOL_TCP, TCP_CORK, &v, sizeof(v)); +#else + return 0; +#endif +} + int qemu_madvise(void *addr, size_t len, int advice) { if (advice == QEMU_MADV_INVALID) { diff --git a/qemu_socket.h b/qemu_socket.h index 9e32fac..fe4cf6c 100644 --- a/qemu_socket.h +++ b/qemu_socket.h @@ -35,6 +35,7 @@ int inet_aton(const char *cp, struct in_addr *ia); /* misc helpers */ int qemu_socket(int domain, int type, int protocol); int qemu_accept(int s, struct sockaddr *addr, socklen_t *addrlen); +int socket_set_cork(int fd, int v); void socket_set_block(int fd); void socket_set_nonblock(int fd); int send_all(int fd, const void *buf, int len1); -- 1.7.7.1