Fixes to make this compile, also add it into configure if epoll/kqueue/ports are not used.

git-svn-id: http://svn.inspircd.org/repository/branches/1_1_stable@10247 e03df62e-2008-0410-955e-edbf42e46eb7
This commit is contained in:
w00t 2008-08-24 21:53:26 +00:00
parent 11f949c487
commit 462a06dbe5
2 changed files with 48 additions and 17 deletions

35
configure vendored
View File

@ -187,6 +187,7 @@ if (defined $opt_nokqueue)
{
$config{USE_KQUEUE} = "n";
}
$config{USE_POLL} = "y"; # poll enabled
$config{USE_EPOLL} = "y"; # epoll enabled
if (defined $opt_epoll)
{
@ -673,22 +674,37 @@ should NOT be used. You should probably specify a newer compiler.\n\n";
dir_check("is the IRCd binary to be placed", "BINARY_DIR");
dir_check("are the IRCd libraries to be placed", "LIBRARY_DIR");
$chose_hiperf = 1;
if ($has_kqueue) {
yesno(USE_KQUEUE,"You are running a BSD operating system, and kqueue\nwas detected. Would you like to enable kqueue support?\nThis is likely to increase performance.\nIf you are unsure, answer yes.\n\nEnable kqueue?");
print "\n";
if ($config{USE_KQUEUE} ne "y") {
$chose_hiperf = 0;
}
}
if ($has_epoll) {
yesno(USE_EPOLL,"You are running a Linux 2.6+ operating system, and epoll\nwas detected. Would you like to enable epoll support?\nThis is likely to increase performance.\nIf you are unsure, answer yes.\n\nEnable epoll?");
print "\n";
if ($config{USE_EPOLL} ne "y") {
$chose_hiperf = 0;
}
}
if ($has_ports) {
yesno(USE_PORTS,"You are running Solaris 10.\nWould you like to enable I/O completion ports support?\nThis is likely to increase performance.\nIf you are unsure, answer yes.\n\nEnable support for I/O completion ports?");
print "\n";
if ($config{USE_PORTS} ne "y") {
$chose_hiperf = 0;
}
}
$chose_hiperf = (($config{USE_EPOLL} eq "y") || ($config{USE_KQUEUE} eq "y") || ($config{USE_PORTS} eq "y"));
if (!$chose_hiperf) {
print "No high-performance socket engines are available, or you chose\n";
print "not to enable one. Defaulting to select() engine.\n\n";
yesno(USE_POLL, "Would you like to use poll?\n This is likely to increase performance.\nIf you are unsure, answer yes.\n\nEnable poll?\n");
if ($config{USE_POLL} ne "y")
{
print "No high-performance socket engines are available, or you chose\n";
print "not to enable one. Defaulting to select() engine.\n\n";
}
}
yesno(IPV6,"Would you like to build InspIRCd with IPv6 support?");
@ -1147,6 +1163,12 @@ print FILEHANDLE "#define MAXBUF " . ($config{MAXBUF}+2) . "\n";
$se = "socketengine_ports";
$use_hiperf = 1;
}
if ($config{USE_POLL} eq "y")
{
print FILEHANDLE "#define USE_POLL\n";
$se = "socketengine_poll";
$use_hiperf = 1;
}
# user didn't choose either epoll or select for their OS.
# default them to USE_SELECT (ewwy puke puke)
if (!$use_hiperf) {
@ -1542,6 +1564,10 @@ if (($has_kqueue) && ($config{USE_KQUEUE} eq "y")) {
elsif (($has_epoll) && ($config{USE_EPOLL} eq "y")) {
$se = "socketengine_epoll";
}
elsif ($config{USE_POLL} eq "y")
{
$se = "socketengine_poll";
}
elsif (($has_ports) && ($config{USE_PORTS} eq "y")) {
$se = "socketengine_ports";
}
@ -1679,6 +1705,9 @@ sub write_dynamic_makefile {
elsif (($has_epoll) && ($config{USE_EPOLL} eq "y")) {
$se = "socketengine_epoll";
}
elsif ($config{USE_POLL} eq "y") {
$se = "socketengine_poll";
}
elsif (($has_ports) && ($config{USE_PORTS} eq "y")) {
$se = "socketengine_ports";
}

View File

@ -13,13 +13,13 @@
#include "inspircd.h"
#include "exitcodes.h"
#include "socketengine_epoll.h"
#include "socketengine_poll.h"
PollEngine::PollEngine(InspIRCd* Instance) : SocketEngine(Instance)
{
// Poll requires no special setup (which is nice).
CurrentSetSize = 0;
memset(&events, 0, sizeof(struct pollfds * MAX_DESCRIPTORS));
// memset(&events, 0, sizeof(struct pollfds) * MAX_DESCRIPTORS);
}
PollEngine::~PollEngine()
@ -90,43 +90,45 @@ int PollEngine::DispatchEvents()
{
int i = poll(events, MAX_DESCRIPTORS, 1000);
int fd = 0;
socklen_t codesize = sizeof(int);
int errcode;
if (i > 0)
{
for (fd = 0; fd < i; fd++)
{
if (events[fd].event & POLLHUP)
if (events[fd].events & POLLHUP)
{
if (ref[events[j].data.fd])
ref[events[j].data.fd]->HandleEvent(EVENT_ERROR, 0);
if (ref[fd])
ref[fd]->HandleEvent(EVENT_ERROR, 0);
continue;
}
if (events[fd].event & POLLERR)
if (events[fd].events & POLLERR)
{
// Get error number
if (getsockopt(events[j].data.fd, SOL_SOCKET, SO_ERROR, &errcode, &codesize) < 0)
if (getsockopt(fd, SOL_SOCKET, SO_ERROR, &errcode, &codesize) < 0)
errcode = errno;
if (ref[events[j].data.fd])
ref[events[j].data.fd]->HandleEvent(EVENT_ERROR, errcode);
if (ref[fd])
ref[fd]->HandleEvent(EVENT_ERROR, errcode);
continue;
}
if (events[fd].event & POLLOUT)
if (events[fd].events & POLLOUT)
{
// Switch to wanting read again
// event handlers have to request to write again if they need it
events[fd].event = POLLRDNORM;
events[fd].events = POLLRDNORM;
if (ref[fd])
ref[fd]->HandleEvent(EVENT_WRITE);
}
if (events[fd].event & POLLIN)
if (events[fd].events & POLLIN)
{
if (ref[events[j].data.fd])
ref[events[j].data.fd]->HandleEvent(EVENT_READ);
if (ref[fd])
ref[fd]->HandleEvent(EVENT_READ);
}
}
}