[svn] - remove broken ports stuff and devpoll stuff.

This commit is contained in:
nenolod 2007-04-03 02:50:56 -07:00
parent 4536ee2587
commit 5e12fb1089
7 changed files with 15 additions and 807 deletions

View File

@ -1,3 +1,13 @@
nenolod 2007/04/03 09:49:11 UTC (20070403-3362)
Log:
- regenerate files
Changes: Modified:
+1 -25 trunk/configure (File Modified)
+0 -3 trunk/include/setup.h.in (File Modified)
nenolod 2007/04/03 09:37:03 UTC (20070403-3360)
Log:
- remove x86-optimized hash code.

311
configure vendored
View File

@ -2,7 +2,7 @@
# Guess values for system-dependent variables and create Makefiles.
# Generated by GNU Autoconf 2.61 for charybdis 2.2.0.
#
# $Id: configure 3362 2007-04-03 09:49:11Z nenolod $
# $Id: configure 3364 2007-04-03 09:50:56Z nenolod $
#
# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001,
# 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
@ -1296,7 +1296,6 @@ Optional Features:
--enable-poll Force poll() usage.
--enable-select Force select() usage.
--enable-kqueue Force kqueue() usage.
--enable-devpoll Force usage of /dev/poll.
--enable-epoll Force sys_epoll usage (Linux only).
--enable-assert Enable assert(). Choose between soft(warnings) and
hard(aborts the daemon)
@ -1406,7 +1405,7 @@ Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001,
This configure script is free software; the Free Software Foundation
gives unlimited permission to copy, distribute and modify it.
$Id: configure 3362 2007-04-03 09:49:11Z nenolod $
$Id: configure 3364 2007-04-03 09:50:56Z nenolod $
_ACEOF
exit
fi
@ -9789,158 +9788,6 @@ if test "${enable_kqueue+set}" = set; then
fi
# Check whether --enable-devpoll was given.
if test "${enable_devpoll+set}" = set; then
enableval=$enable_devpoll; if test $enableval = yes; then
SELECT_TYPE_EXPLICIT="devpoll"
for ac_header in sys/devpoll.h devpoll.h
do
as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
{ echo "$as_me:$LINENO: checking for $ac_header" >&5
echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; }
if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
echo $ECHO_N "(cached) $ECHO_C" >&6
fi
ac_res=`eval echo '${'$as_ac_Header'}'`
{ echo "$as_me:$LINENO: result: $ac_res" >&5
echo "${ECHO_T}$ac_res" >&6; }
else
# Is the header compilable?
{ echo "$as_me:$LINENO: checking $ac_header usability" >&5
echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6; }
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
$ac_includes_default
#include <$ac_header>
_ACEOF
rm -f conftest.$ac_objext
if { (ac_try="$ac_compile"
case "(($ac_try" in
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
*) ac_try_echo=$ac_try;;
esac
eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
(eval "$ac_compile") 2>conftest.er1
ac_status=$?
grep -v '^ *+' conftest.er1 >conftest.err
rm -f conftest.er1
cat conftest.err >&5
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } && {
test -z "$ac_c_werror_flag" ||
test ! -s conftest.err
} && test -s conftest.$ac_objext; then
ac_header_compiler=yes
else
echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
ac_header_compiler=no
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
{ echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
echo "${ECHO_T}$ac_header_compiler" >&6; }
# Is the header present?
{ echo "$as_me:$LINENO: checking $ac_header presence" >&5
echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6; }
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
#include <$ac_header>
_ACEOF
if { (ac_try="$ac_cpp conftest.$ac_ext"
case "(($ac_try" in
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
*) ac_try_echo=$ac_try;;
esac
eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
(eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1
ac_status=$?
grep -v '^ *+' conftest.er1 >conftest.err
rm -f conftest.er1
cat conftest.err >&5
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } >/dev/null && {
test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
test ! -s conftest.err
}; then
ac_header_preproc=yes
else
echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
ac_header_preproc=no
fi
rm -f conftest.err conftest.$ac_ext
{ echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
echo "${ECHO_T}$ac_header_preproc" >&6; }
# So? What about this header?
case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in
yes:no: )
{ echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5
echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;}
{ echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5
echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;}
ac_header_preproc=yes
;;
no:yes:* )
{ echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5
echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;}
{ echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5
echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;}
{ echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5
echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;}
{ echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5
echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;}
{ echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5
echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;}
{ echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5
echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;}
;;
esac
{ echo "$as_me:$LINENO: checking for $ac_header" >&5
echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; }
if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
echo $ECHO_N "(cached) $ECHO_C" >&6
else
eval "$as_ac_Header=\$ac_header_preproc"
fi
ac_res=`eval echo '${'$as_ac_Header'}'`
{ echo "$as_me:$LINENO: result: $ac_res" >&5
echo "${ECHO_T}$ac_res" >&6; }
fi
if test `eval echo '${'$as_ac_Header'}'` = yes; then
cat >>confdefs.h <<_ACEOF
#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
_ACEOF
fi
done
else
use_devpoll=no;
fi
fi
# Check whether --enable-epoll was given.
if test "${enable_epoll+set}" = set; then
enableval=$enable_epoll; if test $enableval = yes; then
@ -10501,160 +10348,6 @@ done
fi
fi
if test ! "x$use_devpoll" = "xno"; then
{ echo "$as_me:$LINENO: checking for /dev/poll" >&5
echo $ECHO_N "checking for /dev/poll... $ECHO_C" >&6; }
if test -c "/dev/poll"; then
{ echo "$as_me:$LINENO: result: yes" >&5
echo "${ECHO_T}yes" >&6; }
for ac_header in devpoll.h sys/devpoll.h
do
as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
{ echo "$as_me:$LINENO: checking for $ac_header" >&5
echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; }
if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
echo $ECHO_N "(cached) $ECHO_C" >&6
fi
ac_res=`eval echo '${'$as_ac_Header'}'`
{ echo "$as_me:$LINENO: result: $ac_res" >&5
echo "${ECHO_T}$ac_res" >&6; }
else
# Is the header compilable?
{ echo "$as_me:$LINENO: checking $ac_header usability" >&5
echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6; }
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
$ac_includes_default
#include <$ac_header>
_ACEOF
rm -f conftest.$ac_objext
if { (ac_try="$ac_compile"
case "(($ac_try" in
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
*) ac_try_echo=$ac_try;;
esac
eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
(eval "$ac_compile") 2>conftest.er1
ac_status=$?
grep -v '^ *+' conftest.er1 >conftest.err
rm -f conftest.er1
cat conftest.err >&5
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } && {
test -z "$ac_c_werror_flag" ||
test ! -s conftest.err
} && test -s conftest.$ac_objext; then
ac_header_compiler=yes
else
echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
ac_header_compiler=no
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
{ echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
echo "${ECHO_T}$ac_header_compiler" >&6; }
# Is the header present?
{ echo "$as_me:$LINENO: checking $ac_header presence" >&5
echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6; }
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
#include <$ac_header>
_ACEOF
if { (ac_try="$ac_cpp conftest.$ac_ext"
case "(($ac_try" in
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
*) ac_try_echo=$ac_try;;
esac
eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
(eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1
ac_status=$?
grep -v '^ *+' conftest.er1 >conftest.err
rm -f conftest.er1
cat conftest.err >&5
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } >/dev/null && {
test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
test ! -s conftest.err
}; then
ac_header_preproc=yes
else
echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
ac_header_preproc=no
fi
rm -f conftest.err conftest.$ac_ext
{ echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
echo "${ECHO_T}$ac_header_preproc" >&6; }
# So? What about this header?
case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in
yes:no: )
{ echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5
echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;}
{ echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5
echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;}
ac_header_preproc=yes
;;
no:yes:* )
{ echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5
echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;}
{ echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5
echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;}
{ echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5
echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;}
{ echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5
echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;}
{ echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5
echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;}
{ echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5
echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;}
;;
esac
{ echo "$as_me:$LINENO: checking for $ac_header" >&5
echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; }
if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
echo $ECHO_N "(cached) $ECHO_C" >&6
else
eval "$as_ac_Header=\$ac_header_preproc"
fi
ac_res=`eval echo '${'$as_ac_Header'}'`
{ echo "$as_me:$LINENO: result: $ac_res" >&5
echo "${ECHO_T}$ac_res" >&6; }
fi
if test `eval echo '${'$as_ac_Header'}'` = yes; then
cat >>confdefs.h <<_ACEOF
#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
_ACEOF
fi
done
SELECT_TYPE="devpoll"
else
{ echo "$as_me:$LINENO: result: no" >&5
echo "${ECHO_T}no" >&6; }
fi
fi
if test ! "x$use_kqueue" = "xno"; then
for ac_func in kevent

