dovecot-2.2: Changed i_close_fd() API to set the fd to -1 after ...

dovecot at dovecot.org dovecot at dovecot.org
Thu Jun 28 00:29:45 EEST 2012


details:   http://hg.dovecot.org/dovecot-2.2/rev/3945a3646c67
changeset: 14691:3945a3646c67
user:      Timo Sirainen <tss at iki.fi>
date:      Thu Jun 28 00:27:13 2012 +0300
description:
Changed i_close_fd() API to set the fd to -1 after closing.

diffstat:

 src/auth/db-checkpassword.c                     |  16 ++++++++--------
 src/auth/db-passwd-file.c                       |   2 +-
 src/auth/mech-winbind.c                         |  14 +++++++-------
 src/config/config-parser.c                      |   2 +-
 src/config/sysinfo-get.c                        |   2 +-
 src/director/director-test.c                    |   2 +-
 src/doveadm/doveadm-dump-log.c                  |   2 +-
 src/doveadm/doveadm-dump-mailboxlog.c           |   2 +-
 src/doveadm/doveadm-instance.c                  |   2 +-
 src/doveadm/doveadm-master.c                    |   2 +-
 src/doveadm/doveadm-sis.c                       |   2 +-
 src/doveadm/doveadm-stats.c                     |   2 +-
 src/doveadm/dsync/doveadm-dsync.c               |  24 +++++++++++-------------
 src/doveadm/dsync/dsync-slave-io.c              |   2 +-
 src/imap/main.c                                 |   6 ++++--
 src/lda/main.c                                  |   2 +-
 src/lib-dict/dict-file.c                        |  10 +++++-----
 src/lib-dns/dns-lookup.c                        |   2 +-
 src/lib-imap-client/imapc-client.c              |   2 +-
 src/lib-index/mail-cache-compress.c             |   4 ++--
 src/lib-lda/smtp-client.c                       |   8 ++++----
 src/lib-master/master-login.c                   |   2 +-
 src/lib-master/master-service-settings.c        |   6 +++---
 src/lib-master/mountpoint-list.c                |   4 ++--
 src/lib-settings/settings-parser.c              |   8 ++++----
 src/lib-storage/index/index-attachment.c        |   2 +-
 src/lib-storage/index/maildir/maildir-storage.c |   2 +-
 src/lib-storage/index/maildir/maildir-uidlist.c |   4 ++--
 src/lib-storage/index/mbox/mbox-file.c          |   2 +-
 src/lib-storage/index/mbox/mbox-lock.c          |   6 +++---
 src/lib-storage/index/mbox/mbox-storage.c       |   4 ++--
 src/lib-storage/index/pop3c/pop3c-client.c      |   2 +-
 src/lib-storage/list/mailbox-list-maildir.c     |   2 +-
 src/lib-storage/mailbox-uidvalidity.c           |   6 +++---
 src/lib/askpass.c                               |   2 +-
 src/lib/failures.c                              |   6 +++---
 src/lib/fdatasync-path.c                        |   2 +-
 src/lib/file-copy.c                             |   4 ++--
 src/lib/file-dotlock.c                          |   7 +++----
 src/lib/ioloop-notify-dn.c                      |   4 ++--
 src/lib/ioloop-notify-kqueue.c                  |   2 +-
 src/lib/iostream-rawlog.c                       |   2 +-
 src/lib/istream-seekable.c                      |   5 ++---
 src/lib/lib.c                                   |  12 ++++++++++++
 src/lib/lib.h                                   |   1 +
 src/lib/macros.h                                |   6 ++----
 src/lib/network.c                               |  16 ++++++++--------
 src/lib/nfs-workarounds.c                       |   6 +++---
 src/lib/randgen.c                               |   3 +--
 src/lib/safe-mkstemp.c                          |   2 +-
 src/lib/test-ostream-file.c                     |   2 +-
 src/lib/unlink-directory.c                      |  12 ++++++------
 src/lmtp/commands.c                             |   2 +-
 src/login-common/access-lookup.c                |   2 +-
 src/login-common/ssl-proxy-gnutls.c             |   2 +-
 src/master/main.c                               |   6 +++---
 src/master/service-listen.c                     |   4 ++--
 src/master/service-monitor.c                    |   7 ++++---
 src/master/service.c                            |   2 +-
 src/plugins/acl/acl-backend-vfile-acllist.c     |   2 +-
 src/plugins/acl/acl-backend-vfile.c             |   6 +++---
 src/plugins/fts-lucene/fts-backend-lucene.c     |   2 +-
 src/plugins/fts-squat/squat-trie.c              |   2 +-
 src/plugins/fts/doveadm-dump-fts-expunge-log.c  |   2 +-
 src/plugins/fts/fts-expunge-log.c               |   2 +-
 src/plugins/fts/fts-indexer.c                   |   2 +-
 src/plugins/fts/fts-parser-script.c             |   4 ++--
 src/plugins/quota/quota-maildir.c               |  17 ++++++-----------
 src/plugins/trash/trash-plugin.c                |   2 +-
 src/plugins/virtual/virtual-config.c            |   2 +-
 src/plugins/zlib/doveadm-zlib.c                 |   2 +-
 src/plugins/zlib/zlib-plugin.c                  |   2 +-
 src/pop3/main.c                                 |   4 +++-
 src/ssl-params/ssl-params.c                     |   6 +++---
 src/util/gdbhelper.c                            |   2 +-
 src/util/rawlog.c                               |  15 ++++++---------
 76 files changed, 178 insertions(+), 175 deletions(-)

