Results 1 to 2 of 2

Thread: Exclusive file creation (Samba shares)

  1. #1
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Exclusive file creation (Samba shares)

    I have the following problem:

    I have an app ( Win + Mac ) that stays connected to a samba share ( concurrent access ).
    The purpose is to lock a directory( shared ) for exclusive access by creating an empty lock file.

    The lock file is created with open(...) using the _O_CREAT and _O_EXCL flags.
    Using _O_EXCL I am guaranteed ( at least I thought so ) that open returns an error if the file already exists.

    The problem is ( I haven't been able to prove it yet ) that open returns a valid file descriptor sometimes when both clients try to create the lock file simultaneously. The result is not good - both clients think that they have created the lock file and tehrefore have exclusive access on that folder.

    Has anyone else encountered this? Or, does anyone sees a problem in this exclusive access mechanism?

    As usually, any suggestion is welcome.

    Regards,
    Marcel.

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Exclusive file creation (Samba shares)

    I think this is an overall problem with remote volumes - you can't have reliable mandatory locks with them. At least I think I read so a couple of times (the same issue is with NFS volumes). I suggest you try to do the job without relying on the lock.

Similar Threads

  1. Mac OS X - Accessing Windows Samba Shares
    By marcel in forum General Programming
    Replies: 1
    Last Post: 11th April 2007, 00:28

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.