Home page logo

nmap-dev logo Nmap Development mailing list archives

Re: [Nsock] Scalable event handling
From: Henri Doreau <henri.doreau () gmail com>
Date: Wed, 7 Aug 2013 09:15:01 +0200

2013/8/7 David Fifield <david () bamsoftware com>:
On Thu, Jul 25, 2013 at 10:31:03PM +0200, Henri Doreau wrote:
2013/7/25 David Fifield <david () bamsoftware com>:
+   gh_lnode_t nodeq;
+   gh_lnode_t nodeq2; /* used for pcap events */

Can you elaborate on how nodeq and nodeq2 work? From what I understand,
nodeq2 is used for pcap-related events and nodeq is used for other kinds
of events. Why do these need to be separate? I wonder if there is a more
orthogonal way to do it. first_ev_next taking a nodeq2 parameter to
choose which list to work on is a little strange.

That's it nodeq is for everything but pcap and nodeq2 is for pcap
only. The thing is that nsock has this strange "BSD hack mode" where
pcap events are added to both "read" and "pcap_read" event lists. This
requires a second gh_lnode_t handle. Having it always (not only in
BSD_HACK_MODE) used for "pcap_read" events makes the code lighter.

The current gh_list implementation hides it a bit, but It's been there
for a while. I'm not fond of it either I have to say, but I'm planning
to change these linked lists to something else (probably a unique red
black tree, I'm still experimenting and benchmarking at the moment).
Making the BSD hack mode less intrusive will be one of my goals then.

One thing I could do in order to avoid having an extra gh_lnode_t (=
two pointers) per structure when not in BSD_HACK_MODE is to add inline
helpers or play with macros like:

  gh_lnode_t nodeq2;
#define nodeq2 nodeq

I don't want you to do any tricks to change the structures. I'm not
worried about struct sizes. Do you think the member name should be
nodeq_bsd_hack or something like that? That would be enough of a clue as
to what it's for.

I admit that nodeq and nodeq2 is cryptic. Let's say nodeq_io and
nodeq_pcap, and add a comment about how they're used. nodeq_bsd_hack
suggests that it's only used when in BSD hack mode, which is

Please go ahead and merge this patch when you are ready.

David Fifield
Sure. I first need to figure out why you get test failures. I suspect
it has more to do with the test than with nsock but I want to make
sure and fix it. Let me know if you see something new.


Sent through the dev mailing list
Archived at http://seclists.org/nmap-dev/

  By Date           By Thread  

Current thread:
[ Nmap | Sec Tools | Mailing Lists | Site News | About/Contact | Advertising | Privacy ]