Code

mcelog: Increase delay between socket reinitialization
authorPrzemyslaw Szczerbik <przemyslawx.szczerbik@intel.com>
Tue, 3 Jan 2017 13:46:04 +0000 (13:46 +0000)
committerPrzemyslaw Szczerbik <przemyslawx.szczerbik@intel.com>
Thu, 19 Jan 2017 12:33:28 +0000 (12:33 +0000)
Change delay between subsequent socket reinitialization attempts from 1000 usec
to 1000 ms. Such frequent attempts were affecting collectd functionality and
flooded the syslog. Issue can be eaisly reproduced by stopping mcelog service
while collectd with mcelog plugin enabled is running.

Signed-off-by: Przemyslaw Szczerbik <przemyslawx.szczerbik@intel.com>
src/mcelog.c

index 6dbfafcee62120a75733cf2798871702fadc68ee..7299d117d532c360c62d692ba46d3476480ce807 100644 (file)
@@ -416,14 +416,13 @@ static void *poll_worker(__attribute__((unused)) void *arg) {
   pthread_cleanup_push(poll_worker_cleanup, pp_file);
 
   while (1) {
-    int res = 0;
     /* blocking call */
-    res = socket_adapter.receive(&socket_adapter, pp_file);
+    int res = socket_adapter.receive(&socket_adapter, pp_file);
     if (res < 0) {
       socket_adapter.close(&socket_adapter);
-      if (socket_adapter.reinit(&socket_adapter) != 0) {
-        socket_adapter.close(&socket_adapter);
-        usleep(MCELOG_POLL_TIMEOUT);
+      while (socket_adapter.reinit(&socket_adapter) != 0) {
+        nanosleep(&CDTIME_T_TO_TIMESPEC(MS_TO_CDTIME_T(MCELOG_POLL_TIMEOUT)),
+                  NULL);
       }
       continue;
     }