PR comments addressed
authorKrzysztof Matczak <krzysztofx.matczak@intel.com>
Fri, 23 Dec 2016 00:21:53 +0000 (00:21 +0000)
committerKrzysztof Matczak <krzysztofx.matczak@intel.com>
Sun, 25 Dec 2016 20:23:40 +0000 (20:23 +0000)
Change-Id: I0ddfd6dcd911ab46fcbc032081a2980b1f1f549b
Signed-off-by: Krzysztof Matczak <krzysztofx.matczak@intel.com>
Makefile.am
src/collectd.conf.pod
src/mcelog.c

index 9f33cdc..9f0506a 100644 (file)
@@ -1045,7 +1045,6 @@ if BUILD_PLUGIN_MCELOG
 pkglib_LTLIBRARIES += mcelog.la
 mcelog_la_SOURCES = mcelog.c
 mcelog_la_LDFLAGS = $(PLUGIN_LDFLAGS)
-mcelog_la_LIBADD =
 endif
 
 if BUILD_PLUGIN_MD
index e6f771e..2f29713 100644 (file)
@@ -3324,23 +3324,23 @@ TCP-Port to connect to. Defaults to B<411>.
 
 =head2 Plugin C<mcelog>
 
-The C<mcelog plugin> uses mcelog to retrieve machine check exceptions, etc.
+The C<mcelog plugin> uses mcelog to retrieve machine check exceptions.
 
 By default the plugin connects to B<"/var/run/mcelog-client"> to check if the
 mcelog server is running. When the server is running, the plugin will tail the
 specified logfile to retrieve machine check exception information and send a
 notification with the details from the logfile. The plugin will use the mcelog
-client protocol to retrieve memory errors.
+client protocol to retrieve memory related machine check exceptions.
 
 =over 4
 
 =item B<McelogClientSocket> I<Path>
-Connect to mcelog client socket using the UNIX domain socket at I<Path>.
+Connect to the mcelog client socket using the UNIX domain socket at I<Path>.
 Defaults to B<"/var/run/mcelog-client">.
 
 =item B<McelogLogfile> I<Path>
 
-mcelog file to parse. Defaults to B<"/var/log/mcelog">.
+The mcelog file to parse. Defaults to B<"/var/log/mcelog">.
 
 =back
 
index f1b4318..9fad0be 100644 (file)
@@ -154,14 +154,13 @@ static int socket_write(socket_adapter_t *self, const char *msg,
 
 static int socket_reinit(socket_adapter_t *self) {
   char errbuff[MCELOG_BUFF_SIZE];
-  int flags;
   int ret = -1;
   cdtime_t interval = plugin_get_interval();
   struct timeval socket_timeout = CDTIME_T_TO_TIMEVAL(interval);
 
   /* synchronization via write lock since sock_fd may be changed here */
   pthread_rwlock_wrlock(&self->lock);
-  self->sock_fd = socket(PF_UNIX, SOCK_STREAM, 0);
+  self->sock_fd = socket(PF_UNIX, SOCK_STREAM|SOCK_CLOEXEC|SOCK_NONBLOCK, 0);
   if (self->sock_fd < 0) {
     ERROR("%s: Could not create a socket. %s", MCELOG_PLUGIN,
           sstrerror(errno, errbuff, sizeof(errbuff)));
@@ -169,13 +168,9 @@ static int socket_reinit(socket_adapter_t *self) {
     return ret;
   }
 
-  flags = fcntl(self->sock_fd, F_GETFL, 0);
-  flags |= O_NONBLOCK;
-  fcntl(self->sock_fd, F_SETFL, flags);
-
   /* Set socket timeout option */
   if (setsockopt(self->sock_fd, SOL_SOCKET, SO_SNDTIMEO,
-                 (char *)&socket_timeout, sizeof(socket_timeout)) < 0)
+                 &socket_timeout, sizeof(socket_timeout)) < 0)
     ERROR("%s: Failed to set the socket timeout option.", MCELOG_PLUGIN);
 
   /* downgrading to read lock due to possible recursive read locks
@@ -411,7 +406,7 @@ static int socket_receive(socket_adapter_t *self, FILE **pp_file) {
 static void *poll_worker(__attribute__((unused)) void *arg) {
   char errbuf[MCELOG_BUFF_SIZE];
   mcelog_thread_running = 1;
-  FILE **pp_file = calloc(1, sizeof(FILE *));
+  FILE **pp_file = calloc(1, sizeof(*pp_file));
   if (pp_file == NULL) {
     ERROR("mcelog: memory allocation failed: %s",
           sstrerror(errno, errbuf, sizeof(errbuf)));
@@ -439,8 +434,7 @@ static void *poll_worker(__attribute__((unused)) void *arg) {
     if (*pp_file == NULL)
       continue;
 
-    mcelog_memory_rec_t memory_record;
-    memset(&memory_record, 0, sizeof(memory_record));
+    mcelog_memory_rec_t memory_record = {0};
     while (parse_memory_info(*pp_file, &memory_record)) {
       notification_t n = {NOTIF_OKAY, cdtime(), "", "",  MCELOG_PLUGIN,
                           "",         "",       "", NULL};