exported / pypcap

Automatically exported from code.google.com/p/pypcap
Other
0 stars 0 forks source link

timeout_ms less than 1 second is not supported #37

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Set timeout_ms to less than 1 second
2. Run a capture on an interface with no traffic
3. Record the timings of the returned calls

This is pypcap 1.1 from svn (revision 102).

I traced the bug to the following line in pcap_ex.c:
#else
    static u_char *__pkt;
    static struct pcap_pkthdr __hdr;
    struct timeval tv = { 1, 0 };
    fd_set rfds;
    int fd, n;

The timeval struct in the select call is set to 1 second timeout, regardless of 
the timeout_ms value passed in. I attached a patch that changes the struct to:
struct timeval tv = { 0, 1000 };
i.e. a timeout of 1 ms. Sub ms timeout probably doesn't make sense anyway.

I think that's the right way to resolve that, unless I missed something.

Original issue reported on code.google.com by timur.al...@gmail.com on 2 Mar 2012 at 9:52

Attachments: