"GOT", but the "O" is a cute, smiling pufferfish. Index | Thread | Search

From:
Tracey Emery <tracey@traceyemery.net>
Subject:
fds not getting properly closed
To:
gameoftrees@openbsd.org
Date:
Tue, 15 Jun 2021 15:05:55 -0600

Download raw body.

Thread
Hello,

While working on a section of gotwebd, I was testing and found that the
process's fd table kept growing and growing, also verified by the
quantity of opened fds in fstat.

I tracked this down to repo->gitdir_fd being opened in got_repo_open,
but never being closed in got_repo_close. The following is a small diff
that fixes the problem.

ok?

-- 

Tracey Emery

diff 282f42e5d1095015379b49280429e558b3bbc4fe /home/tracey/src/got
blob - a97375aa5712bae416359100f0059fa17f6cfc46
file + lib/repository.c
--- lib/repository.c
+++ lib/repository.c
@@ -752,6 +752,9 @@ got_repo_close(struct got_repository *repo)
 			err = got_error_from_errno("close");
 	}
 
+	if (repo->gitdir_fd != -1)
+		close(repo->gitdir_fd);
+
 	if (repo->gotconfig)
 		got_gotconfig_free(repo->gotconfig);
 	free(repo->gitconfig_author_name);