[dovecot-cvs] dovecot/src/plugins/fts fts-api-private.h, 1.6, 1.7 fts-api.c, 1.7, 1.8 fts-api.h, 1.6, 1.7 fts-storage.c, 1.9, 1.10

tss at dovecot.org tss at dovecot.org
Wed Dec 6 15:45:18 UTC 2006


Update of /var/lib/cvs/dovecot/src/plugins/fts
In directory talvi:/tmp/cvs-serv1158/fts

Modified Files:
	fts-api-private.h fts-api.c fts-api.h fts-storage.c 
Log Message:
Added lock/unlock backend operations.



Index: fts-api-private.h
===================================================================
RCS file: /var/lib/cvs/dovecot/src/plugins/fts/fts-api-private.h,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- fts-api-private.h	1 Dec 2006 20:55:55 -0000	1.6
+++ fts-api-private.h	6 Dec 2006 15:45:15 -0000	1.7
@@ -20,6 +20,9 @@
 	void (*expunge_finish)(struct fts_backend *backend,
 			       struct mailbox *box, bool committed);
 
+	int (*lock)(struct fts_backend *backend);
+	void (*unlock)(struct fts_backend *backend);
+
 	int (*lookup)(struct fts_backend *backend, const char *key,
 		      ARRAY_TYPE(seq_range) *result);
 	int (*filter)(struct fts_backend *backend, const char *key,

Index: fts-api.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/plugins/fts/fts-api.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- fts-api.c	1 Dec 2006 20:55:55 -0000	1.7
+++ fts-api.c	6 Dec 2006 15:45:15 -0000	1.8
@@ -88,6 +88,16 @@
 	backend->v.expunge_finish(backend, box, committed);
 }
 
+int fts_backend_lock(struct fts_backend *backend)
+{
+	return backend->v.lock(backend);
+}
+
+void fts_backend_unlock(struct fts_backend *backend)
+{
+	backend->v.unlock(backend);
+}
+
 int fts_backend_lookup(struct fts_backend *backend, const char *key,
 		       ARRAY_TYPE(seq_range) *result)
 {

Index: fts-api.h
===================================================================
RCS file: /var/lib/cvs/dovecot/src/plugins/fts/fts-api.h,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- fts-api.h	1 Dec 2006 20:55:55 -0000	1.6
+++ fts-api.h	6 Dec 2006 15:45:15 -0000	1.7
@@ -32,6 +32,14 @@
 void fts_backend_expunge_finish(struct fts_backend *backend,
 				struct mailbox *box, bool committed);
 
+/* Lock/unlock the backend for multiple lookups. Returns 1 if locked, 0 if
+   locking timeouted, -1 if error.
+
+   It's not required to call these functions manually, but if you're doing
+   multiple lookup/filter operations this avoids multiple lock/unlock calls. */
+int fts_backend_lock(struct fts_backend *backend);
+void fts_backend_unlock(struct fts_backend *backend);
+
 /* Lookup key from the index and return the found UIDs in result. */
 int fts_backend_lookup(struct fts_backend *backend, const char *key,
 		       ARRAY_TYPE(seq_range) *result);

Index: fts-storage.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/plugins/fts/fts-storage.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- fts-storage.c	1 Dec 2006 20:55:55 -0000	1.9
+++ fts-storage.c	6 Dec 2006 15:45:15 -0000	1.10
@@ -25,6 +25,8 @@
 struct fts_search_context {
 	ARRAY_TYPE(seq_range) result;
 	unsigned int result_pos;
+
+	unsigned int locked:1;
 };
 
 struct fts_transaction_context {
@@ -289,6 +291,10 @@
 		if (fts_build_new(t) < 0)
 			return ctx;
 
+		if (fts_backend_lock(fbox->backend) <= 0)
+			return ctx;
+		fctx->locked = TRUE;
+
 		i_array_init(&uid_result, 64);
 		if (fts_backend_lookup(fbox->backend, args->value.str,
 				       &uid_result) < 0) {
@@ -373,6 +379,9 @@
 	struct fts_mailbox *fbox = FTS_CONTEXT(ctx->transaction->box);
 	struct fts_search_context *fctx = FTS_CONTEXT(ctx);
 
+	if (fctx->locked)
+		fts_backend_unlock(fbox->backend);
+
 	if (array_is_created(&fctx->result))
 		array_free(&fctx->result);
 	i_free(fctx);



More information about the dovecot-cvs mailing list