@matheusbsbs / matheus-bagliano / commits / a47551c382
Fork 0

daemon: deglobalize variable 'directory'

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 49ba83fb67d9e447b86953965ce5f949c6a93b81. Signed-off-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx> Signed-off-by: Junio C Hamano <gitster@pobox.com>

René Scharfe committed Nov 23, 2008 at 00:21 UTC a47551c3828f81ec88d5b0b3d05887f1a7a4233a
1 file changed +6 -10
daemon.c
+6 -10
@@ -57,7 +57,6 @@ static char *hostname;
57 static char *canon_hostname;
58 static char *ip_address;
59 static char *tcp_port;
60 -static char *directory;
60
61 static void logreport(int priority, const char *err, va_list params)
62 {
@@ -147,7 +146,7 @@ static int avoid_alias(char *p)
146 }
147 }
148
150 -static char *path_ok(void)
149 +static char *path_ok(char *directory)
150 {
151 static char rpath[PATH_MAX];
152 static char interp_path[PATH_MAX];
@@ -296,12 +295,12 @@ static int git_daemon_config(const char *var, const char *value, void *cb)
295 return 0;
296 }
297
299 -static int run_service(struct daemon_service *service)
298 +static int run_service(char *dir, struct daemon_service *service)
299 {
300 const char *path;
301 int enabled = service->enabled;
302
304 - loginfo("Request %s for '%s'", service->name, directory);
303 + loginfo("Request %s for '%s'", service->name, dir);
304
305 if (!enabled && !service->overridable) {
306 logerror("'%s': service not enabled.", service->name);
@@ -309,7 +308,7 @@ static int run_service(struct daemon_service *service)
308 return -1;
309 }
310
312 - if (!(path = path_ok()))
311 + if (!(path = path_ok(dir)))
312 return -1;
313
314 /*
@@ -555,8 +554,7 @@ static int execute(struct sockaddr *addr)
554 free(canon_hostname);
555 free(ip_address);
556 free(tcp_port);
558 - free(directory);
559 - hostname = canon_hostname = ip_address = tcp_port = directory = NULL;
557 + hostname = canon_hostname = ip_address = tcp_port = NULL;
558
559 if (len != pktlen)
560 parse_extra_args(line + len + 1, pktlen - len - 1);
@@ -571,9 +569,7 @@ static int execute(struct sockaddr *addr)
569 * Note: The directory here is probably context sensitive,
570 * and might depend on the actual service being performed.
571 */
574 - free(directory);
575 - directory = xstrdup(line + namelen + 5);
576 - return run_service(s);
572 + return run_service(line + namelen + 5, s);
573 }
574 }
575