wait_timeout(long long int started)
{
long long int now = time_msec();
- long long int timeout = 10000 - (now - started);
- if (timeout <= 0) {
- poll_immediate_wake();
- } else {
- poll_timer_wait(timeout);
- }
+ poll_timer_wait(10000 - (now - started));
}
void
return new_waiter(fd, events);
}
+/* The caller must ensure that 'msec' is not negative. */
+static void
+poll_timer_wait__(int msec)
+{
+ if (timeout < 0 || msec < timeout) {
+ timeout = msec;
+ if (VLOG_IS_DBG_ENABLED()) {
+ backtrace_capture(&timeout_backtrace);
+ }
+ }
+}
+
/* Causes the following call to poll_block() to block for no more than 'msec'
* milliseconds. If 'msec' is nonpositive, the following call to poll_block()
* will not block at all.
* is affected. The timer will need to be re-registered after poll_block() is
* called if it is to persist. */
void
-poll_timer_wait(int msec)
+poll_timer_wait(long long int msec)
{
- if (timeout < 0 || msec < timeout) {
- timeout = MAX(0, msec);
- if (VLOG_IS_DBG_ENABLED()) {
- backtrace_capture(&timeout_backtrace);
- }
- }
+ poll_timer_wait__(msec < 0 ? 0
+ : msec > INT_MAX ? INT_MAX
+ : msec);
}
/* Causes the following call to poll_block() to wake up immediately, without
/*
- * Copyright (c) 2008, 2009 Nicira Networks.
+ * Copyright (c) 2008, 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.
/* Schedule events to wake up the following poll_block(). */
struct poll_waiter *poll_fd_wait(int fd, short int events);
-void poll_timer_wait(int msec);
+void poll_timer_wait(long long int msec);
void poll_immediate_wake(void);
/* Wait until an event occurs. */
-/* 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.
}
if (deadline < LLONG_MAX) {
- poll_timer_wait(MIN(deadline - now, INT_MAX));
+ poll_timer_wait(deadline - now);
}
}
}