changeset 1788:42d9cae286b5 HEAD

Fix for leaking fds with non-writable .customflags files.
author Timo Sirainen <tss@iki.fi>
date Mon, 22 Sep 2003 17:29:11 +0300
parents 6cb3cbf8c7c4
children e71256caeff9
files src/lib-index/mail-custom-flags.c
diffstat 1 files changed, 8 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/src/lib-index/mail-custom-flags.c	Sun Sep 21 21:03:49 2003 +0300
+++ b/src/lib-index/mail-custom-flags.c	Mon Sep 22 17:29:11 2003 +0300
@@ -248,16 +248,14 @@
 				   CUSTOM_FLAGS_FILE_NAME, NULL);
 		fd = !readonly ? open(path, O_RDWR | O_CREAT, 0660) :
 			open(path, O_RDONLY);
-		if (fd == -1) {
-			if (errno == EACCES) {
-				fd = open(path, O_RDONLY);
-				readonly = TRUE;
-			}
-			if (errno != EACCES && errno != ENOENT &&
-			    !ENOSPACE(errno)) {
-				index_file_set_syscall_error(index, path, "open()");
-				return FALSE;
-			}
+		if (fd == -1 && errno == EACCES) {
+			fd = open(path, O_RDONLY);
+			readonly = TRUE;
+		}
+		if (fd == -1 && errno != EACCES && errno != ENOENT &&
+		    !ENOSPACE(errno)) {
+			index_file_set_syscall_error(index, path, "open()");
+			return FALSE;
 		}
 	} else {
 		path = NULL;