diff -ur thttpd-2.15-orig/configure thttpd-2.15/configure
--- thttpd-2.15-orig/configure	Sun Feb  6 20:31:20 2000
+++ thttpd-2.15/configure	Mon Jun  5 13:56:18 2000
@@ -1061,13 +1061,50 @@
 fi
 done
 
+ac_safe=`echo "linux/devpoll.h" | sed 'y%./+-%__p_%'`
+echo $ac_n "checking for linux/devpoll.h""... $ac_c" 1>&6
+echo "configure:1067: checking for linux/devpoll.h" >&5
+if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
+  echo $ac_n "(cached) $ac_c" 1>&6
+else
+  cat > conftest.$ac_ext <<EOF
+#line 1072 "configure"
+#include "confdefs.h"
+#include <linux/devpoll.h>
+EOF
+ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
+{ (eval echo configure:1077: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
+if test -z "$ac_err"; then
+  rm -rf conftest*
+  eval "ac_cv_header_$ac_safe=yes"
+else
+  echo "$ac_err" >&5
+  echo "configure: failed program was:" >&5
+  cat conftest.$ac_ext >&5
+  rm -rf conftest*
+  eval "ac_cv_header_$ac_safe=no"
+fi
+rm -f conftest*
+fi
+if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then
+  echo "$ac_t""yes" 1>&6
+  cat >> confdefs.h <<\EOF
+#define HAVE_LINUX_DEVPOLL_H 1
+EOF
+
+	LIBOBJS="$LIBOBJS devpoll.o"
+else
+  echo "$ac_t""no" 1>&6
+fi
+
 echo $ac_n "checking whether time.h and sys/time.h may both be included""... $ac_c" 1>&6
-echo "configure:1066: checking whether time.h and sys/time.h may both be included" >&5
+echo "configure:1103: checking whether time.h and sys/time.h may both be included" >&5
 if eval "test \"`echo '$''{'ac_cv_header_time'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 1071 "configure"
+#line 1108 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #include <sys/time.h>
@@ -1076,7 +1113,7 @@
 struct tm *tp;
 ; return 0; }
 EOF
-if { (eval echo configure:1080: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:1117: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ac_cv_header_time=yes
 else
@@ -1101,12 +1138,12 @@
 do
 ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for $ac_hdr that defines DIR""... $ac_c" 1>&6
-echo "configure:1105: checking for $ac_hdr that defines DIR" >&5
+echo "configure:1142: checking for $ac_hdr that defines DIR" >&5
 if eval "test \"`echo '$''{'ac_cv_header_dirent_$ac_safe'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 1110 "configure"
+#line 1147 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #include <$ac_hdr>
@@ -1114,7 +1151,7 @@
 DIR *dirp = 0;
 ; return 0; }
 EOF
-if { (eval echo configure:1118: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:1155: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   eval "ac_cv_header_dirent_$ac_safe=yes"
 else
@@ -1139,7 +1176,7 @@
 # Two versions of opendir et al. are in -ldir and -lx on SCO Xenix.
 if test $ac_header_dirent = dirent.h; then
 echo $ac_n "checking for opendir in -ldir""... $ac_c" 1>&6
-echo "configure:1143: checking for opendir in -ldir" >&5
+echo "configure:1180: checking for opendir in -ldir" >&5
 ac_lib_var=`echo dir'_'opendir | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -1147,7 +1184,7 @@
   ac_save_LIBS="$LIBS"
 LIBS="-ldir  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 1151 "configure"
+#line 1188 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -1158,7 +1195,7 @@
 opendir()
 ; return 0; }
 EOF
-if { (eval echo configure:1162: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:1199: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -1180,7 +1217,7 @@
 
 else
 echo $ac_n "checking for opendir in -lx""... $ac_c" 1>&6
-echo "configure:1184: checking for opendir in -lx" >&5
+echo "configure:1221: checking for opendir in -lx" >&5
 ac_lib_var=`echo x'_'opendir | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -1188,7 +1225,7 @@
   ac_save_LIBS="$LIBS"
 LIBS="-lx  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 1192 "configure"
+#line 1229 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -1199,7 +1236,7 @@
 opendir()
 ; return 0; }
 EOF
-if { (eval echo configure:1203: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:1240: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -1224,7 +1261,7 @@
 
 d="/usr/local/v6/lib"
 echo $ac_n "checking for $d""... $ac_c" 1>&6
-echo "configure:1228: checking for $d" >&5
+echo "configure:1265: checking for $d" >&5
 if test -d $d; then
 	echo "$ac_t""yes (Adding -L$d to LDFLAGS)" 1>&6
 	LDFLAGS="$LDFLAGS -L$d"
@@ -1234,12 +1271,12 @@
 
 V_NETLIBS=""
 echo $ac_n "checking for gethostbyname""... $ac_c" 1>&6
-echo "configure:1238: checking for gethostbyname" >&5
+echo "configure:1275: checking for gethostbyname" >&5
 if eval "test \"`echo '$''{'ac_cv_func_gethostbyname'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 1243 "configure"
+#line 1280 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char gethostbyname(); below.  */
@@ -1262,7 +1299,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:1266: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:1303: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_func_gethostbyname=yes"
 else
@@ -1281,7 +1318,7 @@
   echo "$ac_t""no" 1>&6
 # Some OSes (eg. Solaris) place it in libnsl:
     echo $ac_n "checking for gethostbyname in -lnsl""... $ac_c" 1>&6
-echo "configure:1285: checking for gethostbyname in -lnsl" >&5
+echo "configure:1322: checking for gethostbyname in -lnsl" >&5
 ac_lib_var=`echo nsl'_'gethostbyname'_' | sed 'y%./+- %__p__%'`
 if eval "test \"`echo '$''{'ac_cv_lbl_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -1289,7 +1326,7 @@
   ac_save_LIBS="$LIBS"
 LIBS="-lnsl  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 1293 "configure"
+#line 1330 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -1300,7 +1337,7 @@
 gethostbyname()
 ; return 0; }
 EOF
-if { (eval echo configure:1304: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:1341: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lbl_lib_$ac_lib_var=yes"
 else
@@ -1320,7 +1357,7 @@
   echo "$ac_t""no" 1>&6
 # Some strange OSes (SINIX) have it in libsocket:
 	echo $ac_n "checking for gethostbyname in -lsocket""... $ac_c" 1>&6
-echo "configure:1324: checking for gethostbyname in -lsocket" >&5
+echo "configure:1361: checking for gethostbyname in -lsocket" >&5
 ac_lib_var=`echo socket'_'gethostbyname'_' | sed 'y%./+- %__p__%'`
 if eval "test \"`echo '$''{'ac_cv_lbl_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -1328,7 +1365,7 @@
   ac_save_LIBS="$LIBS"
 LIBS="-lsocket  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 1332 "configure"
+#line 1369 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -1339,7 +1376,7 @@
 gethostbyname()
 ; return 0; }
 EOF
-if { (eval echo configure:1343: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:1380: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lbl_lib_$ac_lib_var=yes"
 else
@@ -1361,7 +1398,7 @@
 	    # AC_CHECK_LIB's API is essentially broken so the
 	    # following ugliness is necessary:
 	    echo $ac_n "checking for gethostbyname in -lsocket""... $ac_c" 1>&6
-echo "configure:1365: checking for gethostbyname in -lsocket" >&5
+echo "configure:1402: checking for gethostbyname in -lsocket" >&5
 ac_lib_var=`echo socket'_'gethostbyname'_'-lnsl | sed 'y%./+- %__p__%'`
 if eval "test \"`echo '$''{'ac_cv_lbl_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -1369,7 +1406,7 @@
   ac_save_LIBS="$LIBS"
 LIBS="-lsocket -lnsl $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 1373 "configure"
+#line 1410 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -1380,7 +1417,7 @@
 gethostbyname()
 ; return 0; }
 EOF
-if { (eval echo configure:1384: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:1421: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lbl_lib_$ac_lib_var=yes"
 else
@@ -1399,7 +1436,7 @@
 else
   echo "$ac_t""no" 1>&6
 echo $ac_n "checking for gethostbyname in -lresolv""... $ac_c" 1>&6
-echo "configure:1403: checking for gethostbyname in -lresolv" >&5
+echo "configure:1440: checking for gethostbyname in -lresolv" >&5
 ac_lib_var=`echo resolv'_'gethostbyname | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -1407,7 +1444,7 @@
   ac_save_LIBS="$LIBS"
 LIBS="-lresolv  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 1411 "configure"
+#line 1448 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -1418,7 +1455,7 @@
 gethostbyname()
 ; return 0; }
 EOF
-if { (eval echo configure:1422: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:1459: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -1447,12 +1484,12 @@
 fi
 
 echo $ac_n "checking for socket""... $ac_c" 1>&6
-echo "configure:1451: checking for socket" >&5
+echo "configure:1488: checking for socket" >&5
 if eval "test \"`echo '$''{'ac_cv_func_socket'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 1456 "configure"
+#line 1493 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char socket(); below.  */
@@ -1475,7 +1512,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:1479: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:1516: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_func_socket=yes"
 else
@@ -1493,7 +1530,7 @@
 else
   echo "$ac_t""no" 1>&6
 echo $ac_n "checking for socket in -lsocket""... $ac_c" 1>&6
-echo "configure:1497: checking for socket in -lsocket" >&5
+echo "configure:1534: checking for socket in -lsocket" >&5
 ac_lib_var=`echo socket'_'socket | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -1501,7 +1538,7 @@
   ac_save_LIBS="$LIBS"
 LIBS="-lsocket  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 1505 "configure"
+#line 1542 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -1512,7 +1549,7 @@
 socket()
 ; return 0; }
 EOF
-if { (eval echo configure:1516: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:1553: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -1531,7 +1568,7 @@
 else
   echo "$ac_t""no" 1>&6
 echo $ac_n "checking for socket in -lsocket""... $ac_c" 1>&6
-echo "configure:1535: checking for socket in -lsocket" >&5
+echo "configure:1572: checking for socket in -lsocket" >&5
 ac_lib_var=`echo socket'_'socket'_'-lnsl | sed 'y%./+- %__p__%'`
 if eval "test \"`echo '$''{'ac_cv_lbl_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -1539,7 +1576,7 @@
   ac_save_LIBS="$LIBS"
 LIBS="-lsocket -lnsl $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 1543 "configure"
+#line 1580 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -1550,7 +1587,7 @@
 socket()
 ; return 0; }
 EOF
-if { (eval echo configure:1554: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:1591: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lbl_lib_$ac_lib_var=yes"
 else
@@ -1576,7 +1613,7 @@
 
 
 echo $ac_n "checking for main in -linet6""... $ac_c" 1>&6
-echo "configure:1580: checking for main in -linet6" >&5
+echo "configure:1617: checking for main in -linet6" >&5
 ac_lib_var=`echo inet6'_'main | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -1584,14 +1621,14 @@
   ac_save_LIBS="$LIBS"
 LIBS="-linet6  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 1588 "configure"
+#line 1625 "configure"
 #include "confdefs.h"
 
 int main() {
 main()
 ; return 0; }
 EOF
-if { (eval echo configure:1595: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:1632: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -1620,12 +1657,12 @@
 
 
 echo $ac_n "checking for crypt""... $ac_c" 1>&6
-echo "configure:1624: checking for crypt" >&5
+echo "configure:1661: checking for crypt" >&5
 if eval "test \"`echo '$''{'ac_cv_func_crypt'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 1629 "configure"
+#line 1666 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char crypt(); below.  */
@@ -1648,7 +1685,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:1652: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:1689: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_func_crypt=yes"
 else
@@ -1666,7 +1703,7 @@
 else
   echo "$ac_t""no" 1>&6
 echo $ac_n "checking for crypt in -lcrypt""... $ac_c" 1>&6
-echo "configure:1670: checking for crypt in -lcrypt" >&5
+echo "configure:1707: checking for crypt in -lcrypt" >&5
 ac_lib_var=`echo crypt'_'crypt | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -1674,7 +1711,7 @@
   ac_save_LIBS="$LIBS"
 LIBS="-lcrypt  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 1678 "configure"
+#line 1715 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -1685,7 +1722,7 @@
 crypt()
 ; return 0; }
 EOF
-if { (eval echo configure:1689: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:1726: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -1715,12 +1752,12 @@
 fi
 
 echo $ac_n "checking for hstrerror""... $ac_c" 1>&6
-echo "configure:1719: checking for hstrerror" >&5
+echo "configure:1756: checking for hstrerror" >&5
 if eval "test \"`echo '$''{'ac_cv_func_hstrerror'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 1724 "configure"
+#line 1761 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char hstrerror(); below.  */
@@ -1743,7 +1780,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:1747: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:1784: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_func_hstrerror=yes"
 else
@@ -1761,7 +1798,7 @@
 else
   echo "$ac_t""no" 1>&6
 echo $ac_n "checking for hstrerror in -lresolv""... $ac_c" 1>&6
-echo "configure:1765: checking for hstrerror in -lresolv" >&5
+echo "configure:1802: checking for hstrerror in -lresolv" >&5
 ac_lib_var=`echo resolv'_'hstrerror | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -1769,7 +1806,7 @@
   ac_save_LIBS="$LIBS"
 LIBS="-lresolv  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 1773 "configure"
+#line 1810 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -1780,7 +1817,7 @@
 hstrerror()
 ; return 0; }
 EOF
-if { (eval echo configure:1784: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:1821: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -1806,12 +1843,12 @@
 for ac_func in strerror
 do
 echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:1810: checking for $ac_func" >&5
+echo "configure:1847: checking for $ac_func" >&5
 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 1815 "configure"
+#line 1852 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char $ac_func(); below.  */
@@ -1834,7 +1871,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:1838: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:1875: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_func_$ac_func=yes"
 else
@@ -1863,12 +1900,12 @@
 for ac_func in waitpid vsnprintf daemon setsid setlogin getaddrinfo getnameinfo gai_strerror
 do
 echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:1867: checking for $ac_func" >&5
+echo "configure:1904: checking for $ac_func" >&5
 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 1872 "configure"
+#line 1909 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char $ac_func(); below.  */
@@ -1891,7 +1928,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:1895: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:1932: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_func_$ac_func=yes"
 else
@@ -1919,17 +1956,17 @@
 do
 ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:1923: checking for $ac_hdr" >&5
+echo "configure:1960: checking for $ac_hdr" >&5
 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 1928 "configure"
+#line 1965 "configure"
 #include "confdefs.h"
 #include <$ac_hdr>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:1933: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:1970: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -1958,12 +1995,12 @@
 for ac_func in getpagesize
 do
 echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:1962: checking for $ac_func" >&5
+echo "configure:1999: checking for $ac_func" >&5
 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 1967 "configure"
+#line 2004 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char $ac_func(); below.  */
@@ -1986,7 +2023,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:1990: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:2027: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_func_$ac_func=yes"
 else
@@ -2011,7 +2048,7 @@
 done
 
 echo $ac_n "checking for working mmap""... $ac_c" 1>&6
-echo "configure:2015: checking for working mmap" >&5
+echo "configure:2052: checking for working mmap" >&5
 if eval "test \"`echo '$''{'ac_cv_func_mmap_fixed_mapped'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -2019,7 +2056,7 @@
   ac_cv_func_mmap_fixed_mapped=no
 else
   cat > conftest.$ac_ext <<EOF
-#line 2023 "configure"
+#line 2060 "configure"
 #include "confdefs.h"
 
 /* Thanks to Mike Haertel and Jim Avera for this test.
@@ -2159,7 +2196,7 @@
 }
 
 EOF
-if { (eval echo configure:2163: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:2200: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   ac_cv_func_mmap_fixed_mapped=yes
 else
@@ -2187,12 +2224,12 @@
 		for ac_func in poll
 do
 echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:2191: checking for $ac_func" >&5
+echo "configure:2228: checking for $ac_func" >&5
 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 2196 "configure"
+#line 2233 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char $ac_func(); below.  */
@@ -2215,7 +2252,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:2219: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:2256: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_func_$ac_func=yes"
 else
@@ -2244,12 +2281,12 @@
 	for ac_func in select poll
 do
 echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:2248: checking for $ac_func" >&5
+echo "configure:2285: checking for $ac_func" >&5
 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 2253 "configure"
+#line 2290 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char $ac_func(); below.  */
@@ -2272,7 +2309,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:2276: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:2313: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_func_$ac_func=yes"
 else
@@ -2300,12 +2337,12 @@
 esac
 
 echo $ac_n "checking if struct tm has tm_gmtoff member""... $ac_c" 1>&6
-echo "configure:2304: checking if struct tm has tm_gmtoff member" >&5
+echo "configure:2341: checking if struct tm has tm_gmtoff member" >&5
     if eval "test \"`echo '$''{'ac_cv_acme_tm_has_tm_gmtoff'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 2309 "configure"
+#line 2346 "configure"
 #include "confdefs.h"
 
 #	include <sys/types.h>
@@ -2314,7 +2351,7 @@
 u_int i = sizeof(((struct tm *)0)->tm_gmtoff)
 ; return 0; }
 EOF
-if { (eval echo configure:2318: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:2355: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ac_cv_acme_tm_has_tm_gmtoff=yes
 else
@@ -2334,12 +2371,12 @@
 
     fi
 echo $ac_n "checking if struct sockaddr_storage exists""... $ac_c" 1>&6
-echo "configure:2338: checking if struct sockaddr_storage exists" >&5
+echo "configure:2375: checking if struct sockaddr_storage exists" >&5
     if eval "test \"`echo '$''{'ac_cv_acme_sockaddr_storage'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 2343 "configure"
+#line 2380 "configure"
 #include "confdefs.h"
 
 #	include <sys/types.h>
@@ -2348,7 +2385,7 @@
 struct sockaddr_storage sas
 ; return 0; }
 EOF
-if { (eval echo configure:2352: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:2389: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ac_cv_acme_sockaddr_storage=yes
 else
@@ -2368,12 +2405,12 @@
 
     fi
 echo $ac_n "checking if struct sockaddr_in6 exists""... $ac_c" 1>&6
-echo "configure:2372: checking if struct sockaddr_in6 exists" >&5
+echo "configure:2409: checking if struct sockaddr_in6 exists" >&5
     if eval "test \"`echo '$''{'ac_cv_acme_sockaddr_in6'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 2377 "configure"
+#line 2414 "configure"
 #include "confdefs.h"
 
 #	include <sys/types.h>
@@ -2385,7 +2422,7 @@
 struct sockaddr_in6 sa6
 ; return 0; }
 EOF
-if { (eval echo configure:2389: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:2426: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ac_cv_acme_sockaddr_in6=yes
 else
@@ -2406,7 +2443,7 @@
     fi
 
 echo $ac_n "checking whether ${MAKE-make} sets \${MAKE}""... $ac_c" 1>&6
-echo "configure:2410: checking whether ${MAKE-make} sets \${MAKE}" >&5
+echo "configure:2447: checking whether ${MAKE-make} sets \${MAKE}" >&5
 set dummy ${MAKE-make}; ac_make=`echo "$2" | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_prog_make_${ac_make}_set'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -2444,7 +2481,7 @@
 # SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff"
 # ./install, which can be erroneously created by make from ./install.sh.
 echo $ac_n "checking for a BSD compatible install""... $ac_c" 1>&6
-echo "configure:2448: checking for a BSD compatible install" >&5
+echo "configure:2485: checking for a BSD compatible install" >&5
 if test -z "$INSTALL"; then
 if eval "test \"`echo '$''{'ac_cv_path_install'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
diff -ur thttpd-2.15-orig/configure.in thttpd-2.15/configure.in
--- thttpd-2.15-orig/configure.in	Sun Feb  6 20:31:16 2000
+++ thttpd-2.15/configure.in	Mon Jun  5 13:56:10 2000
@@ -65,6 +65,9 @@
 fi
 
 AC_CHECK_HEADERS(fcntl.h grp.h memory.h paths.h poll.h sys/poll.h netinet6/in6.h)
+AC_CHECK_HEADER(linux/devpoll.h, 
+	AC_DEFINE(HAVE_LINUX_DEVPOLL_H)
+	LIBOBJS="$LIBOBJS devpoll.o", )
 AC_HEADER_TIME
 AC_HEADER_DIRENT
 
diff -ur thttpd-2.15-orig/fdwatch.c thttpd-2.15/fdwatch.c
--- thttpd-2.15-orig/fdwatch.c	Tue Jan 18 23:14:31 2000
+++ thttpd-2.15/fdwatch.c	Mon Jun  5 14:06:19 2000
@@ -36,6 +36,12 @@
 #define MIN(a,b) ((a) < (b) ? (a) : (b))
 #endif
 
+#ifdef HAVE_LINUX_DEVPOLL_H
+#undef HAVE_SELECT
+#undef HAVE_SELECT_H
+#include <linux/poll.h> /* POLLREMOVE needs to be propagated */
+#include "devpoll.h"
+#else /* HAVE_LINUX_DEVPOLL_H */
 #ifdef HAVE_POLL_H
 #include <poll.h>
 #else /* HAVE_POLL */
@@ -43,6 +49,7 @@
 #include <sys/poll.h>
 #endif /* HAVE_SYS_POLL_H */
 #endif /* HAVE_POLL */
+#endif /* HAVE_LINUX_DEVPOLL_H */
 
 #include "fdwatch.h"
 
@@ -83,6 +90,7 @@
 #ifdef HAVE_POLL
 static struct pollfd* pollfds;
 static int* fd_idx;
+int* con_idx;
 static int npollfds;
 #endif /* HAVE_POLL */
 
@@ -131,9 +139,15 @@
     nselect = npoll = 0;
 
 #ifdef HAVE_POLL
+#ifdef HAVE_LINUX_DEVPOLL_H
+    pollfds = (struct pollfd *)open_devpoll(nfiles);
+#else
     pollfds = (struct pollfd*) malloc( sizeof(struct pollfd) * nfiles );
+#endif
     fd_idx = (int*) malloc( sizeof(int) * nfiles );
-    if ( pollfds == (struct pollfd*) 0 || fd_idx == (int*) 0 )
+    con_idx = (int*) malloc( sizeof(int) * nfiles );
+    if ( pollfds == (struct pollfd*) 0 || fd_idx == (int*) 0 ||
+	 con_idx == (int*) 0)
 	return -1;
 #endif /* HAVE_POLL */
 
@@ -160,10 +174,18 @@
 #endif /* HAVE_POLL */
     }
 
+void
+fdwatch_send(void)
+{
+#ifdef HAVE_LINUX_DEVPOLL_H
+	update_devpoll(pollfds, npollfds);
+	fdwatch_clear();
+#endif
+}
 
 /* Add a descriptor to the watch list.  rw is either FDW_READ or FDW_WRITE.  */
 void
-fdwatch_add_fd( int fd, int rw )
+fdwatch_add_fd( int fd, int conn, int rw )
     {
 #ifdef HAVE_SELECT_AND_POLL
     ++numfds;
@@ -187,10 +209,22 @@
 	case FDW_WRITE: pollfds[npollfds].events = POLLOUT; break;
 	}
     fd_idx[fd] = npollfds;
+    con_idx[fd] = conn;
     ++npollfds;
 #endif /* HAVE_POLL */
     }
 
+/* remove a descriptor from the watch list.  */
+void
+fdwatch_delete_fd( int fd)
+    {
+#ifdef HAVE_LINUX_DEVPOLL_H
+    pollfds[npollfds].fd = fd;
+    pollfds[npollfds].events = POLLREMOVE;
+    ++npollfds;
+#endif /* HAVE_LINUX_DEVPOLL_H */
+    }
+
 
 /* Do the watch.  Return value is the number of descriptors that are ready,
 ** or 0 if the timeout expired, or -1 on errors.  A timeout of INFTIM means
@@ -237,8 +271,27 @@
 # endif /* HAVE_SELECT */
 
 # ifdef HAVE_POLL
+#   ifdef HAVE_LINUX_DEVPOLL_H
+    int result;
+#   endif
     ++npoll;
-    return poll( pollfds, npollfds, (int) timeout_msecs );
+#   ifdef HAVE_LINUX_DEVPOLL_H
+    result = poll_devpoll(nfiles, (int) timeout_msecs);
+    if (result >= 1) {
+      int i;
+      /* rewrite the fds into connection */
+      for (i = 0; i < result; i++) {
+	/* DEBUG
+	  fprintf(stderr, "Rewrite: %d -> %d\n", mmap_fds[i],
+	  con_idx[mmap_fds[i]]);
+	*/
+	      fd_idx[mmap_pollfds[i].fd] = i;
+      }
+    }
+    return result;
+#   else
+    return poll( pollfds, npollfds, (int) timeout_msecs);
+#   endif /* HAVE_LINUX_DEVPOLL_H */
 # endif /* HAVE_POLL */
 
 #endif /* HAVE_SELECT_AND_POLL */
@@ -304,6 +357,9 @@
 # endif /* HAVE_SELECT */
 
 # ifdef HAVE_POLL
+    if (pollfds[fd_idx[fd]].fd != fd)
+	    return 0;
+
     switch ( rw )
 	{
 	case FDW_READ: return pollfds[fd_idx[fd]].revents & POLLIN;
diff -ur thttpd-2.15-orig/fdwatch.h thttpd-2.15/fdwatch.h
--- thttpd-2.15-orig/fdwatch.h	Wed Dec 22 12:00:10 1999
+++ thttpd-2.15/fdwatch.h	Sun Mar 19 20:07:15 2000
@@ -67,7 +67,10 @@
 extern void fdwatch_clear( void );
 
 /* Add a descriptor to the watch list.  rw is either FDW_READ or FDW_WRITE.  */
-extern void fdwatch_add_fd( int fd, int rw );
+extern void fdwatch_add_fd( int fd, int conn, int rw );
+
+/* Remove a descriptor from the watch list. */
+extern void fdwatch_delete_fd( int fd);
 
 /* Do the watch.  Return value is the number of descriptors that are ready,
 ** or 0 if the timeout expired, or -1 on errors.  A timeout of INFTIM means
@@ -81,4 +84,7 @@
 /* Return usage stats on the fdwatch package. */
 extern void fdwatch_stats( long* nselectP, long* npollP );
 
+extern void fdwatch_send(void);
+
+extern int *con_idx;
 #endif /* _FDWATCH_H_ */
diff -ur thttpd-2.15-orig/libhttpd.c thttpd-2.15/libhttpd.c
--- thttpd-2.15-orig/libhttpd.c	Tue Feb  8 03:48:51 2000
+++ thttpd-2.15/libhttpd.c	Sun Mar 19 20:07:15 2000
@@ -2101,7 +2101,7 @@
     if ( hc->conn_fd >= 0 )
 	{
 	(void) close( hc->conn_fd );
-	hc->conn_fd = -1;
+	/* XXX, why ? hc->conn_fd = -1; */
 	}
     }
 
diff -ur thttpd-2.15-orig/thttpd.c thttpd-2.15/thttpd.c
--- thttpd-2.15-orig/thttpd.c	Fri Mar 31 17:34:07 2000
+++ thttpd-2.15/thttpd.c	Mon Jun  5 13:37:23 2000
@@ -59,6 +59,10 @@
 #include "timers.h"
 #include "match.h"
 
+#ifdef HAVE_LINUX_DEVPOLL_H
+#include <sys/poll.h>
+#include "devpoll.h"
+#endif
 
 static char* argv0;
 static int debug;
@@ -125,7 +129,6 @@
 
 static int fdwatch_recompute;
 
-
 /* Forwards. */
 static void parse_args( int argc, char** argv );
 static void usage( void );
@@ -197,6 +200,27 @@
     }
 
 
+static void inline
+fdwatch_compute(void)
+{
+	int cnum;
+
+	fdwatch_clear();
+	if ( numconnects > 0 )
+		for ( cnum = 0; cnum < maxconnects; ++cnum )
+			switch ( connects[cnum].conn_state ) {
+			case CNST_READING:
+			case CNST_LINGERING:
+				fdwatch_add_fd( connects[cnum].hc->conn_fd, cnum, FDW_READ );
+				break;
+			case CNST_SENDING:
+				fdwatch_add_fd( connects[cnum].hc->conn_fd, cnum, FDW_WRITE );
+				break;
+			}
+	if ( hs != (httpd_server*) 0 )
+		fdwatch_add_fd( hs->listen_fd, -1, FDW_READ );
+}
+
 int
 main( int argc, char** argv )
     {
@@ -461,6 +485,9 @@
 	connects[cnum].hc = (httpd_conn*) 0;
 	}
     numconnects = 0;
+#ifdef HAVE_LINUX_DEVPOLL_H
+    fdwatch_compute();
+#endif
     fdwatch_recompute = 1;
 
     /* Main loop. */
@@ -469,21 +496,11 @@
 	{
 	if ( fdwatch_recompute )
 	    {
-	    fdwatch_clear();
-	    if ( numconnects > 0 )
-		for ( cnum = 0; cnum < maxconnects; ++cnum )
-		    switch ( connects[cnum].conn_state )
-			{
-			case CNST_READING:
-			case CNST_LINGERING:
-			fdwatch_add_fd( connects[cnum].hc->conn_fd, FDW_READ );
-			break;
-			case CNST_SENDING:
-			fdwatch_add_fd( connects[cnum].hc->conn_fd, FDW_WRITE );
-			break;
-			}
-	    if ( hs != (httpd_server*) 0 )
-		fdwatch_add_fd( hs->listen_fd, FDW_READ );
+#ifdef HAVE_LINUX_DEVPOLL_H
+		    fdwatch_send();
+#else
+		    fdwatch_compute();
+#endif
 	    fdwatch_recompute = 0;
 	    }
 
@@ -491,7 +508,7 @@
 	num_ready = fdwatch( tmr_mstimeout( &tv ) );
 	if ( num_ready < 0 )
 	    {
-	    /* if ( errno == EINTR ) */
+	    if ( errno == EINTR )
 		continue;       /* try again */
 	    syslog( LOG_ERR, "fdwatch - %m" );
 	    exit( 1 );
@@ -519,11 +536,19 @@
 	    ** we fall through.
 	    */
 	    }
-
+#ifdef HAVE_LINUX_DEVPOLL_H
+	/* Find the connections that need servicing directly. */
+	for (cnum = 0; cnum < num_ready; cnum++ )
+	    {
+	    if (con_idx[mmap_pollfds[cnum].fd] == -1)
+	      continue;
+	    c = &connects[con_idx[mmap_pollfds[cnum].fd]];
+#else
 	/* Find the connections that need servicing. */
 	for ( cnum = 0; num_ready > 0 && cnum < maxconnects; ++cnum )
 	    {
 	    c = &connects[cnum];
+#endif
 	    hc = c->hc;
 	    if ( c->conn_state == CNST_READING &&
 		 fdwatch_check_fd( hc->conn_fd, FDW_READ ) )
@@ -1154,7 +1179,6 @@
 	    return 1;
 	    }
 	c->conn_state = CNST_READING;
-	fdwatch_recompute = 1;
 	++numconnects;
 	client_data.p = c;
 	c->idle_read_timer = tmr_create(
@@ -1173,6 +1197,11 @@
 	else if ( fcntl( c->hc->conn_fd, F_SETFL, flags | O_NDELAY ) < 0 )
 	    syslog( LOG_ERR, "fcntl O_NDELAY - %m" );
 
+#ifdef HAVE_LINUX_DEVPOLL_H
+	fdwatch_add_fd( connects[cnum].hc->conn_fd, cnum, FDW_READ );
+#endif
+	fdwatch_recompute = 1;
+
 #ifdef STATS_TIME
 	++stats_connections;
 	if ( numconnects > stats_simultaneous )
@@ -1278,7 +1307,6 @@
 
     /* Cool, we have a valid connection and a file to send to it. */
     c->conn_state = CNST_SENDING;
-    fdwatch_recompute = 1;
     c->started_at = tvP->tv_sec;
     c->wouldblock_delay = 0;
     client_data.p = c;
@@ -1287,6 +1315,15 @@
     c->idle_send_timer = tmr_create(
 	tvP, idle_send_connection, client_data, IDLE_SEND_TIMELIMIT * 1000L,
 	0 );
+#ifdef HAVE_LINUX_DEVPOLL_H
+    {
+	    int cnum = ((char *)c - (char *)connects) / sizeof(*c);
+	    if (connects[cnum].conn_state != CNST_SENDING)
+		    exit(1);
+	    fdwatch_add_fd( connects[cnum].hc->conn_fd, cnum, FDW_WRITE );
+    }
+#endif
+    fdwatch_recompute = 1;
     }
 
 
@@ -1335,6 +1372,12 @@
 	*/
 	c->wouldblock_delay += MIN_WOULDBLOCK_DELAY;
 	c->conn_state = CNST_PAUSING;
+#ifdef HAVE_LINUX_DEVPOLL_H
+    {
+	    int cnum = ((char *)c - (char *)connects) / sizeof(*c);
+	    fdwatch_delete_fd( connects[cnum].hc->conn_fd );
+    }
+#endif
 	fdwatch_recompute = 1;
 	client_data.p = c;
 	c->wakeup_timer = tmr_create(
@@ -1399,6 +1442,12 @@
     if ( elapsed == 0 || c->bytes_sent / elapsed > c->limit )
 	{
 	c->conn_state = CNST_PAUSING;
+#ifdef HAVE_LINUX_DEVPOLL_H
+    {
+	    int cnum = ((char *)c - (char *)connects) / sizeof(*c);
+	    fdwatch_delete_fd( connects[cnum].hc->conn_fd );
+    }
+#endif
 	fdwatch_recompute = 1;
 	/* When should we send the next c->limit bytes
 	** to get back on schedule?  If less than a second
@@ -1518,6 +1567,12 @@
     if ( c->hc->should_linger )
 	{
 	c->conn_state = CNST_LINGERING;
+#ifdef HAVE_LINUX_DEVPOLL_H
+    {
+	    int cnum = ((char *)c - (char *)connects) / sizeof(*c);
+	    fdwatch_add_fd( connects[cnum].hc->conn_fd, cnum, FDW_READ );
+    }
+#endif
 	fdwatch_recompute = 1;
 	client_data.p = c;
 	c->linger_timer = tmr_create(
@@ -1539,6 +1594,12 @@
 	c->linger_timer = 0;
 	}
     c->conn_state = CNST_FREE;
+#ifdef HAVE_LINUX_DEVPOLL_H
+    {
+	    int cnum = ((char *)c - (char *)connects) / sizeof(*c);
+	    fdwatch_delete_fd( connects[cnum].hc->conn_fd );
+    }
+#endif
     fdwatch_recompute = 1;
     --numconnects;
     }
@@ -1589,6 +1650,14 @@
     if ( c->conn_state == CNST_PAUSING )
 	{
 	c->conn_state = CNST_SENDING;
+#ifdef HAVE_LINUX_DEVPOLL_H
+    {
+	    int cnum = ((char *)c - (char *)connects) / sizeof(*c);
+	    if (connects[cnum].conn_state != CNST_SENDING)
+		    exit(1);
+	    fdwatch_add_fd( connects[cnum].hc->conn_fd, cnum, FDW_WRITE );
+    }
+#endif
 	fdwatch_recompute = 1;
 	}
     }
--- /dev/null	Tue May  5 16:32:27 1998
+++ thttpd-2.15/devpoll.h	Sun Mar 19 20:07:15 2000
@@ -0,0 +1,19 @@
+/*
+ *  Suport for mmap'ed /dev/poll
+ *  by Niels Provos <provos@citi.umich.edu>
+ *
+ *  Copyright 2000 Niels Provos
+ */
+
+#ifndef _DEVPOLL_H
+#define _DEVPOLL_H
+
+u_char *open_devpoll(int nfiles);
+int poll_devpoll(int nfiles, int timout);
+
+struct pollfd;
+int update_devpoll(struct pollfd *pfds, int nfds);
+
+extern struct pollfd *mmap_pollfds;
+extern int *mmap_fds;
+#endif
--- /dev/null	Tue May  5 16:32:27 1998
+++ thttpd-2.15/devpoll.c	Mon Jun  5 13:41:37 2000
@@ -0,0 +1,73 @@
+/*
+ *  Suport for mmap'ed /dev/poll
+ *  by Niels Provos <provos@citi.umich.edu>
+ *
+ *  Copyright 2000 Niels Provos
+ */
+
+#include <sys/types.h>
+#include <sys/time.h>
+#include <sys/resource.h>
+#include <sys/ioctl.h>
+#include <sys/mman.h>
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <fcntl.h>
+#include <poll.h>
+
+#include <linux/devpoll.h>
+
+#include "devpoll.h"
+
+int devpoll_fd;
+struct pollfd *mmap_pollfds;
+
+u_char *
+open_devpoll(int nfiles)
+{
+	u_char *address;
+
+	devpoll_fd = open("/dev/poll", O_RDWR, 0);
+	if (devpoll_fd == -1) {
+		perror("open");
+		return NULL;
+	}
+
+	if (ioctl(devpoll_fd, DP_ALLOC, nfiles) == -1) {
+		perror("ioctl");
+		return NULL;
+	}
+
+	address = mmap(0, DP_MMAP_SIZE(nfiles),
+		       PROT_WRITE|PROT_READ,
+		       MAP_SHARED,
+		       devpoll_fd, 0);
+
+	if (address == MAP_FAILED) {
+		perror("mmap");
+		return NULL;
+	}
+	
+	mmap_pollfds = (struct pollfd *)address;
+
+	return address;
+}
+
+int
+poll_devpoll(int nfds, int timeout)
+{
+  struct dvpoll dopoll;
+
+  dopoll.dp_fds = NULL;
+  dopoll.dp_nfds = nfds;
+  dopoll.dp_timeout = timeout;
+
+  return ioctl(devpoll_fd, DP_POLL, &dopoll);
+}
+
+int
+update_devpoll(struct pollfd *pfds, int nfds)
+{
+	return write(devpoll_fd, pfds, nfds * sizeof(struct pollfd));
+}