View File

@ -1,4 +1,4 @@
dnl $Id: configure.ac 3360 2007-04-03 09:37:03Z nenolod $
dnl $Id: configure.ac 3364 2007-04-03 09:50:56Z nenolod $
dnl Process this file with autoconf to produce a configure script.
dnl TODO: clean up all the OpenSSL and shared module checking stuff;
@ -8,7 +8,7 @@ dnl said functions need to be just about as complex as they already are.
AC_PREREQ(2.57)
dnl Sneaky way to get an Id tag into the configure script
AC_COPYRIGHT([$Id: configure.ac 3360 2007-04-03 09:37:03Z nenolod $])
AC_COPYRIGHT([$Id: configure.ac 3364 2007-04-03 09:50:56Z nenolod $])
AC_INIT([charybdis],[2.2.0])
@ -655,16 +655,6 @@ AC_ARG_ENABLE(kqueue, AC_HELP_STRING([--enable-kqueue],[Force kqueue() usage.]),
fi
],)
AC_ARG_ENABLE(devpoll,AC_HELP_STRING([--enable-devpoll],[Force usage of /dev/poll.]),
[ if test $enableval = yes; then
SELECT_TYPE_EXPLICIT="devpoll"
dnl These need to be defined or not defined
AC_CHECK_HEADERS([sys/devpoll.h devpoll.h])
else
use_devpoll=no;
fi
],)
AC_ARG_ENABLE(epoll, AC_HELP_STRING([--enable-epoll],[Force sys_epoll usage (Linux only).]),
[ if test $enableval = yes; then
SELECT_TYPE_EXPLICIT="epoll"
@ -765,17 +755,6 @@ if test ! "x$use_poll" = "xno"; then
fi
fi
if test ! "x$use_devpoll" = "xno"; then
AC_MSG_CHECKING(for /dev/poll)
if test -c "/dev/poll"; then
AC_MSG_RESULT(yes)
AC_CHECK_HEADERS([devpoll.h sys/devpoll.h])
SELECT_TYPE="devpoll"
else
AC_MSG_RESULT(no)
fi
fi
if test ! "x$use_kqueue" = "xno"; then
AC_CHECK_FUNCS(kevent, [havekqueue=yes], [havekqueue=no])
if test "x$havekqueue" = "xyes" ; then

View File

@ -1 +1 @@
#define SERNO "20070403-3360"
#define SERNO "20070403-3362"

View File

@ -39,9 +39,6 @@
/* Define to 1 if you have the <crypt.h> header file. */
#undef HAVE_CRYPT_H
/* Define to 1 if you have the <devpoll.h> header file. */
#undef HAVE_DEVPOLL_H
/* Define to 1 if you have the <dlfcn.h> header file. */
#undef HAVE_DLFCN_H
@ -129,9 +126,6 @@
/* Define to 1 if you have the `strndup' function. */
#undef HAVE_STRNDUP
/* Define to 1 if you have the <sys/devpoll.h> header file. */
#undef HAVE_SYS_DEVPOLL_H
/* Define to 1 if you have the <sys/epoll.h> header file. */
#undef HAVE_SYS_EPOLL_H

View File

@ -1,294 +0,0 @@
/*
* ircd-ratbox: A slightly useful ircd.
* s_bsd_devpoll.c: /dev/poll compatible network routines.
*
* Copyright (C) 1990 Jarkko Oikarinen and University of Oulu, Co Center
* Copyright (C) 1996-2002 Hybrid Development Team
* Copyright (C) 2001 Adrian Chadd <adrian@creative.net.au>
* Copyright (C) 2002-2005 ircd-ratbox development team
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* USA
*
* $Id: devpoll.c 3354 2007-04-03 09:21:31Z nenolod $
*/
#include "config.h"
#include "stdinc.h"
#include <sys/devpoll.h>
#include "libcharybdis.h"
#define POLL_LENGTH 1024
static void devpoll_update_events(int, short, PF *);
static int dpfd;
static short fdmask[POLL_LENGTH];
static void devpoll_update_events(int, short, PF *);
static void devpoll_write_update(int, int);
/* #define NOTYET 1 */
/* XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX */
/* Private functions */
/*
* Write an update to the devpoll filter.
* See, we end up having to do a seperate (?) remove before we do an
* add of a new polltype, so we have to have this function seperate from
* the others.
*/
static void
devpoll_write_update(int fd, int events)
{
struct pollfd pollfds[1]; /* Just to be careful */
int retval;
/* Build the pollfd entry */
pollfds[0].revents = 0;
pollfds[0].fd = fd;
pollfds[0].events = events;
/* Write the thing to our poll fd */
retval = write(dpfd, &pollfds[0], sizeof(struct pollfd));
if(retval != sizeof(struct pollfd))
libcharybdis_log("devpoll_write_update: dpfd write failed %d: %s", errno, strerror(errno));
/* Done! */
}
void
devpoll_update_events(int fd, short filter, PF * handler)
{
int update_required = 0;
int cur_mask = fdmask[fd];
PF *cur_handler;
fdmask[fd] = 0;
fde_t *F = comm_locate_fd(fd);
switch (filter)
{
case COMM_SELECT_READ:
cur_handler = F->read_handler;
if(handler)
fdmask[fd] |= POLLRDNORM;
else
fdmask[fd] &= ~POLLRDNORM;
if(F->write_handler)
fdmask[fd] |= POLLWRNORM;
break;
case COMM_SELECT_WRITE:
cur_handler = F->write_handler;
if(handler)
fdmask[fd] |= POLLWRNORM;
else
fdmask[fd] &= ~POLLWRNORM;
if(F->read_handler)
fdmask[fd] |= POLLRDNORM;
break;
default:
#ifdef NOTYET
libcharybdis_log("devpoll_update_events called with unknown filter: %hd", filter);
#endif
return;
break;
}
if(cur_handler == NULL && handler != NULL)
update_required++;
else if(cur_handler != NULL && handler == NULL)
update_required++;
if(cur_mask != fdmask[fd])
update_required++;
if(update_required)
{
/*
* Ok, we can call devpoll_write_update() here now to re-build the
* fd struct. If we end up with nothing on this fd, it won't write
* anything.
*/
if(fdmask[fd])
{
devpoll_write_update(fd, POLLREMOVE);
devpoll_write_update(fd, fdmask[fd]);
}
else
devpoll_write_update(fd, POLLREMOVE);
}
}
/* XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX */
/* Public functions */
/*
* init_netio
*
* This is a needed exported function which will be called to initialise
* the network loop code.
*/
void
init_netio(void)
{
memset(&fdmask, 0, sizeof(fdmask));
dpfd = open("/dev/poll", O_RDWR);
if(dpfd < 0)
{
fprintf(stderr,
"init_netio: Couldn't open /dev/poll - %d: %s\n",
errno, strerror(errno));
exit(115); /* Whee! */
}
}
/*
* comm_setselect
*
* This is a needed exported function which will be called to register
* and deregister interest in a pending IO state for a given FD.
*/
void
comm_setselect(int fd, fdlist_t list, unsigned int type, PF * handler,
void *client_data, time_t timeout)
{
fde_t *F = comm_locate_fd(fd);
s_assert(fd >= 0);
s_assert(F->flags.open);
/* Update the list, even though we're not using it .. */
F->list = list;
if(type & COMM_SELECT_READ)
{
devpoll_update_events(fd, COMM_SELECT_READ, handler);
F->read_handler = handler;
F->read_data = client_data;
}
if(type & COMM_SELECT_WRITE)
{
devpoll_update_events(fd, COMM_SELECT_WRITE, handler);
F->write_handler = handler;
F->write_data = client_data;
}
if(timeout)
F->timeout = CurrentTime + (timeout / 1000);
}
/*
* Check all connections for new connections and input data that is to be
* processed. Also check for connections with data queued and whether we can
* write it out.
*/
/*
* comm_select
*
* Called to do the new-style IO, courtesy of squid (like most of this
* new IO code). This routine handles the stuff we've hidden in
* comm_setselect and fd_table[] and calls callbacks for IO ready
* events.
*/
int
comm_select(unsigned long delay)
{
int num, i;
struct pollfd pollfds[POLL_LENGTH];
struct dvpoll dopoll;
do
{
for (;;)
{
dopoll.dp_timeout = delay;
dopoll.dp_nfds = POLL_LENGTH;
dopoll.dp_fds = &pollfds[0];
num = ioctl(dpfd, DP_POLL, &dopoll);
if(num >= 0)
break;
if(ignoreErrno(errno))
break;
set_time();
return COMM_ERROR;
}
set_time();
if(num == 0)
continue;
for (i = 0; i < num; i++)
{
int fd = dopoll.dp_fds[i].fd;
PF *hdl = NULL;
fde_t *F = comm_locate_fd(fd);
if((dopoll.dp_fds[i].
revents & (POLLRDNORM | POLLIN | POLLHUP |
POLLERR))
&& (dopoll.dp_fds[i].events & (POLLRDNORM | POLLIN)))
{
if((hdl = F->read_handler) != NULL)
{
F->read_handler = NULL;
hdl(fd, F->read_data);
/*
* this call used to be with a NULL pointer, BUT
* in the devpoll case we only want to update the
* poll set *if* the handler changes state (active ->
* NULL or vice versa.)
*/
devpoll_update_events(fd,
COMM_SELECT_READ, F->read_handler);
}
else
libcharybdis_log("comm_select: Unhandled read event: fdmask: %x",
fdmask[fd]);
}
if(F->flags.open == 0)
continue; /* Read handler closed us..go on to do something more useful */
if((dopoll.dp_fds[i].
revents & (POLLWRNORM | POLLOUT | POLLHUP |
POLLERR))
&& (dopoll.dp_fds[i].events & (POLLWRNORM | POLLOUT)))
{
if((hdl = F->write_handler) != NULL)
{
F->write_handler = NULL;
hdl(fd, F->write_data);
/* See above similar code in the read case */
devpoll_update_events(fd,
COMM_SELECT_WRITE, F->write_handler);
}
else
libcharybdis_log("comm_select: Unhandled write event: fdmask: %x",
fdmask[fd]);
}
if(dopoll.dp_fds[i].revents & POLLNVAL)
{
libcharybdis_log("revents was Invalid for %d", fd);
}
}
return COMM_OK;
}
while (0);
/* XXX Get here, we broke! */
return 0;
}

View File

@ -1,174 +0,0 @@
/*
* charybdis: A slightly useful ircd.
* ports.c: Solaris ports compatible network routines.
*
* Copyright (C) 1990 Jarkko Oikarinen and University of Oulu, Co Center
* Copyright (C) 1996-2002 Hybrid Development Team
* Copyright (C) 2001 Adrian Chadd <adrian@creative.net.au>
* Copyright (C) 2002-2004 ircd-ratbox development team
* Copyright (C) 2005 Edward Brocklesby.
* Copyright (C) 2005 William Pitcock and Jilles Tjoelker
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* USA
*
* $Id$
*/
#include "stdinc.h"
#include <port.h>
#include <time.h>
#include "libcharybdis.h"
#define PE_LENGTH 128
static void pe_update_events(fde_t *, short, PF *);
static int pe;
static struct timespec zero_timespec;
static port_event_t *pelst; /* port buffer */
static int pemax; /* max structs to buffer */
int
ircd_setup_fd(int fd)
{
return 0;
}
void
pe_update_events(fde_t * F, short filter, PF * handler)
{
PF *cur_handler = NULL;
if (filter == POLLRDNORM)
cur_handler = F->read_handler;
else if (filter == POLLWRNORM)
cur_handler = F->write_handler;
if (!cur_handler && handler)
port_associate(pe, PORT_SOURCE_FD, F->fd, filter, F);
else if (cur_handler && !handler)
port_dissociate(pe, PORT_SOURCE_FD, F->fd);
}
/* XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX */
/* Public functions */
/*
* init_netio
*
* This is a needed exported function which will be called to initialise
* the network loop code.
*/
void
init_netio(void)
{
if((pe = port_create()) < 0) {
libcharybdis_log("init_netio: Couldn't open port fd!\n");
exit(115); /* Whee! */
}
pemax = getdtablesize();
pelst = MyMalloc(sizeof(port_event_t) * pemax);
zero_timespec.tv_sec = 0;
zero_timespec.tv_nsec = 0;
}
/*
* ircd_setselect
*
* This is a needed exported function which will be called to register
* and deregister interest in a pending IO state for a given FD.
*/
void
ircd_setselect(int fd, fdlist_t list, unsigned int type, PF * handler,
void *client_data)
{
fde_t *F = comm_locate_fd(fd);
s_assert(fd >= 0);
s_assert(F->flags.open);
/* Update the list, even though we're not using it .. */
F->list = list;
if(type & IRCD_SELECT_READ) {
pe_update_events(F, POLLRDNORM, handler);
F->read_handler = handler;
F->read_data = client_data;
}
if(type & IRCD_SELECT_WRITE) {
pe_update_events(F, POLLWRNORM, handler);
F->write_handler = handler;
F->write_data = client_data;
}
}
/*
* ircd_select
*
* Called to do the new-style IO, courtesy of squid (like most of this
* new IO code). This routine handles the stuff we've hidden in
* ircd_setselect and fd_table[] and calls callbacks for IO ready
* events.
*/
int
ircd_select(unsigned long delay)
{
int i, fd;
uint nget = 1;
struct timespec poll_time;
struct timer_data *tdata;
poll_time.tv_sec = delay / 1000;
poll_time.tv_nsec = (delay % 1000) * 1000000;
i = port_getn(pe, pelst, pemax, &nget, &poll_time);
ircd_set_time();
if (i == -1)
return COMM_ERROR;
for (i = 0; i < nget; i++) {
switch(pelst[i].portev_source) {
case PORT_SOURCE_FD:
fd = pelst[i].portev_object;
PF *hdl = NULL;
fde_t *F = comm_locate_fd(fd);
if ((pelst[i].portev_events & POLLRDNORM) && (hdl = F->read_handler)) {
F->read_handler = NULL;
hdl(fd, F->read_data);
}
if ((pelst[i].portev_events & POLLWRNORM) && (hdl = F->write_handler)) {
F->write_handler = NULL;
hdl(fd, F->write_data);
}
break;
case PORT_SOURCE_TIMER:
tdata = pelst[i].portev_user;
tdata->td_cb(tdata->td_udata);
if (!tdata->td_repeat)
free(tdata);
break;
}
}
return COMM_OK;
}