diffs (truncated from 1518 to 300 lines):

diff -r 183adc90781c -r 3945a3646c67 src/auth/db-checkpassword.c
--- a/src/auth/db-checkpassword.c	Wed Jun 27 12:03:51 2012 +0300
+++ b/src/auth/db-checkpassword.c	Thu Jun 28 00:27:13 2012 +0300
@@ -473,8 +473,8 @@
 		auth_request_log_error(request, "checkpassword",
 				       "pipe() failed: %m");
 		if (fd_in[0] != -1) {
-			i_close_fd(fd_in[0]);
-			i_close_fd(fd_in[1]);
+			i_close_fd(&fd_in[0]);
+			i_close_fd(&fd_in[1]);
 		}
 		callback(request, DB_CHECKPASSWORD_STATUS_INTERNAL_FAILURE,
 			 NULL, request_callback);
@@ -485,10 +485,10 @@
 	if (pid == -1) {
 		auth_request_log_error(request, "checkpassword",
 				       "fork() failed: %m");
-		i_close_fd(fd_in[0]);
-		i_close_fd(fd_in[1]);
-		i_close_fd(fd_out[0]);
-		i_close_fd(fd_out[1]);
+		i_close_fd(&fd_in[0]);
+		i_close_fd(&fd_in[1]);
+		i_close_fd(&fd_out[0]);
+		i_close_fd(&fd_out[1]);
 		callback(request, DB_CHECKPASSWORD_STATUS_INTERNAL_FAILURE,
 			 NULL, request_callback);
 		return;
@@ -496,8 +496,8 @@
 
 	if (pid == 0) {
 		/* child */
-		i_close_fd(fd_in[0]);
-		i_close_fd(fd_out[1]);
+		i_close_fd(&fd_in[0]);
+		i_close_fd(&fd_out[1]);
 		checkpassword_exec(db, request, fd_in[1], fd_out[0],
 				   auth_password != NULL);
 		/* not reached */
diff -r 183adc90781c -r 3945a3646c67 src/auth/db-passwd-file.c
--- a/src/auth/db-passwd-file.c	Wed Jun 27 12:03:51 2012 +0300
+++ b/src/auth/db-passwd-file.c	Thu Jun 28 00:27:13 2012 +0300
@@ -184,7 +184,7 @@
 
 	if (fstat(fd, &st) != 0) {
 		i_error("passwd-file %s: fstat() failed: %m", pw->path);
-		i_close_fd(fd);
+		i_close_fd(&fd);
 		return FALSE;
 	}
 
diff -r 183adc90781c -r 3945a3646c67 src/auth/mech-winbind.c
--- a/src/auth/mech-winbind.c	Wed Jun 27 12:03:51 2012 +0300
+++ b/src/auth/mech-winbind.c	Thu Jun 28 00:27:13 2012 +0300
@@ -111,15 +111,15 @@
 		return;
 	}
 	if (pipe(outfd) < 0) {
-		i_close_fd(infd[0]); i_close_fd(infd[1]);
+		i_close_fd(&infd[0]); i_close_fd(&infd[1]);
 		return;
 	}
 
 	pid = fork();
 	if (pid < 0) {
 		i_error("fork() failed: %m");
-		i_close_fd(infd[0]); i_close_fd(infd[1]);
-		i_close_fd(outfd[0]); i_close_fd(outfd[1]);
+		i_close_fd(&infd[0]); i_close_fd(&infd[1]);
+		i_close_fd(&outfd[0]); i_close_fd(&outfd[1]);
 		return;
 	}
 
@@ -127,8 +127,8 @@
 		/* child */
 		const char *args[3];
 
-		i_close_fd(infd[0]);
-		i_close_fd(outfd[1]);
+		i_close_fd(&infd[0]);
+		i_close_fd(&outfd[1]);
 
 		if (dup2(outfd[0], STDIN_FILENO) < 0 ||
 		    dup2(infd[1], STDOUT_FILENO) < 0)
@@ -141,8 +141,8 @@
 	}
 
 	/* parent */
-	i_close_fd(infd[1]);
-	i_close_fd(outfd[0]);
+	i_close_fd(&infd[1]);
+	i_close_fd(&outfd[0]);
 
 	winbind->pid = pid;
 	winbind->in_pipe =
diff -r 183adc90781c -r 3945a3646c67 src/config/config-parser.c
--- a/src/config/config-parser.c	Wed Jun 27 12:03:51 2012 +0300
+++ b/src/config/config-parser.c	Thu Jun 28 00:27:13 2012 +0300
@@ -439,7 +439,7 @@
 		*error_r = t_strdup_printf("%s: read(%s) failed: %m",
 					   key, path);
 	}
-	i_close_fd(fd);
+	i_close_fd(&fd);
 	return ret < 0 ? -1 : 0;
 }
 
diff -r 183adc90781c -r 3945a3646c67 src/config/sysinfo-get.c
--- a/src/config/sysinfo-get.c	Wed Jun 27 12:03:51 2012 +0300
+++ b/src/config/sysinfo-get.c	Thu Jun 28 00:27:13 2012 +0300
@@ -21,7 +21,7 @@
 	if (fd == -1)
 		return FALSE;
 	ret = read(fd, buf, sizeof(buf));
-	i_close_fd(fd);
+	i_close_fd(&fd);
 	if (ret <= 0)
 		return FALSE;
 
diff -r 183adc90781c -r 3945a3646c67 src/director/director-test.c
--- a/src/director/director-test.c	Wed Jun 27 12:03:51 2012 +0300
+++ b/src/director/director-test.c	Thu Jun 28 00:27:13 2012 +0300
@@ -338,7 +338,7 @@
 
 	out_fd = net_connect_ip(local_ip, DIRECTOR_OUT_PORT, NULL);
 	if (out_fd == -1) {
-		i_close_fd(in_fd);
+		i_close_fd(&in_fd);
 		return;
 	}
 
diff -r 183adc90781c -r 3945a3646c67 src/doveadm/doveadm-dump-log.c
--- a/src/doveadm/doveadm-dump-log.c	Wed Jun 27 12:03:51 2012 +0300
+++ b/src/doveadm/doveadm-dump-log.c	Thu Jun 28 00:27:13 2012 +0300
@@ -509,7 +509,7 @@
 	    hdr.major_version == MAIL_TRANSACTION_LOG_MAJOR_VERSION &&
 	    hdr.hdr_size >= MAIL_TRANSACTION_LOG_HEADER_MIN_SIZE)
 		ret = TRUE;
