]> Cypherpunks.ru repositories - goredo.git/blobdiff - run.go
Redundant @documentencoding
[goredo.git] / run.go
diff --git a/run.go b/run.go
index 01da3b26b4cfe1010c57fa6397415d4766fad007..2e5dbf5f7ebd5fc8e9c4cfc6e8194333b0456fd9 100644 (file)
--- a/run.go
+++ b/run.go
@@ -1,6 +1,6 @@
 /*
 goredo -- djb's redo implementation on pure Go
-Copyright (C) 2020-2022 Sergey Matveev <stargrave@stargrave.org>
+Copyright (C) 2020-2023 Sergey Matveev <stargrave@stargrave.org>
 
 This program is free software: you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
@@ -217,7 +217,7 @@ func runScript(tgtOrig string, errs chan error, traced bool) error {
                tracef(CLock, "LOCK_UN: %s", fdLock.Name())
                flock.Type = unix.F_UNLCK
                if err := unix.FcntlFlock(fdLock.Fd(), unix.F_SETLK, &flock); err != nil {
-                       log.Fatalln(err)
+                       log.Fatalln(err, fdLock.Name())
                }
                fdLock.Close()
        }
@@ -231,7 +231,7 @@ func runScript(tgtOrig string, errs chan error, traced bool) error {
                }
                Jobs.Add(1)
                if err = unix.FcntlFlock(fdLock.Fd(), unix.F_GETLK, &flock); err != nil {
-                       log.Fatalln(err)
+                       log.Fatalln(err, fdLock.Name())
                }
                tracef(CDebug, "waiting: %s (pid=%d)", tgtOrig, flock.Pid)
                if FdStatus != nil {
@@ -242,8 +242,11 @@ func runScript(tgtOrig string, errs chan error, traced bool) error {
                go func() {
                        defer Jobs.Done()
                        tracef(CLock, "LOCK_EX: %s", fdLock.Name())
+               LockAgain:
                        if err := unix.FcntlFlock(fdLock.Fd(), unix.F_SETLKW, &flock); err != nil {
-                               log.Fatalln(err)
+                               log.Println(err, fdLock.Name())
+                               time.Sleep(10 * time.Millisecond)
+                               goto LockAgain
                        }
                        lockRelease()
                        tracef(CDebug, "waiting done: %s", tgtOrig)