aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLiu Ping Fan <qemulist@gmail.com>2013-08-25 10:01:20 +0800
committerJan Kiszka <jan.kiszka@siemens.com>2013-09-17 12:26:04 +0200
commitf8eebce425fc41f277e083e2e96b08e693b12de5 (patch)
tree1620571f1f3ca3ff3a4c7f3bfdab1d6b7938a401
parentcd0ec4933dca9b3a472640e2232725dcd7d3f1b3 (diff)
downloadslirp-f8eebce425fc41f277e083e2e96b08e693b12de5.zip
slirp-f8eebce425fc41f277e083e2e96b08e693b12de5.tar.gz
slirp-f8eebce425fc41f277e083e2e96b08e693b12de5.tar.bz2
slirp: define timeout as macro
Signed-off-by: Liu Ping Fan <pingfank@linux.vnet.ibm.com> Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
-rw-r--r--slirp.c17
1 files changed, 12 insertions, 5 deletions
diff --git a/slirp.c b/slirp.c
index 9327ccc..dc3e4a1 100644
--- a/slirp.c
+++ b/slirp.c
@@ -46,6 +46,11 @@ static QTAILQ_HEAD(slirp_instances, Slirp)
static struct in_addr dns_addr;
static u_int dns_addr_time;
+#define TIMEOUT_FAST 2 /* milliseconds */
+#define TIMEOUT_SLOW 499 /* milliseconds */
+/* for the aging of certain requests like DNS */
+#define TIMEOUT_DEFAULT 1000 /* milliseconds */
+
#ifdef _WIN32
int get_dns_addr(struct in_addr *pdns_addr)
@@ -56,7 +61,7 @@ int get_dns_addr(struct in_addr *pdns_addr)
IP_ADDR_STRING *pIPAddr;
struct in_addr tmp_addr;
- if (dns_addr.s_addr != 0 && (curtime - dns_addr_time) < 1000) {
+ if (dns_addr.s_addr != 0 && (curtime - dns_addr_time) < TIMEOUT_DEFAULT) {
*pdns_addr = dns_addr;
return 0;
}
@@ -112,7 +117,7 @@ int get_dns_addr(struct in_addr *pdns_addr)
if (dns_addr.s_addr != 0) {
struct stat old_stat;
- if ((curtime - dns_addr_time) < 1000) {
+ if ((curtime - dns_addr_time) < TIMEOUT_DEFAULT) {
*pdns_addr = dns_addr;
return 0;
}
@@ -261,7 +266,7 @@ void slirp_cleanup(Slirp *slirp)
void slirp_update_timeout(uint32_t *timeout)
{
if (!QTAILQ_EMPTY(&slirp_instances)) {
- *timeout = MIN(1000, *timeout);
+ *timeout = MIN(TIMEOUT_DEFAULT, *timeout);
}
}
@@ -450,11 +455,13 @@ void slirp_pollfds_poll(GArray *pollfds, int select_error)
/*
* See if anything has timed out
*/
- if (slirp->time_fasttimo && ((curtime - slirp->time_fasttimo) >= 2)) {
+ if (slirp->time_fasttimo &&
+ ((curtime - slirp->time_fasttimo) >= TIMEOUT_FAST)) {
tcp_fasttimo(slirp);
slirp->time_fasttimo = 0;
}
- if (slirp->do_slowtimo && ((curtime - slirp->last_slowtimo) >= 499)) {
+ if (slirp->do_slowtimo &&
+ ((curtime - slirp->last_slowtimo) >= TIMEOUT_SLOW)) {
ip_slowtimo(slirp);
tcp_slowtimo(slirp);
slirp->last_slowtimo = curtime;