dovecot-2.2: lib-fs: Add data stack frames to most API calls, so...

dovecot at dovecot.org dovecot at dovecot.org
Wed Apr 10 14:52:30 EEST 2013


details:   http://hg.dovecot.org/dovecot-2.2/rev/08602cf498ea
changeset: 16264:08602cf498ea
user:      Timo Sirainen <tss at iki.fi>
date:      Wed Apr 10 14:52:17 2013 +0300
description:
lib-fs: Add data stack frames to most API calls, so the backends/callers don't need to.

diffstat:

 src/lib-fs/fs-api.c |  138 ++++++++++++++++++++++++++++++++++++++++++---------
 1 files changed, 113 insertions(+), 25 deletions(-)

diffs (271 lines):

diff -r e8f366822a59 -r 08602cf498ea src/lib-fs/fs-api.c
--- a/src/lib-fs/fs-api.c	Wed Apr 10 14:51:37 2013 +0300
+++ b/src/lib-fs/fs-api.c	Wed Apr 10 14:52:17 2013 +0300
@@ -175,7 +175,9 @@
 	}
 
 	file->fs->files_open_count--;
-	file->fs->v.file_deinit(file);
+	T_BEGIN {
+		file->fs->v.file_deinit(file);
+	} T_END;
 
 	if (metadata_pool != NULL)
 		pool_unref(&metadata_pool);
