[Iftop-users] iftop on openbsd
Chris Lightfoot
chris at ex-parrot.com
Fri, 29 Aug 2003 17:13:02 +0100
On Fri, Aug 29, 2003 at 05:07:29PM +0100, Paul Warren wrote:
> On Fri, Aug 29, 2003 at 04:54:11PM +0100, Chris Lightfoot wrote:
> > > My guess is that it's a difference in the handling of threads (is that
> > > vague enough?), and the stuff that makes is quit is <blame-torch
> > > action="pass">stuff that Chris wrote</blame-torch>
[...]
> At a quick guess, I'd say that pcap_loop doesn't call any thread
> cancellation points, so it hangs on pthread_cancel.
Ah, that's a good point. That said, I'm surprised that
quitting works on Mac OS X if that's the problem....
Try this patch: (not absolutely certain about the second
parameter to pcap_dispatch; try 1 if -1 doesn't work)
diff -u -r1.44 iftop.c
--- iftop.c 2003/05/20 21:14:37 1.44
+++ iftop.c 2003/08/29 16:10:06
@@ -528,7 +528,9 @@
/* packet_loop:
* Worker function for packet capture thread. */
void packet_loop(void* ptr) {
- pcap_loop(pd,-1,(pcap_handler)packet_handler,NULL);
+ /* Make sure that this thread is cancellable. */
+ while (pcap_dispatch(p, -1, (pcap_handler)packet_handler, NULL) != -1)
+ pcap_testcancel();
}
(I should say that I don't recall being the one to put the
PCAP stuff in a thread. I have a horror of threads
anyway....)
--
``... you cannot make a pair of croak-voiced Daleks appear benevolent even if
you dress one of them up in an Armani suit and call the other Marmaduke.''
(Dennis Potter, on ex-BBC big cheeses John Birt and Marmaduke Hussey)