summaryrefslogtreecommitdiff
path: root/lib/unixctl.c
diff options
context:
space:
mode:
authorBen Pfaff <blp@nicira.com>2010-11-29 12:21:08 -0800
committerBen Pfaff <blp@nicira.com>2010-11-29 16:29:10 -0800
commit614c4892032f424efa5f0ec404b2d499acad254d (patch)
treeb1f784ef17cc77b53b13129aef59eda007449774 /lib/unixctl.c
parentb31bcf60cf4fbabca0182196c97b3004e42f53e5 (diff)
downloadopenvswitch-614c4892032f424efa5f0ec404b2d499acad254d.tar.gz
Add new "dummy" netdev and dpif implementations for use in unit tests.
Diffstat (limited to 'lib/unixctl.c')
-rw-r--r--lib/unixctl.c19
1 files changed, 18 insertions, 1 deletions
diff --git a/lib/unixctl.c b/lib/unixctl.c
index 6abb3328d..e10de4915 100644
--- a/lib/unixctl.c
+++ b/lib/unixctl.c
@@ -174,6 +174,9 @@ unixctl_command_reply(struct unixctl_conn *conn,
*
* - NULL, in which case <rundir>/<program>.<pid>.ctl is used.
*
+ * - "none", in which case the function will return successfully but
+ * no socket will actually be created.
+ *
* - A name that does not start with '/', in which case it is put in
* <rundir>.
*
@@ -186,13 +189,19 @@ unixctl_command_reply(struct unixctl_conn *conn,
* "ovs-appctl --target=<program>" will fail.)
*
* Returns 0 if successful, otherwise a positive errno value. If successful,
- * sets '*serverp' to the new unixctl_server, otherwise to NULL. */
+ * sets '*serverp' to the new unixctl_server (or to NULL if 'path' was "none"),
+ * otherwise to NULL. */
int
unixctl_server_create(const char *path, struct unixctl_server **serverp)
{
struct unixctl_server *server;
int error;
+ if (path && !strcmp(path, "none")) {
+ *serverp = NULL;
+ return 0;
+ }
+
unixctl_command_register("help", unixctl_help, NULL);
server = xmalloc(sizeof *server);
@@ -400,6 +409,10 @@ unixctl_server_run(struct unixctl_server *server)
struct unixctl_conn *conn, *next;
int i;
+ if (!server) {
+ return;
+ }
+
for (i = 0; i < 10; i++) {
int fd = accept(server->fd, NULL, NULL);
if (fd < 0) {
@@ -424,6 +437,10 @@ unixctl_server_wait(struct unixctl_server *server)
{
struct unixctl_conn *conn;
+ if (!server) {
+ return;
+ }
+
poll_fd_wait(server->fd, POLLIN);
LIST_FOR_EACH (conn, node, &server->conns) {
if (conn->state == S_RECV) {