Ethereal-dev: Re: [Ethereal-dev] [CYGWIN]Build hints

Note: This archive is from the project's previous web site, ethereal.com. This list is no longer active.

From: Guy Harris <guy@xxxxxxxxxxxx>
Date: Fri, 14 Nov 2003 13:22:54 -0800

On Nov 14, 2003, at 4:31 AM, Biot Olivier wrote:

When capturing with tethereal, my CPU gets utilized at 60-100% while nothing
happens (even ^C does not help for quitting the application).

Other than a GNU ADNS problem, or a problem with something controlled by _WIN32 where Cygwin's "pretend-it's-UNIX" environment doesn't make it enough like UNIX, I don't know what that might be.

 With ethereal
I get a popup with the following message:
	"Unexpected error from select: Bad file descriptor"

_WIN32 isn't being defined (otherwise, there would be no "select()" calls).

The attached patch (which I've checked in) forces it to treat Cygwin as if it were Windows, not UNIX, when deciding whether to use "select()" in the main input loop or not.
Index: capture.c
===================================================================
RCS file: /cvsroot/ethereal/capture.c,v
retrieving revision 1.213
diff -c -r1.213 capture.c
*** capture.c	1 Nov 2003 02:30:14 -0000	1.213
--- capture.c	14 Nov 2003 21:16:25 -0000
***************
*** 106,133 ****
  #endif
  
  /*
-  * 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__) || defined(__bsdi__) || defined(__APPLE__)
- #ifndef BSD
- #define BSD
- #endif /* BSD */
- #endif /* defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__bsdi__) || defined(__APPLE__) */
- 
- /*
   * We don't want to do a "select()" on the pcap_t's file descriptor on
   * BSD (because "select()" doesn't work correctly on BPF devices on at
   * least some releases of some flavors of BSD), and we don't want to do
   * it on Windows (because "select()" is something for sockets, not for
!  * arbitrary handles).
   *
   * We *do* want to do it on other platforms, as, on other platforms (with
   * the possible exception of Ultrix and Digital UNIX), the read timeout
   * doesn't expire if no packets have arrived, so a "pcap_dispatch()" call
   * will block until packets arrive, causing the UI to hang.
   */
! #if !defined(BSD) && !defined(_WIN32)
  # define MUST_DO_SELECT
  #endif
  
--- 106,130 ----
  #endif
  
  /*
   * We don't want to do a "select()" on the pcap_t's file descriptor on
   * BSD (because "select()" doesn't work correctly on BPF devices on at
   * least some releases of some flavors of BSD), and we don't want to do
   * it on Windows (because "select()" is something for sockets, not for
!  * arbitrary handles).  (Note that "Windows" here includes Cygwin;
!  * even in its pretend-it's-UNIX environment, we're using WinPcap, not
!  * a UNIX libpcap.)
   *
   * We *do* want to do it on other platforms, as, on other platforms (with
   * the possible exception of Ultrix and Digital UNIX), the read timeout
   * doesn't expire if no packets have arrived, so a "pcap_dispatch()" call
   * will block until packets arrive, causing the UI to hang.
+  *
+  * 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__) && \
!     !defined(__bsdi__) && !defined(__APPLE__) && !defined(_WIN32) && \
!     !defined(__CYGWIN__)
  # define MUST_DO_SELECT
  #endif