X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=ofproto%2Fcollectors.c;h=0b84c3ece300a44fd62d9e4f6f4e255e99a111a8;hb=609d182a8161e9e87300cc680ff55c50d02b6e22;hp=f7cb1dbe4f23a5e791e23d63e134d5e6018ab07f;hpb=58fda1dab104041fc693032475ec4662c1a52849;p=openvswitch diff --git a/ofproto/collectors.c b/ofproto/collectors.c index f7cb1dbe..0b84c3ec 100644 --- a/ofproto/collectors.c +++ b/ofproto/collectors.c @@ -1,5 +1,5 @@ /* - * 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. @@ -20,6 +20,7 @@ #include #include +#include #include #include "socket-util.h" @@ -111,13 +112,21 @@ collectors_destroy(struct collectors *c) void collectors_send(const struct collectors *c, const void *payload, size_t n) { - size_t i; + if (c) { + size_t i; - for (i = 0; i < c->n_fds; i++) { - static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(1, 5); - if (send(c->fds[i], payload, n, 0) == -1) { - VLOG_WARN_RL(&rl, "sending to collector failed: %s", - strerror(errno)); + for (i = 0; i < c->n_fds; i++) { + static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(1, 5); + if (send(c->fds[i], payload, n, 0) == -1) { + VLOG_WARN_RL(&rl, "sending to collector failed: %s", + strerror(errno)); + } } } } + +int +collectors_count(const struct collectors *c) +{ + return c ? c->n_fds : 0; +}