]> git.tuebingen.mpg.de Git - dss.git/commitdiff
Merge branch 'refs/heads/t/lopsub'
authorAndre Noll <maan@tuebingen.mpg.de>
Sun, 15 Oct 2017 12:51:29 +0000 (14:51 +0200)
committerAndre Noll <maan@tuebingen.mpg.de>
Sun, 15 Oct 2017 12:54:40 +0000 (14:54 +0200)
Conversion to lopsub and a few other improvements on top of it.

* refs/heads/t/lopsub:
  INSTALL: Explain how to use CPPFLAGS and LDFLAGS.
  build: Introduce DSS_CPPFLAGS.
  build: Fix cc command which creates dependencies,
  build: Combine CFLAGS and DEBUG_CFLAGS.
  Implement --checksum.
  run: Improve error diagnostics for chdir(2) failure.
  run: Improve error message if dss is already running.
  run: Fix exit status in case another dss process is running.
  build: Add target install and install-strip.
  Convert dss to lopsub.
  Remove --no-resume.

NEWS
ipc.c

diff --git a/NEWS b/NEWS
index 15323207ace195048ca7ee69de66e22f2969ea7c..755cad21834cc7b6d150746e6555544d706802c6 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,26 @@
+-----------------------
+x.y.z (to be announced)
+-----------------------
+
+ - Improved error diagnostics for the kill subcommand.
+
+ - The --no-resume option has been removed.
+
+ - The gengetopt option parser has been replaced by the
+ [lopsub](http://people.tuebingen.mpg.de/~maan/lopsub) library. Hence
+ lopsub must be installed to compile this package. Also help2man is
+ no longer required since lopsub has built-in roff support.
+
+ - "make install" will install the executable and the man page.
+
+ - In run mode, dss no longer exits successfully if another instance
+ is already running.
+
+ - New option --checksum to let rsync compute checksums occasionally.
+
+ - CFLAGS, CPPFLAGS and LDFLAGS can now be used to override the flags
+ of the build system.
+
 ------------------
 0.1.7 (2017-04-17)
 ------------------
diff --git a/ipc.c b/ipc.c
index c55554c5d3fd815cd09c045a94f7b72d5bd5db85..183c76e9b4ad0b46ee2910207f12626fbb7087ca 100644 (file)
--- a/ipc.c
+++ b/ipc.c
@@ -258,11 +258,11 @@ static int get_key_or_die(const char *config_file)
        return ret;
 }
 
-static int mutex_get(int key, int flags)
+static int mutex_get(key_t key, int flags)
 {
        int ret;
 
-       DSS_DEBUG_LOG(("getting semaphore 0x%x\n", key));
+       DSS_DEBUG_LOG(("getting semaphore 0x%lx\n", (long)key));
        ret = semget(key, 2, flags);
        if (ret < 0)
                return -ERRNO_TO_DSS_ERROR(errno);
@@ -282,31 +282,6 @@ static int do_semop(int id, struct sembuf *sops, int num)
        return -ERRNO_TO_DSS_ERROR(errno);
 }
 
-static int mutex_lock(int id)
-{
-       struct sembuf sops[4];
-
-       DSS_DEBUG_LOG(("locking\n"));
-
-       sops[0].sem_num = 0;
-       sops[0].sem_op = 0;
-       sops[0].sem_flg = SEM_UNDO | IPC_NOWAIT;
-
-       sops[1].sem_num = 0;
-       sops[1].sem_op = 1;
-       sops[1].sem_flg = SEM_UNDO | IPC_NOWAIT;
-
-       sops[2].sem_num = 1;
-       sops[2].sem_op = 0;
-       sops[2].sem_flg = SEM_UNDO | IPC_NOWAIT;
-
-       sops[3].sem_num = 1;
-       sops[3].sem_op = 1;
-       sops[3].sem_flg = SEM_UNDO | IPC_NOWAIT;
-
-       return do_semop(id, sops, 4);
-}
-
 static bool mutex_is_locked(int id)
 {
        struct sembuf sops;
@@ -326,23 +301,44 @@ static bool mutex_is_locked(int id)
 
 int lock_dss(char *config_file)
 {
-       int ret, key = get_key_or_die(config_file);
+       int ret, id;
+       struct sembuf sops[4];
+       key_t key = get_key_or_die(config_file);
 
        ret = mutex_get(key, IPC_CREAT | 0600);
        if (ret < 0)
                return ret;
-       return mutex_lock(ret);
+       id = ret;
+
+       sops[0].sem_num = 0;
+       sops[0].sem_op = 0;
+       sops[0].sem_flg = SEM_UNDO | IPC_NOWAIT;
+
+       sops[1].sem_num = 0;
+       sops[1].sem_op = 1;
+       sops[1].sem_flg = SEM_UNDO | IPC_NOWAIT;
+
+       sops[2].sem_num = 1;
+       sops[2].sem_op = 0;
+       sops[2].sem_flg = SEM_UNDO | IPC_NOWAIT;
+
+       sops[3].sem_num = 1;
+       sops[3].sem_op = 1;
+       sops[3].sem_flg = SEM_UNDO | IPC_NOWAIT;
+
+       return do_semop(id, sops, 4);
 }
 
 int get_dss_pid(char *config_file, pid_t *pid)
 {
-       int ret, semid, key = get_key_or_die(config_file);
+       int ret, semid;
+       key_t key = get_key_or_die(config_file);
 
        if (pid)
                *pid = 0;
        ret = mutex_get(key, 0);
        if (ret < 0)
-               return ret;
+               return ret == -ERRNO_TO_DSS_ERROR(ENOENT)? -E_NOT_RUNNING : ret;
        semid = ret;
        ret = semctl(semid, 1, GETPID);
        if (ret < 0)