1
0
mirror of https://github.com/Zygo/bees.git synced 2025-05-18 05:45:45 +02:00

context: cache result of home_fd()

BeesContext::home_fd() is supposed to open $BEESHOME once and cache
the Fd for later calls; however, instead it was reopening a new Fd each
time it was called, and _also_ holding that Fd in a BeesContext member.
Fds clean themselves up when they are forgotten, so it was not leaking
per se, but it certainly had more open Fds than it needed to.

Check to see if we have m_home_fd open, and return that if so.

Signed-off-by: Zygo Blaxell <bees@furryterror.org>
This commit is contained in:
Zygo Blaxell 2018-10-30 01:28:34 -04:00 committed by Kai Krakow
parent c426794542
commit 256da15ac1
No known key found for this signature in database
GPG Key ID: 046FAC3028D76321

View File

@ -150,6 +150,10 @@ BeesContext::show_progress()
Fd Fd
BeesContext::home_fd() BeesContext::home_fd()
{ {
if (!!m_home_fd) {
return m_home_fd;
}
const char *base_dir = getenv("BEESHOME"); const char *base_dir = getenv("BEESHOME");
if (!base_dir) { if (!base_dir) {
base_dir = ".beeshome"; base_dir = ".beeshome";