Signed-off-by: Pawel Wieczorkiewicz <pwieczorkiewicz(a)suse.de>
Signed-off-by: Sebastian Krahmer <krahmer(a)suse.com>
---
configure.ac | 8 ++++++++
teamd/teamd.c | 8 ++++----
teamd/teamd.h | 2 ++
teamd/teamd_usock.c | 4 ----
4 files changed, 14 insertions(+), 8 deletions(-)
diff --git a/configure.ac b/configure.ac
index 1115e95..302a11a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -101,6 +101,14 @@ AC_ARG_ENABLE([zmq],
fi
fi
+AC_ARG_WITH([run-dir],
+ [AS_HELP_STRING([--with-run-dir@<:@=DIR@:>@], [Teamd run time directory @<:@default=${localstatedir}@:>@])],
+ [case "$withval" in
+ yes|no|"") ;;
+ *) AC_DEFINE_UNQUOTED(TEAMD_RUN_DIR, "${withval}/", [TEAMD RUN DIR.]) ;;
+ esac]
+)
+
AC_CHECK_PROGS([DOXYGEN], [doxygen])
if test -z "$DOXYGEN";
then AC_MSG_WARN([Doxygen not found - continuing without Doxygen support])
diff --git a/teamd/teamd.c b/teamd/teamd.c
index 764e4f6..cdf1fc3 100644
--- a/teamd/teamd.c
+++ b/teamd/teamd.c
@@ -1621,10 +1621,6 @@ static int teamd_set_default_pid_file(struct teamd_context *ctx)
if (ctx->pid_file)
return 0;
- err = teamd_make_rundir();
- if (err)
- return err;
-
err = asprintf(&ctx->pid_file, TEAMD_RUN_DIR"%s.pid", ctx->team_devname);
if (err == -1) {
teamd_log_err("Failed allocate memory for PID file string.");
@@ -1676,6 +1672,10 @@ int main(int argc, char **argv)
int err;
struct teamd_context *ctx;
+ err = teamd_make_rundir();
+ if (err)
+ return ret;
+
err = teamd_context_init(&ctx);
if (err) {
fprintf(stderr, "Failed to init daemon context\n");
diff --git a/teamd/teamd.h b/teamd/teamd.h
index 845ca18..d8ab6c8 100644
--- a/teamd/teamd.h
+++ b/teamd/teamd.h
@@ -67,7 +67,9 @@ static inline void TEAMD_BUG_ON(bool condition)
TEAMD_BUG();
}
+#ifndef TEAMD_RUN_DIR
#define TEAMD_RUN_DIR "/var/run/teamd/"
+#endif
static inline int teamd_make_rundir(void)
{
diff --git a/teamd/teamd_usock.c b/teamd/teamd_usock.c
index 967f68c..c421c7a 100644
--- a/teamd/teamd_usock.c
+++ b/teamd/teamd_usock.c
@@ -298,10 +298,6 @@ static int teamd_usock_sock_open(struct teamd_context *ctx)
int sock;
int err;
- err = teamd_make_rundir();
- if (err)
- return err;
-
sock = socket(AF_UNIX, SOCK_SEQPACKET, 0);
if (sock == -1) {
teamd_log_err("usock: Failed to create socket.");
--
2.1.4