orbs 191 Posted October 27, 2014 i find it hard to follow the SQL code, but that's probably because i'm not an SQL expert... anyway this UDF is a general-purpose tool (also capable of handling SQLite "lock", among many others), so i think youshould post this SQL code in one of the SQLite-related threads (or a new thread), where SQLite users can find it more easily, because the question of "locking" SQLite DB over network is repeatedly asked. Share this post Link to post Share on other sites
orbs 191 Posted November 30, 2014 i needed to know if, when a semaphore was created successfully, was an ancient semaphore needed to be cleaned-up. so i added the usage of @extended in _CFS_RequestSemaphore() so it is set to 1 if cleanup of ancient semaphore was due: Func _CFS_RequestSemaphore($sRequestedResource, $iTimeout = 300, $iClean = 900) Local $sCFS_Semaphore = _CFS_ResourseLockName($sRequestedResource) Local $iStart = TimerInit() Local $iExtended = 0 While True If _CFS_LockAge($sCFS_Semaphore, $iClean) Then ; Too old? _CFS_RemoveLock($sCFS_Semaphore) $iExtended = 1 EndIf If TimerDiff($iStart) > ($iTimeout * 1000) Then ; have we timed out? Return 0 Else If _CFS_CreateLock($sCFS_Semaphore) Then Return SetExtended($iExtended, 1) ; did we get the lock? EndIf Sleep(100) ; didn't get a lock, pause and try again WEnd EndFunc ;==>_CFS_RequestSemaphore Share this post Link to post Share on other sites
jchd 1,286 Posted June 5, 2015 Zedna,Sorry for the very late followup, but this scheme doesn't work reliably. You hit the problem of individual local cacheing of the remote DB by SQLite page cache in as many "clients" which have a live connection to it. There are other, lower-level issues with that which all make the scheme pretty risky.SQLite has no clue whether the open connection is on a local drive or remote mapped drive. Hide jchd's signature Hide all signatures This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe hereRegExp tutorial: enough to get startedPCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt) Share this post Link to post Share on other sites
willichan 216 Posted June 16, 2015 Sorry that I haven't chimed in for a while here.I am always open to improvements to the UDF. One thing to clarify though.Even though I initially wrote this for an SQLite project, it is for locking any resource, not just SQLite databases. I have also used this to keep multiple scripts that share an INI file from stomping on each other, as well as for scripts running on multiple PCs writing to a single log file. Hide willichan's signature Hide all signatures Join me in supporting Pediatric Therapy Network through Amazon Smile. My UDFs: Barcode Libraries, Automate creation of any type of project folder, File Locking with Cooperative Semaphores, Inline binary files, Continue script after reboot, WinWaitMulti, Name Aggregator Share this post Link to post Share on other sites
jchd 1,286 Posted June 16, 2015 Granted. I was only warning. Hide jchd's signature Hide all signatures This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe hereRegExp tutorial: enough to get startedPCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt) Share this post Link to post Share on other sites
willichan 216 Posted June 16, 2015 Granted. I was only warning.I was really more responding to Zedna, but like I said, I am always open to improvements. Hide willichan's signature Hide all signatures Join me in supporting Pediatric Therapy Network through Amazon Smile. My UDFs: Barcode Libraries, Automate creation of any type of project folder, File Locking with Cooperative Semaphores, Inline binary files, Continue script after reboot, WinWaitMulti, Name Aggregator Share this post Link to post Share on other sites