chg: check lockfd at freecmdserveropts
authorJun Wu <quark@fb.com>
Sun, 10 Apr 2016 22:58:11 +0100
changeset 28853 d11548b4ae45
parent 28852 7b5f5a1b4b41
child 28854 ddef14468952
chg: check lockfd at freecmdserveropts We check for sockdirfd at freecmdserveropts but not lockfd, which is a bit strange to people new to the code. Add a comment and an assert to make it clear that lockfd should be closed earlier.
contrib/chg/chg.c
--- a/contrib/chg/chg.c	Sun Apr 10 23:56:00 2016 +0100
+++ b/contrib/chg/chg.c	Sun Apr 10 22:58:11 2016 +0100
@@ -49,6 +49,7 @@
 	free(opts->args);
 	opts->args = NULL;
 	opts->argsize = 0;
+	assert(opts->lockfd == -1 && "should be closed by unlockcmdserver()");
 	if (opts->sockdirfd != AT_FDCWD) {
 		close(opts->sockdirfd);
 		opts->sockdirfd = AT_FDCWD;