src/Makefile | 11 +++++------
src/main.c | 4 +++-
src/monotime.c | 13 +++++++++++++
src/monotime.h | 14 ++++++++++++++
wdmd/main.c | 5 ++++-
5 files changed, 39 insertions(+), 8 deletions(-)
New commits:
commit 1b7f6c1ff6468066c173e77bb11c6cfc23ae3140
Author: David Teigland <teigland(a)redhat.com>
Date: Wed Aug 3 15:11:07 2011 -0500
sanlock: add missing monotime files
forgot to add in earlier commit
diff --git a/src/monotime.c b/src/monotime.c
new file mode 100644
index 0000000..79e7a58
--- /dev/null
+++ b/src/monotime.c
@@ -0,0 +1,13 @@
+#include <unistd.h>
+#include <stdint.h>
+#include <time.h>
+#include "monotime.h"
+
+uint64_t monotime(void)
+{
+ struct timespec ts;
+
+ clock_gettime(CLOCK_MONOTONIC, &ts);
+
+ return ts.tv_sec;
+}
diff --git a/src/monotime.h b/src/monotime.h
new file mode 100644
index 0000000..c375111
--- /dev/null
+++ b/src/monotime.h
@@ -0,0 +1,14 @@
+/*
+ * Copyright (C) 2011 Red Hat, Inc. All rights reserved.
+ *
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU General Public License v.2.
+ */
+
+#ifndef __MONOTIME_H__
+#define __MONOTIME_H__
+
+uint64_t monotime(void);
+
+#endif
commit e5755f76327b05a1b980d1739013cb7a767156b8
Author: David Teigland <teigland(a)redhat.com>
Date: Wed Aug 3 14:34:06 2011 -0500
sanlock/wdmd: nonblocking listening/accept
Undo previous commits that changed accept() to accept4(SOCK_NONBLOCK).
That causes the fd returned from accept to be nonblocking, which is
not what I want (it causes recv's to start returning EAGAIN). What
I intended was the listening fd to be nonblocking.
diff --git a/src/main.c b/src/main.c
index b58ecd4..1dc268e 100644
--- a/src/main.c
+++ b/src/main.c
@@ -2033,7 +2033,7 @@ static void process_listener(int ci GNUC_UNUSED)
int fd;
int on = 1;
- fd = accept4(client[ci].fd, NULL, NULL, SOCK_NONBLOCK);
+ fd = accept(client[ci].fd, NULL, NULL);
if (fd < 0)
return;
@@ -2072,6 +2072,8 @@ static int setup_listener(void)
if (rv < 0)
goto exit_fail;
+ fcntl(fd, F_SETFL, fcntl(fd, F_GETFL, 0) | O_NONBLOCK);
+
ci = client_add(fd, process_listener, NULL);
if (ci < 0)
goto exit_fail;
diff --git a/wdmd/main.c b/wdmd/main.c
index 8977a49..95dcd3b 100644
--- a/wdmd/main.c
+++ b/wdmd/main.c
@@ -280,7 +280,7 @@ static void process_listener(int ci)
int fd;
int on = 1;
- fd = accept4(client[ci].fd, NULL, NULL, SOCK_NONBLOCK);
+ fd = accept(client[ci].fd, NULL, NULL);
if (fd < 0)
return;
@@ -327,6 +327,9 @@ static int setup_listener_socket(int *listener_socket)
close(s);
return rv;
}
+
+ fcntl(s, F_SETFL, fcntl(s, F_GETFL, 0) | O_NONBLOCK);
+
*listener_socket = s;
return 0;
}
commit 4329415cd8387118072a90ee09a4829920457b31
Author: David Teigland <teigland(a)redhat.com>
Date: Wed Aug 3 14:11:43 2011 -0500
sanlock: build with pie
diff --git a/src/Makefile b/src/Makefile
index edc299b..ec318d3 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -62,15 +62,14 @@ CFLAGS += -D_GNU_SOURCE -g \
-fexceptions \
-fasynchronous-unwind-tables \
-fdiagnostics-show-option
-# -fPIE -DPIE
+
+CMD_CFLAGS = $(CFLAGS) -fPIE -DPIE
CMD_LDFLAGS += -lpthread -luuid -lrt -laio -lblkid -lsanlock -L../wdmd -lwdmd
-CMD_LDFLAGS += -Wl,-z,now -Wl,-z,relro
-#CMD_LDFLAGS += -Wl,-z,now -Wl,-z,relro -pie
+CMD_LDFLAGS += -Wl,-z,now -Wl,-z,relro -pie
LIB_LDFLAGS += -lpthread -lrt -laio -lblkid -L../wdmd -lwdmd
-LIB_LDFLAGS += -Wl,-z,relro
-#LIB_LDFLAGS += -Wl,-z,relro -pie
+LIB_LDFLAGS += -Wl,-z,relro -pie
all: $(SHLIB_TARGET) $(CMD_TARGET)
@@ -80,7 +79,7 @@ $(SHLIB_TARGET): $(LIB_SOURCE)
ln -sf $(SHLIB_TARGET) $(LIB_TARGET).so.$(SOMAJOR)
$(CMD_TARGET): $(SHLIB_TARGET) $(CMD_SOURCE)
- $(CC) $(CFLAGS) $(CMD_LDFLAGS) $(CMD_SOURCE) -o $@ -L.
+ $(CC) $(CMD_CFLAGS) $(CMD_LDFLAGS) $(CMD_SOURCE) -o $@ -L.
clean:
rm -f *.o *.so *.so.* $(CMD_TARGET)