Hello,
I'm using the attached patch (against latest svn) successfully on
FreeBSD 4.9-RELEASE to prevent UI hangs during captures. In other words,
without the patch, which enables select() on the BPF pcap fd, the main
window and capture info dialog will not respond to input unless traffic
matching the capture filter continues filling the buffer.
NOTE: I plan on testing the patch on one of my 4.10-RELEASE machines
tomorrow. The attached patch includes using select on 4.10 too.
Does anyone have any concerns with using the patch or ideas on how to
test it more thoroughly than what I've done; which is start and stop a
few small captures?
I searched the FreeBSD mailing lists many months ago and found only a
few emails from a person or two who ran into this same problem. So I'm
not the only one. :o) Unfortunately, I never found a reply or suggestion
or patch on how to fix it... so this is what I came up with.
BTW, the FreeBSD ports maintainer patched the 0.10.{5|6} version by
ripping "__FreeBSD__" out of the entire #if conditional. My attached
patch only includes select() for 4.9 and 4.10. I haven't tested other
versions. I suppose he thinks it's safe for all FreeBSDs for some reason.
-Nathan
Index: capture_loop.c
===================================================================
--- capture_loop.c (revision 12506)
+++ capture_loop.c (working copy)
@@ -118,10 +118,22 @@
* XXX - the various BSDs appear to define BSD in <sys/param.h>; we don't
* want to include it if it's not present on this platform, however.
*/
-#if !defined(__FreeBSD__) && !defined(__NetBSD__) && !defined(__OpenBSD__) && \
+
+/* Use select for these exceptions. */
+
+/* FreeBSD >= 4.9, but not >= 5.0 */
+#if (defined(__FreeBSD__) && (__FreeBSD__ >= 2))
+# include <osreldate.h>
+# if ((__FreeBSD_version >= 490000) && (__FreeBSD_version < 500000))
+# define MUST_DO_SELECT
+# endif
+
+/* Do not use select for all others below. */
+
+#elif !defined(__FreeBSD__) && !defined(__NetBSD__) && !defined(__OpenBSD__) && \
!defined(__bsdi__) && !defined(__APPLE__) && !defined(_WIN32) && \
!defined(__CYGWIN__)
-# define MUST_DO_SELECT
+# define MUST_DO_SELECT
#endif