Hi John,

I experimentally added support for dazukofs to our upcoming avg8
because I would like to make some performance comparison between
dazukofs and avflt. After dazukofs integration to our scanner I have
noticed that dazukofs_get_access returns a lots of -EINTR. I am using
dazukofs in a multi-threaded scanner and this error occurs only when
more then one thread is used. I wrote a simple showfiles_mt application
using dazukofs in several threads just to check out if the problem is in
my integration or in dazukofs. As I found out I can easily reproduce
this behavior with showfiles_mt. Also there is just a simple single
process example shipped within dazukofs package so I am not sure if I
am using it right. But as I peeked into the code I think my
integration is ok. I wasn't digging very deep, but I am pretty sure
the -ERESTARTSYS is returned by wait_event_freezable in
dazukofs_get_event. I just can not see what(signal?) is
interrupting it. Anyway I attached a patch for dazukofs-3.0.0 which adds
showfiles_mt so you should be able to reproduce it.

1) copy dazukofs-3.0.0-showfiles_mt.patch into the dazukofs-3.0.0
   source code

2) in the dazukofs-3.0.0 directory use
   $ patch -p1 < dazukofs-3.0.0-showfiles_mt.patch

3) now you can use showfiles_mt in the same way as showfiles

Could you please look at the showfiles_mt if my implementation is ok
or if there is a bug in dazukofs?

Thanx

-FH 
diff -Nru dazukofs-3.0.0a/test/Makefile dazukofs-3.0.0b/test/Makefile
--- dazukofs-3.0.0a/test/Makefile	2008-09-24 20:42:48.000000000 +0200
+++ dazukofs-3.0.0b/test/Makefile	2009-02-26 22:15:12.000000000 +0100
@@ -4,14 +4,19 @@
 CFLAGS = -Wall -fPIC -O2 -Ilib
 LDFLAGS = -Llib
 
+all: showfiles showfiles_mt
+
 showfiles: showfiles.c lib/libdazukofs.so
 	$(CC) $(CFLAGS) $(LDFLAGS) showfiles.c -ldazukofs -o showfiles
 
+showfiles_mt: showfiles_mt.c lib/libdazukofs.so
+	$(CC) $(CFLAGS) $(LDFLAGS) showfiles_mt.c -ldazukofs -lpthread -o showfiles_mt
+
 lib/libdazukofs.so:
 	$(MAKE) -C lib
 
 clean:
 	$(MAKE) -C lib clean
-	$(RM) -f showfiles
+	$(RM) -f showfiles showfiles_mt
 
 .PHONY: clean
diff -Nru dazukofs-3.0.0a/test/showfiles_mt.c dazukofs-3.0.0b/test/showfiles_mt.c
--- dazukofs-3.0.0a/test/showfiles_mt.c	1970-01-01 01:00:00.000000000 +0100
+++ dazukofs-3.0.0b/test/showfiles_mt.c	2009-02-26 22:42:41.000000000 +0100
@@ -0,0 +1,111 @@
+#include "dazukofs.h"
+#include <stdio.h>
+#include <string.h>
+#include <unistd.h>
+#include <errno.h>
+#include <signal.h>
+#include <pthread.h>
+
+#define NUMBER_OF_THREADS 10
+
+static int running = 1;
+
+static void print_access(struct dazukofs_access *acc)
+{
+	char filename[1024];
+
+	if (dazukofs_get_filename(acc, filename, sizeof(filename)) > 0) {
+		printf("tid: %lu pid:%05lu file:%s\n", pthread_self(), acc->pid,
+				filename);
+	} else {
+		fprintf(stderr, "dazukofs_get_filename() failed: %s\n",
+			strerror(errno));
+		printf("pid:%05lu file:???\n", acc->pid);
+	}
+}
+
+static void sigterm(int sig)
+{
+	running = 0;
+	signal(sig, sigterm);
+}
+
+void *thread_proc(void *data)
+{
+	dazukofs_handle_t hndl;
+	struct dazukofs_access acc;
+	sigset_t sigset;
+
+	sigemptyset(&sigset);
+	sigaddset(&sigset, SIGINT);
+	sigaddset(&sigset, SIGTERM);
+	pthread_sigmask(SIG_BLOCK, &sigset, NULL);
+	sigaddset(&sigset, SIGUSR1);
+	pthread_sigmask(SIG_UNBLOCK, &sigset, NULL);
+	
+	hndl = dazukofs_open("dazukofs_mt_example", DAZUKOFS_TRACK_GROUP);
+	if (!hndl) {
+		fprintf(stderr, "dazukofs_open() failed: %s\n",
+			strerror(errno));
+		return NULL;
+	}
+
+	while (running) {
+		if (dazukofs_get_access(hndl, &acc) != 0) {
+			if (running) {
+				fprintf(stderr,
+					"dazukofs_get_access() failed: %s\n",
+					strerror(errno));
+			}
+			break;
+		}
+
+		print_access(&acc);
+
+		if (dazukofs_return_access(hndl, &acc) != 0) {
+			if (running) {
+				fprintf(stderr,
+					"dazukofs_return_access() failed: %s\n",
+					strerror(errno));
+			}
+			break;
+		}
+	}
+
+	if (dazukofs_close(hndl, DAZUKOFS_REMOVE_GROUP) != 0) {
+		fprintf(stderr, "dazukofs_close() failed: %s\n",
+			strerror(errno));
+	}
+
+	return NULL;
+}
+
+int main(void)
+{
+	pthread_t tid[NUMBER_OF_THREADS];
+	int i;
+
+	signal(SIGTERM, sigterm);
+	signal(SIGINT, sigterm);
+
+	for (i = 0 ; i < NUMBER_OF_THREADS ; i++) {
+		pthread_create(&tid[i], NULL, thread_proc, NULL);
+	}
+
+	while (running) {
+		sleep(1);
+	}
+
+	for (i = 0 ; i < NUMBER_OF_THREADS ; i++) {
+		pthread_kill(tid[i], SIGUSR1);
+	}
+
+	for (i = 0 ; i < NUMBER_OF_THREADS ; i++) {
+		pthread_join(tid[i], NULL);
+	}
+
+	printf("\nGoodbye.\n");
+
+	return 0;
+}
+
_______________________________________________
Dazuko-devel mailing list
Dazuko-devel@nongnu.org
http://lists.nongnu.org/mailman/listinfo/dazuko-devel

Reply via email to