Permalink
Browse files

Move setup and teardown of logging into main() to avoid duplication.

  • Loading branch information...
1 parent 140220b commit ef41220ad89b3345bc05497968333946aa621670 @aspiers committed Mar 3, 2012
Showing with 4 additions and 6 deletions.
  1. +4 −6 src/main.c
View
@@ -961,7 +961,6 @@ static int do_server(int type)
int fd;
int rv = -1;
- setup_logging();
fd = lockfile();
if (fd < 0)
return fd;
@@ -990,7 +989,6 @@ static int do_server(int type)
goto fail;
unlink_lockfile(fd);
- close_logging();
return 0;
fail:
@@ -1001,8 +999,6 @@ static int do_client(void)
{
int rv = -1;
- setup_logging();
-
switch (cl.op) {
case OP_LIST:
rv = do_list();
@@ -1017,8 +1013,6 @@ static int do_client(void)
break;
}
- close_logging();
-
return rv;
}
@@ -1033,6 +1027,8 @@ int main(int argc, char *argv[])
if (rv < 0)
goto out;
+ setup_logging();
+
switch (cl.type) {
case ACT_ARBITRATOR:
rv = do_server(ARBITRATOR);
@@ -1047,6 +1043,8 @@ int main(int argc, char *argv[])
break;
}
+ close_logging();
+
out:
return rv ? EXIT_FAILURE : EXIT_SUCCESS;
}

0 comments on commit ef41220

Please sign in to comment.