summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/jsonrpc.c2
-rw-r--r--lib/latch.c10
-rw-r--r--lib/latch.h4
-rw-r--r--lib/ovs-thread.c16
-rw-r--r--lib/ovs-thread.h8
-rw-r--r--lib/poll-loop.c37
-rw-r--r--lib/poll-loop.h31
-rw-r--r--lib/timer.c12
-rw-r--r--lib/timer.h6
9 files changed, 70 insertions, 56 deletions
diff --git a/lib/jsonrpc.c b/lib/jsonrpc.c
index 6c482c2d1..a7d89f705 100644
--- a/lib/jsonrpc.c
+++ b/lib/jsonrpc.c
@@ -352,7 +352,7 @@ void
jsonrpc_recv_wait(struct jsonrpc *rpc)
{
if (rpc->status || rpc->received || !byteq_is_empty(&rpc->input)) {
- (poll_immediate_wake)(rpc->name);
+ poll_immediate_wake_at(rpc->name);
} else {
stream_recv_wait(rpc->stream);
}
diff --git a/lib/latch.c b/lib/latch.c
index 9b130062b..bf518b9ca 100644
--- a/lib/latch.c
+++ b/lib/latch.c
@@ -75,9 +75,13 @@ latch_is_set(const struct latch *latch)
return pfd.revents & POLLIN;
}
-/* Causes the next poll_block() to wake up when 'latch' is set. */
+/* Causes the next poll_block() to wake up when 'latch' is set.
+ *
+ * ('where' is used in debug logging. Commonly one would use latch_wait() to
+ * automatically provide the caller's source file and line number for
+ * 'where'.) */
void
-(latch_wait)(const struct latch *latch, const char *where)
+latch_wait_at(const struct latch *latch, const char *where)
{
- (poll_fd_wait)(latch->fds[0], POLLIN, where);
+ poll_fd_wait_at(latch->fds[0], POLLIN, where);
}
diff --git a/lib/latch.h b/lib/latch.h
index 08f45b117..0b6e8a3c9 100644
--- a/lib/latch.h
+++ b/lib/latch.h
@@ -36,7 +36,7 @@ bool latch_poll(struct latch *);
void latch_set(struct latch *);
bool latch_is_set(const struct latch *);
-void latch_wait(const struct latch *, const char *where);
-#define latch_wait(latch) latch_wait(latch, SOURCE_LOCATOR)
+void latch_wait_at(const struct latch *, const char *where);
+#define latch_wait(latch) latch_wait_at(latch, SOURCE_LOCATOR)
#endif /* latch.h */
diff --git a/lib/ovs-thread.c b/lib/ovs-thread.c
index 91bb3d958..abadeb9be 100644
--- a/lib/ovs-thread.c
+++ b/lib/ovs-thread.c
@@ -136,9 +136,13 @@ ovsthread_once_done(struct ovsthread_once *once)
}
/* Asserts that the process has not yet created any threads (beyond the initial
- * thread). */
+ * thread).
+ *
+ * ('where' is used in logging. Commonly one would use
+ * assert_single_threaded() to automatically provide the caller's source file
+ * and line number for 'where'.) */
void
-(assert_single_threaded)(const char *where)
+assert_single_threaded_at(const char *where)
{
if (multithreaded) {
VLOG_FATAL("%s: attempted operation not allowed when multithreaded",
@@ -148,9 +152,13 @@ void
/* Forks the current process (checking that this is allowed). Aborts with
* VLOG_FATAL if fork() returns an error, and otherwise returns the value
- * returned by fork(). */
+ * returned by fork().
+ *
+ * ('where' is used in logging. Commonly one would use xfork() to
+ * automatically provide the caller's source file and line number for
+ * 'where'.) */
pid_t
-(xfork)(const char *where)
+xfork_at(const char *where)
{
pid_t pid;
diff --git a/lib/ovs-thread.h b/lib/ovs-thread.h
index 29a8637a5..98428fd04 100644
--- a/lib/ovs-thread.h
+++ b/lib/ovs-thread.h
@@ -377,11 +377,11 @@ ovsthread_once_start(struct ovsthread_once *once)
((ONCE)->done ? false : ({ OVS_ACQUIRE(ONCE); true; }))
#endif
-void assert_single_threaded(const char *where);
-#define assert_single_threaded() assert_single_threaded(SOURCE_LOCATOR)
+void assert_single_threaded_at(const char *where);
+#define assert_single_threaded() assert_single_threaded_at(SOURCE_LOCATOR)
-pid_t xfork(const char *where);
-#define xfork() xfork(SOURCE_LOCATOR)
+pid_t xfork_at(const char *where);
+#define xfork() xfork_at(SOURCE_LOCATOR)
void forbid_forking(const char *reason);
bool may_fork(void);
diff --git a/lib/poll-loop.c b/lib/poll-loop.c
index 97fc8068c..0f45d9835 100644
--- a/lib/poll-loop.c
+++ b/lib/poll-loop.c
@@ -30,11 +30,6 @@
#include "timeval.h"
#include "vlog.h"
-#undef poll_fd_wait
-#undef poll_timer_wait
-#undef poll_timer_wait_until
-#undef poll_immediate_wake
-
VLOG_DEFINE_THIS_MODULE(poll_loop);
COVERAGE_DEFINE(poll_fd_wait);
@@ -63,10 +58,11 @@ static struct poll_loop *poll_loop(void);
* is affected. The event will need to be re-registered after poll_block() is
* called if it is to persist.
*
- * Ordinarily the 'where' argument is supplied automatically; see poll-loop.h
- * for more information. */
+ * ('where' is used in debug logging. Commonly one would use poll_fd_wait() to
+ * automatically provide the caller's source file and line number for
+ * 'where'.) */
void
-poll_fd_wait(int fd, short int events, const char *where)
+poll_fd_wait_at(int fd, short int events, const char *where)
{
struct poll_loop *loop = poll_loop();
@@ -93,10 +89,11 @@ poll_fd_wait(int fd, short int events, const char *where)
* is affected. The timer will need to be re-registered after poll_block() is
* called if it is to persist.
*
- * Ordinarily the 'where' argument is supplied automatically; see poll-loop.h
- * for more information. */
+ * ('where' is used in debug logging. Commonly one would use poll_timer_wait()
+ * to automatically provide the caller's source file and line number for
+ * 'where'.) */
void
-poll_timer_wait(long long int msec, const char *where)
+poll_timer_wait_at(long long int msec, const char *where)
{
long long int now = time_msec();
long long int when;
@@ -112,7 +109,7 @@ poll_timer_wait(long long int msec, const char *where)
when = LLONG_MAX;
}
- poll_timer_wait_until(when, where);
+ poll_timer_wait_until_at(when, where);
}
/* Causes the following call to poll_block() to wake up when the current time,
@@ -124,10 +121,11 @@ poll_timer_wait(long long int msec, const char *where)
* is affected. The timer will need to be re-registered after poll_block() is
* called if it is to persist.
*
- * Ordinarily the 'where' argument is supplied automatically; see poll-loop.h
- * for more information. */
+ * ('where' is used in debug logging. Commonly one would use
+ * poll_timer_wait_until() to automatically provide the caller's source file
+ * and line number for 'where'.) */
void
-poll_timer_wait_until(long long int when, const char *where)
+poll_timer_wait_until_at(long long int when, const char *where)
{
struct poll_loop *loop = poll_loop();
if (when < loop->timeout_when) {
@@ -139,12 +137,13 @@ poll_timer_wait_until(long long int when, const char *where)
/* Causes the following call to poll_block() to wake up immediately, without
* blocking.
*
- * Ordinarily the 'where' argument is supplied automatically; see poll-loop.h
- * for more information. */
+ * ('where' is used in debug logging. Commonly one would use
+ * poll_immediate_wake() to automatically provide the caller's source file and
+ * line number for 'where'.) */
void
-poll_immediate_wake(const char *where)
+poll_immediate_wake_at(const char *where)
{
- poll_timer_wait(0, where);
+ poll_timer_wait_at(0, where);
}
/* Logs, if appropriate, that the poll loop was awakened by an event
diff --git a/lib/poll-loop.h b/lib/poll-loop.h
index 6614ebe58..03978530e 100644
--- a/lib/poll-loop.h
+++ b/lib/poll-loop.h
@@ -44,25 +44,24 @@ extern "C" {
/* Schedule events to wake up the following poll_block().
*
* The poll_loop logs the 'where' argument to each function at "debug" level
- * when an event causes a wakeup. Ordinarily, it is automatically filled in
- * with the location in the source of the call, and the caller should therefore
- * omit it. But, if the function you are implementing is very generic, so that
- * its location in the source would not be very helpful for debugging, you can
- * avoid the macro expansion and pass a different argument, e.g.:
- * (poll_fd_wait)(fd, events, where);
- * See timer_wait() for an example.
- */
-void poll_fd_wait(int fd, short int events, const char *where);
-#define poll_fd_wait(fd, events) poll_fd_wait(fd, events, SOURCE_LOCATOR)
+ * when an event causes a wakeup. Each of these ways to schedule an event has
+ * a function and a macro wrapper. The macro version automatically supplies
+ * the source code location of the caller. The function version allows the
+ * caller to supply a location explicitly, which is useful if the caller's own
+ * caller would be more useful in log output. See timer_wait_at() for an
+ * example. */
+void poll_fd_wait_at(int fd, short int events, const char *where);
+#define poll_fd_wait(fd, events) poll_fd_wait_at(fd, events, SOURCE_LOCATOR)
-void poll_timer_wait(long long int msec, const char *where);
-#define poll_timer_wait(msec) poll_timer_wait(msec, SOURCE_LOCATOR)
+void poll_timer_wait_at(long long int msec, const char *where);
+#define poll_timer_wait(msec) poll_timer_wait_at(msec, SOURCE_LOCATOR)
-void poll_timer_wait_until(long long int msec, const char *where);
-#define poll_timer_wait_until(msec) poll_timer_wait_until(msec, SOURCE_LOCATOR)
+void poll_timer_wait_until_at(long long int msec, const char *where);
+#define poll_timer_wait_until(msec) \
+ poll_timer_wait_until_at(msec, SOURCE_LOCATOR)
-void poll_immediate_wake(const char *where);
-#define poll_immediate_wake() poll_immediate_wake(SOURCE_LOCATOR)
+void poll_immediate_wake_at(const char *where);
+#define poll_immediate_wake() poll_immediate_wake_at(SOURCE_LOCATOR)
/* Wait until an event occurs. */
void poll_block(void);
diff --git a/lib/timer.c b/lib/timer.c
index e767db65f..e90355bdb 100644
--- a/lib/timer.c
+++ b/lib/timer.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2011 Nicira, Inc.
+ * Copyright (c) 2011, 2013 Nicira, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -32,11 +32,15 @@ timer_msecs_until_expired(const struct timer *timer)
}
}
-/* Causes poll_block() to wake when 'timer' expires. */
+/* Causes poll_block() to wake when 'timer' expires.
+ *
+ * ('where' is used in debug logging. Commonly one would use timer_wait() to
+ * automatically provide the caller's source file and line number for
+ * 'where'.) */
void
-(timer_wait)(const struct timer *timer, const char *where)
+timer_wait_at(const struct timer *timer, const char *where)
{
if (timer->t < LLONG_MAX) {
- (poll_timer_wait_until)(timer->t, where);
+ poll_timer_wait_until_at(timer->t, where);
}
}
diff --git a/lib/timer.h b/lib/timer.h
index e9650ada9..9afe3b75e 100644
--- a/lib/timer.h
+++ b/lib/timer.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2011 Nicira, Inc.
+ * Copyright (c) 2011, 2013 Nicira, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -27,8 +27,8 @@ struct timer {
};
long long int timer_msecs_until_expired(const struct timer *);
-void timer_wait(const struct timer *, const char *where);
-#define timer_wait(timer) timer_wait(timer, SOURCE_LOCATOR)
+void timer_wait_at(const struct timer *, const char *where);
+#define timer_wait(timer) timer_wait_at(timer, SOURCE_LOCATOR)
/* Causes 'timer' to expire when 'duration' milliseconds have passed.
*