From 8bf4bbe390af3f370e7e95d9237572ff750047a8 Mon Sep 17 00:00:00 2001 From: Ben Pfaff Date: Wed, 12 May 2010 10:56:45 -0700 Subject: poll-loop: Change poll_timer_wait() parameter from "int" to "long long". Every so often I get concerned because OVS does most of its time arithmetic in "long long int" but poll_timer_wait() takes an "int", so there is potential for truncating a large value to a small value or a positive value to a negative value. That would cause excessive wakeups and possibly 100% CPU usage. This commit therefore changes poll_timer_wait()'s parameter type from "int" to "long long int". The file-scope 'timeout' variable remains type "int" because that is the type of poll()'s timeout argument. Factoring poll_timer_wait() into two functions is not necessary here but it comes in handy in the following patch. --- ovsdb/trigger.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'ovsdb/trigger.c') diff --git a/ovsdb/trigger.c b/ovsdb/trigger.c index 1ecfdcac1..8f18291f4 100644 --- a/ovsdb/trigger.c +++ b/ovsdb/trigger.c @@ -1,4 +1,4 @@ -/* Copyright (c) 2009 Nicira Networks +/* Copyright (c) 2009, 2010 Nicira Networks * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -102,7 +102,7 @@ ovsdb_trigger_wait(struct ovsdb *db, long long int now) } if (deadline < LLONG_MAX) { - poll_timer_wait(MIN(deadline - now, INT_MAX)); + poll_timer_wait(deadline - now); } } } -- cgit v1.2.1