Skip to content

Commit

Permalink
daemon: deglobalize variable 'directory'
Browse files Browse the repository at this point in the history
Remove the global variable 'directory' and pass it as a parameter of
the two functions that use it instead, (almost) restoring their
interface to how it was before 49ba83f.

Signed-off-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
René Scharfe authored and Junio C Hamano committed Nov 24, 2008
1 parent d433ed0 commit a47551c
Showing 1 changed file with 6 additions and 10 deletions.
16 changes: 6 additions & 10 deletions daemon.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ static char *hostname;
static char *canon_hostname;
static char *ip_address;
static char *tcp_port;
static char *directory;

static void logreport(int priority, const char *err, va_list params)
{
Expand Down Expand Up @@ -147,7 +146,7 @@ static int avoid_alias(char *p)
}
}

static char *path_ok(void)
static char *path_ok(char *directory)
{
static char rpath[PATH_MAX];
static char interp_path[PATH_MAX];
Expand Down Expand Up @@ -296,20 +295,20 @@ static int git_daemon_config(const char *var, const char *value, void *cb)
return 0;
}

static int run_service(struct daemon_service *service)
static int run_service(char *dir, struct daemon_service *service)
{
const char *path;
int enabled = service->enabled;

loginfo("Request %s for '%s'", service->name, directory);
loginfo("Request %s for '%s'", service->name, dir);

if (!enabled && !service->overridable) {
logerror("'%s': service not enabled.", service->name);
errno = EACCES;
return -1;
}

if (!(path = path_ok()))
if (!(path = path_ok(dir)))
return -1;

/*
Expand Down Expand Up @@ -555,8 +554,7 @@ static int execute(struct sockaddr *addr)
free(canon_hostname);
free(ip_address);
free(tcp_port);
free(directory);
hostname = canon_hostname = ip_address = tcp_port = directory = NULL;
hostname = canon_hostname = ip_address = tcp_port = NULL;

if (len != pktlen)
parse_extra_args(line + len + 1, pktlen - len - 1);
Expand All @@ -571,9 +569,7 @@ static int execute(struct sockaddr *addr)
* Note: The directory here is probably context sensitive,
* and might depend on the actual service being performed.
*/
free(directory);
directory = xstrdup(line + namelen + 5);
return run_service(s);
return run_service(line + namelen + 5, s);
}
}

Expand Down

0 comments on commit a47551c

Please sign in to comment.