X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=ofproto%2Fcollectors.c;h=69eed5d7d85a50fb118e3e1eac05fab3bc32e695;hb=9884eaad2b8386aefa036f370891fd1159598994;hp=4589f32985e60afd9ac9f781f55dc3c5d435557f;hpb=49c36903d6d65bed96cba31f05534510a21a68d7;p=sliver-openvswitch.git diff --git a/ofproto/collectors.c b/ofproto/collectors.c index 4589f3298..69eed5d7d 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,15 +20,16 @@ #include #include +#include #include #include "socket-util.h" #include "svec.h" #include "util.h" - -#define THIS_MODULE VLM_collectors #include "vlog.h" +VLOG_DEFINE_THIS_MODULE(collectors) + struct collectors { int *fds; /* Sockets. */ size_t n_fds; /* Number of sockets. */ @@ -111,13 +112,15 @@ 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)); + } } } } @@ -125,5 +128,5 @@ collectors_send(const struct collectors *c, const void *payload, size_t n) int collectors_count(const struct collectors *c) { - return c->n_fds; + return c ? c->n_fds : 0; }