Contention issues with GetPrivateProfileString/WritePrivateProfileString [VC++6]

  • 14 years ago

    I have X computers (typically 5, 7, or 9) that all access a single .INI file on one of the computers (so if I have 5 machines, 4 connect remotely using \\MachineName\Folder\

    and the other one that houses the .INI file connects locally using the typical C:\Folder\).

     

    The function in questions performs the following stpes:

    -         GetPrivateProfileString to get some information from the shared .INI file

    -         WritePrivateProfileString to write some values in the shared .INI file

    (the Write occurs/is called multiple times)

     

    Now the problem is all computers try to access the SAME file at the SAME time to perform their operations (I call it a SHARED .INI file). Some of the time this works perfectly fine however there are instances (almost impossible to reproduce) where the code doesn’t return from a call to GetPrivateProfileString or WritePrivateProfileString and the process (and corresponding INI file) just stays locked in memory until I manually kill it.

     

    I was reading the following link: “http://blogs.msdn.com/junfeng/archive/2004/02/06/68152.aspx” that mentioned a similar sitation (mind you I think this was more geared towards issues on the same PC not over a network) and he mentioned manually locking the file somehow. But it looks like a bug as I would imagine the functions would fail (return false) if they encountered any issues and not just never return…

     

    Is there anyway to somehow get around this contention issue while using my “shared .INI” file so that my program does not lock up (deadlock?) – I don’t mind if it fails to write because one of the other machines are currently using the file (it will retry later) or if it waits its turn, etc…

     

     

    Any help, hints, or ideas would be greatly appreciated.

    Thanks,

Post a reply

No one has replied yet! Why not be the first?

Sign in or Join us (it's free).

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“Perfection is achieved, not when there is nothing more to add, but when there is nothing left to take away.” - Antoine de Saint Exupéry