Nmap Development mailing list archives
Re: Locking a mutex by name?
From: "Patrick Donnelly" <batrick.donnelly () gmail com>
Date: Fri, 14 Nov 2008 18:53:23 -0700
On Fri, Nov 14, 2008 at 6:07 PM, Ron <ron () skullsecurity net> wrote:
Patrick Donnelly wrote:On Fri, Nov 14, 2008 at 5:04 PM, Ron <ron () skullsecurity net> wrote: The problem you are experiencing is the mutex is being garbage collected during the time between you lock it and release it. The mutexes are stored internally with weak references to allow them to be collected when no longer used. The registry is holding onto that reference for you. It is normally expected you use a local reference to the mutex. I would recommend you not store the reference in the registry and instead keep it local or in the function's (that is, your script) environment.Ah, that would explain the behaviour. The issue is that multiple scripts need to use the same mutex. If there are three scripts using SMB against a single host, they need to run individually. Due to a "feature" in Windows, you can't make more than one SMB connection at the same time from the same IP. Do you think that storing them in the registry is a good bet, or do you see a better way of doing mutexes on a global level?
You really only need to worry that the thread using the mutex keeps a reference to it from the point it locks it to the point it releases it. How you decide to keep the reference is up to you. It could be as simple as: local mutex; -- ... other code function action(host, port) mutex = nmap.mutex("SMB-"..host.ip); -- do stuff... end Cheers, -- -Patrick Donnelly "One of the lessons of history is that nothing is often a good thing to do and always a clever thing to say." -Will Durant _______________________________________________ Sent through the nmap-dev mailing list http://cgi.insecure.org/mailman/listinfo/nmap-dev Archived at http://SecLists.Org
Current thread:
- Locking a mutex by name? Ron (Nov 13)
- Re: Locking a mutex by name? Patrick Donnelly (Nov 13)
- Re: Locking a mutex by name? Ron (Nov 14)
- Re: Locking a mutex by name? Patrick Donnelly (Nov 14)
- Re: Locking a mutex by name? Ron (Nov 14)
- Re: Locking a mutex by name? Patrick Donnelly (Nov 14)
- Re: Locking a mutex by name? Ron (Nov 14)
- Re: Locking a mutex by name? Patrick Donnelly (Nov 14)
- Re: Locking a mutex by name? Ron (Nov 14)
- Re: Locking a mutex by name? Kris Katterjohn (Nov 14)
- Re: Locking a mutex by name? Patrick Donnelly (Nov 14)
- Re: Locking a mutex by name? Ron (Nov 15)
- Re: Locking a mutex by name? Ron (Nov 14)
- Re: Locking a mutex by name? Patrick Donnelly (Nov 13)