-	i_close_fd(fd);
+	i_close_fd(&fd);
 	return ret;
 }
 
diff -r 183adc90781c -r 3945a3646c67 src/doveadm/doveadm-dump-mailboxlog.c
--- a/src/doveadm/doveadm-dump-mailboxlog.c	Wed Jun 27 12:03:51 2012 +0300
+++ b/src/doveadm/doveadm-dump-mailboxlog.c	Thu Jun 28 00:27:13 2012 +0300
@@ -100,7 +100,7 @@
 			break;
 		}
 	}
-	i_close_fd(fd);
+	i_close_fd(&fd);
 	return ret;
 }
 
diff -r 183adc90781c -r 3945a3646c67 src/doveadm/doveadm-instance.c
--- a/src/doveadm/doveadm-instance.c	Wed Jun 27 12:03:51 2012 +0300
+++ b/src/doveadm/doveadm-instance.c	Thu Jun 28 00:27:13 2012 +0300
@@ -39,7 +39,7 @@
 				  (kill(pid, 0) < 0 && errno == ESRCH));
 		}
 	}
-	i_close_fd(fd);
+	i_close_fd(&fd);
 	return found;
 }
 
diff -r 183adc90781c -r 3945a3646c67 src/doveadm/doveadm-master.c
--- a/src/doveadm/doveadm-master.c	Wed Jun 27 12:03:51 2012 +0300
+++ b/src/doveadm/doveadm-master.c	Thu Jun 28 00:27:13 2012 +0300
@@ -41,7 +41,7 @@
 				  (kill(*pid_r, 0) < 0 && errno == ESRCH));
 		}
 	}
-	i_close_fd(fd);
+	i_close_fd(&fd);
 	return found;
 }
 
diff -r 183adc90781c -r 3945a3646c67 src/doveadm/doveadm-sis.c
--- a/src/doveadm/doveadm-sis.c	Wed Jun 27 12:03:51 2012 +0300
+++ b/src/doveadm/doveadm-sis.c	Thu Jun 28 00:27:13 2012 +0300
@@ -48,7 +48,7 @@
 	if (fd1 == -1) {
 		if (errno != ENOENT)
 			i_error("open(%s) failed: %m", path2);
-		i_close_fd(fd1);
+		i_close_fd(&fd1);
 		return -1;
 	}
 
diff -r 183adc90781c -r 3945a3646c67 src/doveadm/doveadm-stats.c
--- a/src/doveadm/doveadm-stats.c	Wed Jun 27 12:03:51 2012 +0300
+++ b/src/doveadm/doveadm-stats.c	Thu Jun 28 00:27:13 2012 +0300
@@ -496,7 +496,7 @@
 	array_free(&ctx.lines);
 	pool_unref(&ctx.prev_pool);
 	pool_unref(&ctx.cur_pool);
-	i_close_fd(ctx.fd);
+	i_close_fd(&ctx.fd);
 }
 
 static void cmd_stats_top(int argc, char *argv[])
diff -r 183adc90781c -r 3945a3646c67 src/doveadm/dsync/doveadm-dsync.c
--- a/src/doveadm/dsync/doveadm-dsync.c	Wed Jun 27 12:03:51 2012 +0300
+++ b/src/doveadm/dsync/doveadm-dsync.c	Thu Jun 28 00:27:13 2012 +0300
@@ -79,12 +79,12 @@
 		    dup2(fd_err[1], STDERR_FILENO) < 0)
 			i_fatal("dup2() failed: %m");
 
