You're right, it's not needed anywhere, at the end I used setLock directly.
I'll remove this patch from the series.


On Thu, Apr 17, 2014 at 3:33 PM, Klaus Aehlig <[email protected]> wrote:

> On Thu, Apr 17, 2014 at 03:11:19PM +0200, Petr Pudlak wrote:
> > Also extend 'lockFile' to return the file descriptor of the locked file
> > so that it can be closed later, if needed.
> >
> > Signed-off-by: Petr Pudlak <[email protected]>
> > ---
> >  src/Ganeti/Query/Server.hs |  2 +-
> >  src/Ganeti/Utils.hs        | 15 ++++++++++++++-
> >  2 files changed, 15 insertions(+), 2 deletions(-)
> >
> > diff --git a/src/Ganeti/Query/Server.hs b/src/Ganeti/Query/Server.hs
> > index 3aa8ed7..7315d83 100644
> > --- a/src/Ganeti/Query/Server.hs
> > +++ b/src/Ganeti/Query/Server.hs
> > @@ -466,7 +466,7 @@ main _ _ (server, cref, jq) = do
> >    initJQScheduler jq
> >
> >    qlockFile <- jobQueueLockFile
> > -  lockFile qlockFile >>= exitIfBad "Failed to obtain the job-queue lock"
> > +  _ <- lockFile qlockFile >>= exitIfBad "Failed to obtain the job-queue
> lock"
> >    qlock <- newMVar ()
> >
> >    finally
> > diff --git a/src/Ganeti/Utils.hs b/src/Ganeti/Utils.hs
> > index 3c1b0f1..57c7cea 100644
> > --- a/src/Ganeti/Utils.hs
> > +++ b/src/Ganeti/Utils.hs
> > @@ -69,6 +69,7 @@ module Ganeti.Utils
> >    , formatOrdinal
> >    , tryAndLogIOError
> >    , lockFile
> > +  , lockFileR
> >    , FStat
> >    , nullFStat
> >    , getFStat
> > @@ -564,11 +565,23 @@ formatOrdinal num
> >
> >  -- | Attempt, in a non-blocking way, to obtain a lock on a given file;
> report
> >  -- back success.
> > -lockFile :: FilePath -> IO (Result ())
> > +-- Returns the file descriptor so that the lock can be released by
> closing it.
> > +lockFile :: FilePath -> IO (Result Fd)
> >  lockFile path = runResultT . liftIO $ do
> >    handle <- openFile path WriteMode
> >    fd <- handleToFd handle
> >    setLock fd (WriteLock, AbsoluteSeek, 0, 0)
> > +  return fd
> > +
> > +-- | Attempt, in a non-blocking way, to obtain a /read/ lock on a given
> file;
> > +-- report back success.
> > +-- Returns the file descriptor so that the lock can be released by
> closing it.
> > +lockFileR :: FilePath -> IO (Result Fd)
> > +lockFileR path = runResultT . liftIO $ do
> > +  handle <- openFile path ReadMode
> > +  fd <- handleToFd handle
> > +  setLock fd (ReadLock, AbsoluteSeek, 0, 0)
> > +  return fd
>
> I don't find the function lockFileR used anywhere in this patch series.
> Can you
> check whether this part of the patch is needed?
>
> --
> Klaus Aehlig
> Google Germany GmbH, Dienerstr. 12, 80331 Muenchen
> Registergericht und -nummer: Hamburg, HRB 86891
> Sitz der Gesellschaft: Hamburg
> Geschaeftsfuehrer: Graham Law, Christine Elizabeth Flores
>

Reply via email to