]> git.openfabrics.org - ~shefty/ibacm.git/commitdiff
commit
authorSean Hefty <sean.hefty@intel.com>
Fri, 10 Dec 2010 20:04:22 +0000 (12:04 -0800)
committerSean Hefty <sean.hefty@intel.com>
Fri, 10 Dec 2010 20:04:22 +0000 (12:04 -0800)
meta
patches/locking [deleted file]

diff --git a/meta b/meta
index c1e7103aead89af8a645aa918beda7d975064679..582acf3400357339d94aa0cf3b9c9af5f59fe8a4 100644 (file)
--- a/meta
+++ b/meta
@@ -1,8 +1,7 @@
 Version: 1
-Previous: 0f6ffd140e00669f8993d5eb503c8eafd439c461
+Previous: e69b7efd06283fb01f0a35f3aecd706c5e513195
 Head: 98bc2544502c6dd9bb2ed852419d0b36e7f45b74
 Applied:
-  locking: 49fcc60d268ba85ee40dc4a4e7d3a4faac3abe9b
   verbose: ab647a30aa155e72a51f9e7e228d558b8db6ec2a
   dbg_1: 669d3ab25cff51dd8ecd7a36eb74d02bd40f945e
   no_addr: c399f0580c6ba387b6aca30c622c8d2739498846
diff --git a/patches/locking b/patches/locking
deleted file mode 100644 (file)
index 4c0dc69..0000000
+++ /dev/null
@@ -1,128 +0,0 @@
-Bottom: 1ac64e1267b46288459f8b4a25aeb893b3d48cba
-Top:    517dae237c64bc280892803e33e19d8e9a7b1c5a
-Author: Sean Hefty <sean.hefty@intel.com>
-Date:   2010-12-02 14:12:56 -0800
-
-ibacm: Add lock to prevent multiple daemons from running
-
-Use a lock file to prevent multiple daemons from running
-simultaneously.
-
-Without this lock, a second instance of ib_acm eventually
-fails to bind to the server's TCP port and exits, but not
-before it overwrites a portion of the log file.
-
-Signed-off-by: Sean Hefty <sean.hefty@intel.com>
-
-
----
-
-diff --git a/acm_opts.cfg b/acm_opts.cfg
-index 372cd7b..7147fe2 100644
---- a/acm_opts.cfg
-+++ b/acm_opts.cfg
-@@ -26,6 +26,12 @@ log_file /var/log/ibacm.log
\r
- log_level 0\r
\r
-+# lock_file:\r
-+# Specifies the location of the ACM lock file used to ensure that only a\r
-+# single instance of ACM is running.\r
-+\r
-+lock_file /var/lock/ibacm.pid\r
-+\r
- # addr_prot:\r
- # Default resolution protocol to resolve IP addresses into IB GIDs.\r
- # Supported protocols are:\r
-diff --git a/src/acm.c b/src/acm.c
-index 3152392..bc7124f 100644
---- a/src/acm.c
-+++ b/src/acm.c
-@@ -36,8 +36,10 @@
- #include <string.h>
- #include <osd.h>
- #include <arpa/inet.h>
-+#include <sys/types.h>
- #include <sys/stat.h>
- #include <sys/time.h>
-+#include <fcntl.h>
- #include <infiniband/acm.h>
- #include <infiniband/umad.h>
- #include <infiniband/verbs.h>
-@@ -208,6 +210,7 @@ static char *opts_file = "/etc/ibacm/acm_opts.cfg";
- static char *addr_file = "/etc/ibacm/acm_addr.cfg";
- static char log_file[128] = "stdout";
- static int log_level = 0;
-+static char lock_file[128] = "/var/lock/ibacm.pid";
- static enum acm_addr_prot addr_prot = ACM_ADDR_PROT_ACM;
- static enum acm_route_prot route_prot = ACM_ROUTE_PROT_ACM;
- static enum acm_loopback_prot loopback_prot = ACM_LOOPBACK_PROT_LOCAL;
-@@ -2654,6 +2657,8 @@ static void acm_set_options(void)
-                       strcpy(log_file, value);
-               else if (!stricmp("log_level", opt))
-                       log_level = atoi(value);
-+              else if (!stricmp("lock_file", opt))
-+                      strcpy(lock_file, value);
-               else if (!stricmp("addr_prot", opt))
-                       addr_prot = acm_convert_addr_prot(value);
-               else if (!stricmp("route_prot", opt))
-@@ -2686,6 +2691,7 @@ static void acm_set_options(void)
- static void acm_log_options(void)
- {
-       acm_log(0, "log level %d\n", log_level);
-+      acm_log(0, "lock file %s\n", lock_file);
-       acm_log(0, "address resolution %d\n", addr_prot);
-       acm_log(0, "route resolution %d\n", route_prot);
-       acm_log(0, "loopback resolution %d\n", loopback_prot);
-@@ -2716,6 +2722,25 @@ static FILE *acm_open_log(void)
-       return f;
- }
-+static int acm_open_lock_file(void)
-+{
-+      int lock_fd;
-+      char pid[16];
-+
-+      lock_fd = open(lock_file, O_RDWR | O_CREAT, 0640);
-+      if (lock_fd < 0)
-+              return lock_fd;
-+
-+      if (lockf(lock_fd, F_TLOCK, 0)) {
-+              close(lock_fd);
-+              return -1;
-+      }
-+
-+      sprintf(pid, "%d\n", getpid());
-+      write(lock_fd, pid, strlen(pid));
-+      return 0;
-+}
-+
- static void daemonize(void)
- {
-       pid_t pid, sid;
-@@ -2778,6 +2803,8 @@ int CDECL_FUNC main(int argc, char **argv)
-               return -1;
-       acm_set_options();
-+      if (acm_open_lock_file())
-+              return -1;
-       lock_init(&log_lock);
-       flog = acm_open_log();
-diff --git a/src/acme.c b/src/acme.c
-index 218dbe8..552f42a 100644
---- a/src/acme.c
-+++ b/src/acme.c
-@@ -106,6 +106,12 @@ static void gen_opts_temp(FILE *f)
-       fprintf(f, "\n");
-       fprintf(f, "log_level 0\n");
-       fprintf(f, "\n");
-+      fprintf(f, "# lock_file:\n");
-+      fprintf(f, "# Specifies the location of the ACM lock file used to ensure that only a\n");
-+      fprintf(f, "# single instance of ACM is running.\n");
-+      fprintf(f, "\n");
-+      fprintf(f, "lock_file /var/lock/ibacm.pid\n");
-+      fprintf(f, "\n");
-       fprintf(f, "# addr_prot:\n");
-       fprintf(f, "# Default resolution protocol to resolve IP addresses into IB GIDs.\n");
-       fprintf(f, "# Supported protocols are:\n");