Nmap Development mailing list archives

Re: [NSE] More library global problems


From: Patrick Donnelly <batrick () batbytes com>
Date: Mon, 8 Feb 2010 12:09:00 -0500

Hi Patrik,

On Mon, Feb 8, 2010 at 3:41 AM, Patrik Karlsson <patrik () cqure net> wrote:
Thanks! I've attached a proposed patch that uses a fully weak local table to store the request id's. I would 
appreciate your comments before committing.

You need to use the actual thread as the index not the string. So:

req_id_tbl[coroutine.running()] = 1;

etc.

Also, strings are not considered a collectible object from a
weak-table perspective. See [1] (particularly, the last two
paragraphs) for a discussion on this.

You should also note in the documentation somewhere that the library
has static per-thread data. (Usually data like this is kept in some
sort of state (a table you construct) by the caller that is passed to
your library's functions (see the html.lua pipeline functions for an
example). Your approach is probably ok so long as you document it.)

[1] http://www.lua.org/pil/17.html

-- 
- Patrick Donnelly
_______________________________________________
Sent through the nmap-dev mailing list
http://cgi.insecure.org/mailman/listinfo/nmap-dev
Archived at http://seclists.org/nmap-dev/


Current thread: