]> git.ipfire.org Git - thirdparty/git.git/blobdiff - daemon.c
submodule: use new config API for worktree configurations
[thirdparty/git.git] / daemon.c
index 9ee21877cd952a7aa47c793d877174d858488794..d3d3e433e370e7a21dad829b5861172e92a6d72f 100644 (file)
--- a/daemon.c
+++ b/daemon.c
@@ -633,7 +633,7 @@ static void lookup_hostname(struct hostinfo *hi)
                char **ap;
                static char addrbuf[HOST_NAME_MAX + 1];
 
-               hent = gethostbyname(hostname.buf);
+               hent = gethostbyname(hi->hostname.buf);
                if (hent) {
                        ap = hent->h_addr_list;
                        memset(&sa, 0, sizeof sa);
@@ -1166,15 +1166,6 @@ static struct credentials *prepare_credentials(const char *user_name,
 }
 #endif
 
-static void store_pid(const char *path)
-{
-       FILE *f = fopen(path, "w");
-       if (!f)
-               die_errno("cannot open pid file '%s'", path);
-       if (fprintf(f, "%"PRIuMAX"\n", (uintmax_t) getpid()) < 0 || fclose(f) != 0)
-               die_errno("failed to write pid file '%s'", path);
-}
-
 static int serve(struct string_list *listen_addr, int listen_port,
     struct credentials *cred)
 {
@@ -1385,7 +1376,7 @@ int main(int argc, char **argv)
                sanitize_stdfds();
 
        if (pid_file)
-               store_pid(pid_file);
+               write_file(pid_file, 1, "%"PRIuMAX"\n", (uintmax_t) getpid());
 
        /* prepare argv for serving-processes */
        cld_argv = xmalloc(sizeof (char *) * (argc + 2));