From patchwork Tue Aug 13 03:15:39 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: pingfan liu X-Patchwork-Id: 266688 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (unknown [IPv6:2001:4830:134:3::12]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 6CDC52C0149 for ; Tue, 13 Aug 2013 13:17:04 +1000 (EST) Received: from localhost ([::1]:51589 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V956U-0004o6-AN for incoming@patchwork.ozlabs.org; Mon, 12 Aug 2013 23:17:02 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41472) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V955z-0004bY-OR for qemu-devel@nongnu.org; Mon, 12 Aug 2013 23:16:40 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1V955r-0007dc-5R for qemu-devel@nongnu.org; Mon, 12 Aug 2013 23:16:31 -0400 Received: from mail-pa0-x229.google.com ([2607:f8b0:400e:c03::229]:49654) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V955q-0007dW-VQ for qemu-devel@nongnu.org; Mon, 12 Aug 2013 23:16:23 -0400 Received: by mail-pa0-f41.google.com with SMTP id bj1so8357768pad.14 for ; Mon, 12 Aug 2013 20:16:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=+kpdc+ZyRXiCP67quVEJ0XGp75Vhg1+yU23VD5zOE5g=; b=JI93sYHOjOwUXnLDr228Zx1+A1zUliTX4JrUIfd0oiTT+nG+kumr2PlPNJRy9AG4aW tiglQokXio63MMckPzKdgvnSUJdIrFn8Py+2RlLFhFmgE1oiD7IZb9ge+htwXECM+pzV IdHhyhbMKZ4YEoXjo+DHkmPYbqj7JYJwQlHaynfGvsf9zKHOy/MEQ+7T6TXyDuXB/IT6 rgvomGRSuHk5FEdJIubT5qecO0GJ66jL0/xoDyRn/hsXMsWgbNfvlxOT/MPxrlgV9DdP qTvOWiRC4RnyNBhT2QNfXrztC2SodcRjD4DmT4gbXdjzU1g5PyR5L4lDmqsvAleKavP8 IC7Q== X-Received: by 10.66.76.34 with SMTP id h2mr2174729paw.128.1376363782242; Mon, 12 Aug 2013 20:16:22 -0700 (PDT) Received: from localhost ([202.108.130.138]) by mx.google.com with ESMTPSA id ut7sm9632113pbc.31.2013.08.12.20.16.19 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Mon, 12 Aug 2013 20:16:20 -0700 (PDT) From: Liu Ping Fan To: qemu-devel@nongnu.org Date: Tue, 13 Aug 2013 11:15:39 +0800 Message-Id: <1376363741-19420-2-git-send-email-pingfank@linux.vnet.ibm.com> X-Mailer: git-send-email 1.8.1.4 In-Reply-To: <1376363741-19420-1-git-send-email-pingfank@linux.vnet.ibm.com> References: <1376363741-19420-1-git-send-email-pingfank@linux.vnet.ibm.com> X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2607:f8b0:400e:c03::229 Cc: Paolo Bonzini , Stefan Hajnoczi , Jan Kiszka Subject: [Qemu-devel] [PATCH 1/3] slirp: make timeout local X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Each slirp has its own time to caculate timeout. Signed-off-by: Liu Ping Fan --- slirp/slirp.c | 22 ++++++++++------------ slirp/slirp.h | 3 +++ 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/slirp/slirp.c b/slirp/slirp.c index 80b28ea..55654d5 100644 --- a/slirp/slirp.c +++ b/slirp/slirp.c @@ -40,8 +40,6 @@ static const uint8_t special_ethaddr[ETH_ALEN] = { static const uint8_t zero_ethaddr[ETH_ALEN] = { 0, 0, 0, 0, 0, 0 }; u_int curtime; -static u_int time_fasttimo, last_slowtimo; -static int do_slowtimo; static QTAILQ_HEAD(slirp_instances, Slirp) slirp_instances = QTAILQ_HEAD_INITIALIZER(slirp_instances); @@ -278,14 +276,13 @@ void slirp_pollfds_fill(GArray *pollfds) /* * First, TCP sockets */ - do_slowtimo = 0; QTAILQ_FOREACH(slirp, &slirp_instances, entry) { /* * *_slowtimo needs calling if there are IP fragments * in the fragment queue, or there are TCP connections active */ - do_slowtimo |= ((slirp->tcb.so_next != &slirp->tcb) || + slirp->do_slowtimo = ((slirp->tcb.so_next != &slirp->tcb) || (&slirp->ipq.ip_link != slirp->ipq.ip_link.next)); for (so = slirp->tcb.so_next; so != &slirp->tcb; @@ -299,8 +296,9 @@ void slirp_pollfds_fill(GArray *pollfds) /* * See if we need a tcp_fasttimo */ - if (time_fasttimo == 0 && so->so_tcpcb->t_flags & TF_DELACK) { - time_fasttimo = curtime; /* Flag when we want a fasttimo */ + if (slirp->time_fasttimo == 0 && + so->so_tcpcb->t_flags & TF_DELACK) { + slirp->time_fasttimo = curtime; /* Flag when want a fasttimo */ } /* @@ -381,7 +379,7 @@ void slirp_pollfds_fill(GArray *pollfds) udp_detach(so); continue; } else { - do_slowtimo = 1; /* Let socket expire */ + slirp->do_slowtimo = 1; /* Let socket expire */ } } @@ -422,7 +420,7 @@ void slirp_pollfds_fill(GArray *pollfds) icmp_detach(so); continue; } else { - do_slowtimo = 1; /* Let socket expire */ + slirp->do_slowtimo = 1; /* Let socket expire */ } } @@ -454,14 +452,14 @@ void slirp_pollfds_poll(GArray *pollfds, int select_error) /* * See if anything has timed out */ - if (time_fasttimo && ((curtime - time_fasttimo) >= 2)) { + if (slirp->time_fasttimo && ((curtime - slirp->time_fasttimo) >= 2)) { tcp_fasttimo(slirp); - time_fasttimo = 0; + slirp->time_fasttimo = 0; } - if (do_slowtimo && ((curtime - last_slowtimo) >= 499)) { + if (slirp->do_slowtimo && ((curtime - slirp->last_slowtimo) >= 499)) { ip_slowtimo(slirp); tcp_slowtimo(slirp); - last_slowtimo = curtime; + slirp->last_slowtimo = curtime; } /* diff --git a/slirp/slirp.h b/slirp/slirp.h index fe0e65d..008360e 100644 --- a/slirp/slirp.h +++ b/slirp/slirp.h @@ -203,6 +203,9 @@ bool arp_table_search(Slirp *slirp, uint32_t ip_addr, struct Slirp { QTAILQ_ENTRY(Slirp) entry; + u_int time_fasttimo; + u_int last_slowtimo; + int do_slowtimo; /* virtual network configuration */ struct in_addr vnetwork_addr;