Browse code

onas: adding throttling to notifications when handling fanotify errors on large files.

Mickey Sola authored on 2015/10/16 04:16:40
Showing 1 changed files
... ...
@@ -34,6 +34,7 @@
34 34
 #include <pthread.h>
35 35
 #include <string.h>
36 36
 #include <errno.h>
37
+#include <time.h>
37 38
 
38 39
 #include <sys/fanotify.h>
39 40
 
... ...
@@ -227,11 +228,17 @@ void *onas_fan_th(void *arg)
227 227
         ret = select(onas_fan_fd + 1, &rfds, NULL, NULL, NULL);
228 228
     } while((ret == -1 && errno == EINTR) || reload);
229 229
 
230
+
231
+    time_t start = time(NULL) - 30;
230 232
     while(((bread = read(onas_fan_fd, buf, sizeof(buf))) > 0) || errno == EOVERFLOW) {
231 233
 
232 234
 	if (errno == EOVERFLOW) {
233
-		logg("!ScanOnAccess: Internal error (failed to read data) ... %s\n", strerror(errno));
234
-		logg("!ScanOnAccess: File too large for fanotify ... recovering and continuing scans...\n");
235
+		if (time(NULL) - start >= 30) {
236
+			logg("!ScanOnAccess: Internal error (failed to read data) ... %s\n", strerror(errno));
237
+			logg("!ScanOnAccess: File too large for fanotify ... recovering and continuing scans...\n");
238
+			start = time(NULL);
239
+		}
240
+
235 241
 		errno = 0;
236 242
 		continue;
237 243
 	}