-		i_close_fd(fd_in[0]);
-		i_close_fd(fd_in[1]);
-		i_close_fd(fd_out[0]);
-		i_close_fd(fd_out[1]);
-		i_close_fd(fd_err[0]);
-		i_close_fd(fd_err[1]);
+		i_close_fd(&fd_in[0]);
+		i_close_fd(&fd_in[1]);
+		i_close_fd(&fd_out[0]);
+		i_close_fd(&fd_out[1]);
+		i_close_fd(&fd_err[0]);
+		i_close_fd(&fd_err[1]);
 
 		execvp_const(args[0], args);
 	default:
@@ -92,9 +92,9 @@
 		break;
 	}
 
-	i_close_fd(fd_in[0]);
-	i_close_fd(fd_out[1]);
-	i_close_fd(fd_err[1]);
+	i_close_fd(&fd_in[0]);
+	i_close_fd(&fd_out[1]);
+	i_close_fd(&fd_err[1]);
 	ctx->fd_in = fd_out[0];
 	ctx->fd_out = fd_in[1];
 	ctx->fd_err = fd_err[0];
@@ -362,10 +362,8 @@
 		dsync_slave_deinit(&slave2);
 	if (ctx->io_err != NULL)
 		io_remove(&ctx->io_err);
-	if (ctx->fd_err != -1) {
-		i_close_fd(ctx->fd_err);
-		ctx->fd_err = -1;
-	}
+	if (ctx->fd_err != -1)
+		i_close_fd(&ctx->fd_err);
 	return ret;
 }
 
diff -r 183adc90781c -r 3945a3646c67 src/doveadm/dsync/dsync-slave-io.c
--- a/src/doveadm/dsync/dsync-slave-io.c	Wed Jun 27 12:03:51 2012 +0300
+++ b/src/doveadm/dsync/dsync-slave-io.c	Thu Jun 28 00:27:13 2012 +0300
@@ -1365,7 +1365,7 @@
 	if (unlink(str_c(path)) < 0) {
 		/* shouldn't happen.. */
 		i_error("unlink(%s) failed: %m", str_c(path));
-		i_close_fd(fd);
+		i_close_fd(&fd);
 		return -1;
 	}
 
diff -r 183adc90781c -r 3945a3646c67 src/imap/main.c
--- a/src/imap/main.c	Wed Jun 27 12:03:51 2012 +0300
+++ b/src/imap/main.c	Thu Jun 28 00:27:13 2012 +0300
@@ -271,13 +271,15 @@
 				 client->auth_req.data_size);
 	if (client_create_from_input(&input, client, client->fd, client->fd,
 				     &input_buf, &error) < 0) {
-		if (write(client->fd, MSG_BYE_INTERNAL_ERROR,
+		int fd = client->fd;
+
+		if (write(fd, MSG_BYE_INTERNAL_ERROR,
 			  strlen(MSG_BYE_INTERNAL_ERROR)) < 0) {
 			if (errno != EAGAIN && errno != EPIPE)
 				i_error("write(client) failed: %m");
 		}
 		i_error("%s", error);
-		i_close_fd(client->fd);
+		i_close_fd(&fd);
 		master_service_client_connection_destroyed(master_service);
 	}
 }
diff -r 183adc90781c -r 3945a3646c67 src/lda/main.c
--- a/src/lda/main.c	Wed Jun 27 12:03:51 2012 +0300
+++ b/src/lda/main.c	Thu Jun 28 00:27:13 2012 +0300
@@ -101,7 +101,7 @@
 	if (unlink(str_c(path)) < 0) {
 		/* shouldn't happen.. */
 		i_error("unlink(%s) failed: %m", str_c(path));
-		i_close_fd(fd);
+		i_close_fd(&fd);
 		return -1;
 	}
 
diff -r 183adc90781c -r 3945a3646c67 src/lib-dict/dict-file.c
--- a/src/lib-dict/dict-file.c	Wed Jun 27 12:03:51 2012 +0300
+++ b/src/lib-dict/dict-file.c	Thu Jun 28 00:27:13 2012 +0300


More information about the dovecot-cvs mailing list