@@ -207,8 +209,9 @@
 
 void fs_set_metadata(struct fs_file *file, const char *key, const char *value)
 {
-	if (file->fs->v.set_metadata != NULL)
+	if (file->fs->v.set_metadata != NULL) T_BEGIN {
 		file->fs->v.set_metadata(file, key, value);
+	} T_END;
 }
 
 int fs_get_metadata(struct fs_file *file,
@@ -257,7 +260,12 @@
 
 bool fs_prefetch(struct fs_file *file, uoff_t length)
 {
-	return file->fs->v.prefetch(file, length);
+	bool ret;
+
+	T_BEGIN {
+		ret = file->fs->v.prefetch(file, length);
+	} T_END;
+	return ret;
 }
 
 ssize_t fs_read_via_stream(struct fs_file *file, void *buf, size_t size)
@@ -289,8 +297,14 @@
 
 ssize_t fs_read(struct fs_file *file, void *buf, size_t size)
 {
-	if (file->fs->v.read != NULL)
-		return file->fs->v.read(file, buf, size);
+	int ret;
+
+	if (file->fs->v.read != NULL) {
+		T_BEGIN {
+			ret = file->fs->v.read(file, buf, size);
+		} T_END;
+		return ret;
+	}
 
 	/* backend didn't bother to implement read(), but we can do it with
 	   streams. */
@@ -310,7 +324,9 @@
 		i_stream_ref(file->seekable_input);
 		return file->seekable_input;
 	}
-	input = file->fs->v.read_stream(file, max_buffer_size);
+	T_BEGIN {
+		input = file->fs->v.read_stream(file, max_buffer_size);
+	} T_END;
 	if (input->stream_errno != 0) {
 		/* read failed already */
 		return input;
@@ -382,8 +398,14 @@
 
 int fs_write(struct fs_file *file, const void *data, size_t size)
 {
-	if (file->fs->v.write != NULL)
-		return file->fs->v.write(file, data, size);
+	int ret;
+
+	if (file->fs->v.write != NULL) {
+		T_BEGIN {
+			ret = file->fs->v.write(file, data, size);
+		} T_END;
+		return ret;
+	}
 
 	/* backend didn't bother to implement write(), but we can do it with
 	   streams. */
@@ -392,22 +414,34 @@
 
 struct ostream *fs_write_stream(struct fs_file *file)
 {
-	file->fs->v.write_stream(file);
+	T_BEGIN {
+		file->fs->v.write_stream(file);
+	} T_END;
 	i_assert(file->output != NULL);
 	return file->output;
 }
 
 int fs_write_stream_finish(struct fs_file *file, struct ostream **output)
 {
+	int ret;
+
 	i_assert(*output == file->output || *output == NULL);
 
 	*output = NULL;
-	return file->fs->v.write_stream_finish(file, TRUE);
+	T_BEGIN {
+		ret = file->fs->v.write_stream_finish(file, TRUE);
+	} T_END;
+	return ret;
 }
 
 int fs_write_stream_finish_async(struct fs_file *file)
 {
-	return file->fs->v.write_stream_finish(file, TRUE);
+	int ret;
+
+	T_BEGIN {
+		ret = file->fs->v.write_stream_finish(file, TRUE);
+	} T_END;
+	return ret;
 }
 
 void fs_write_stream_abort(struct fs_file *file, struct ostream **output)
@@ -415,7 +449,9 @@
 	i_assert(*output == file->output);
 
 	*output = NULL;
-	(void)file->fs->v.write_stream_finish(file, FALSE);
+	T_BEGIN {
+		(void)file->fs->v.write_stream_finish(file, FALSE);
+	} T_END;
 }
 
 void fs_file_set_async_callback(struct fs_file *file,
@@ -430,15 +466,24 @@
 
 int fs_wait_async(struct fs *fs)
 {
+	int ret;
+
 	if (fs->v.wait_async == NULL)
-		return 0;
-	else
-		return fs->v.wait_async(fs);
+		ret = 0;
+	else T_BEGIN {
+		ret = fs->v.wait_async(fs);
+	} T_END;
+	return ret;
 }
 
 int fs_lock(struct fs_file *file, unsigned int secs, struct fs_lock **lock_r)
 {
-	return file->fs->v.lock(file, secs, lock_r);
+	int ret;
+
+	T_BEGIN {
+		ret = file->fs->v.lock(file, secs, lock_r);
+	} T_END;
+	return ret;
 }
 
 void fs_unlock(struct fs_lock **_lock)
@@ -446,17 +491,29 @@
 	struct fs_lock *lock = *_lock;
 
 	*_lock = NULL;
-	lock->file->fs->v.unlock(lock);
+	T_BEGIN {
+		lock->file->fs->v.unlock(lock);
+	} T_END;
 }
 
 int fs_exists(struct fs_file *file)
 {
-	return file->fs->v.exists(file);
+	int ret;
+
+	T_BEGIN {
+		ret = file->fs->v.exists(file);
+	} T_END;
+	return ret;
 }
 
 int fs_stat(struct fs_file *file, struct stat *st_r)
 {
-	return file->fs->v.stat(file, st_r);
+	int ret;
+
+	T_BEGIN {
+		ret = file->fs->v.stat(file, st_r);
+	} T_END;
+	return ret;
 }
 
 int fs_default_copy(struct fs_file *src, struct fs_file *dest)
@@ -501,38 +558,69 @@
 
 int fs_copy(struct fs_file *src, struct fs_file *dest)
 {
+	int ret;
+
 	i_assert(src->fs == dest->fs);
-	return src->fs->v.copy(src, dest);
+
+	T_BEGIN {
+		ret = src->fs->v.copy(src, dest);
+	} T_END;
+	return ret;
 }
 
 int fs_copy_finish_async(struct fs_file *dest)
 {
-	return dest->fs->v.copy(NULL, dest);
+	int ret;
+
+	T_BEGIN {
+		ret = dest->fs->v.copy(NULL, dest);
+	} T_END;
+	return ret;
 }
 
 int fs_rename(struct fs_file *src, struct fs_file *dest)
 {
+	int ret;
+
 	i_assert(src->fs == dest->fs);
-	return src->fs->v.rename(src, dest);
+
+	T_BEGIN {
+		ret = src->fs->v.rename(src, dest);
+	} T_END;
+	return ret;
 }
 
 int fs_delete(struct fs_file *file)
 {
-	return file->fs->v.delete_file(file);
+	int ret;
+
+	T_BEGIN {
+		ret = file->fs->v.delete_file(file);
+	} T_END;
+	return ret;
 }
 
 struct fs_iter *
 fs_iter_init(struct fs *fs, const char *path, enum fs_iter_flags flags)
 {
-	return fs->v.iter_init(fs, path, flags);
+	struct fs_iter *iter;
+
+	T_BEGIN {
+		iter = fs->v.iter_init(fs, path, flags);
+	} T_END;
+	return iter;
 }
 
 int fs_iter_deinit(struct fs_iter **_iter)
 {
 	struct fs_iter *iter = *_iter;
+	int ret;
 
 	*_iter = NULL;
-	return iter->fs->v.iter_deinit(iter);
+	T_BEGIN {
+		ret = iter->fs->v.iter_deinit(iter);
+	} T_END;
+	return ret;
 }
 
 const char *fs_iter_next(struct fs_iter *iter)


More information about the dovecot-cvs mailing list