mirror of
https://github.com/inspircd/inspircd.git
synced 2025-03-10 02:59:01 -04:00
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:
parent
11f949c487
commit
462a06dbe5
35
configure
vendored
35
configure
vendored
@ -187,6 +187,7 @@ if (defined $opt_nokqueue)
|
|||||||
{
|
{
|
||||||
$config{USE_KQUEUE} = "n";
|
$config{USE_KQUEUE} = "n";
|
||||||
}
|
}
|
||||||
|
$config{USE_POLL} = "y"; # poll enabled
|
||||||
$config{USE_EPOLL} = "y"; # epoll enabled
|
$config{USE_EPOLL} = "y"; # epoll enabled
|
||||||
if (defined $opt_epoll)
|
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("is the IRCd binary to be placed", "BINARY_DIR");
|
||||||
dir_check("are the IRCd libraries to be placed", "LIBRARY_DIR");
|
dir_check("are the IRCd libraries to be placed", "LIBRARY_DIR");
|
||||||
|
|
||||||
|
$chose_hiperf = 1;
|
||||||
|
|
||||||
if ($has_kqueue) {
|
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?");
|
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";
|
print "\n";
|
||||||
|
if ($config{USE_KQUEUE} ne "y") {
|
||||||
|
$chose_hiperf = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if ($has_epoll) {
|
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?");
|
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";
|
print "\n";
|
||||||
|
if ($config{USE_EPOLL} ne "y") {
|
||||||
|
$chose_hiperf = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if ($has_ports) {
|
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?");
|
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";
|
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) {
|
if (!$chose_hiperf) {
|
||||||
print "No high-performance socket engines are available, or you chose\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");
|
||||||
print "not to enable one. Defaulting to select() engine.\n\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?");
|
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";
|
$se = "socketengine_ports";
|
||||||
$use_hiperf = 1;
|
$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.
|
# user didn't choose either epoll or select for their OS.
|
||||||
# default them to USE_SELECT (ewwy puke puke)
|
# default them to USE_SELECT (ewwy puke puke)
|
||||||
if (!$use_hiperf) {
|
if (!$use_hiperf) {
|
||||||
@ -1542,6 +1564,10 @@ if (($has_kqueue) && ($config{USE_KQUEUE} eq "y")) {
|
|||||||
elsif (($has_epoll) && ($config{USE_EPOLL} eq "y")) {
|
elsif (($has_epoll) && ($config{USE_EPOLL} eq "y")) {
|
||||||
$se = "socketengine_epoll";
|
$se = "socketengine_epoll";
|
||||||
}
|
}
|
||||||
|
elsif ($config{USE_POLL} eq "y")
|
||||||
|
{
|
||||||
|
$se = "socketengine_poll";
|
||||||
|
}
|
||||||
elsif (($has_ports) && ($config{USE_PORTS} eq "y")) {
|
elsif (($has_ports) && ($config{USE_PORTS} eq "y")) {
|
||||||
$se = "socketengine_ports";
|
$se = "socketengine_ports";
|
||||||
}
|
}
|
||||||
@ -1679,6 +1705,9 @@ sub write_dynamic_makefile {
|
|||||||
elsif (($has_epoll) && ($config{USE_EPOLL} eq "y")) {
|
elsif (($has_epoll) && ($config{USE_EPOLL} eq "y")) {
|
||||||
$se = "socketengine_epoll";
|
$se = "socketengine_epoll";
|
||||||
}
|
}
|
||||||
|
elsif ($config{USE_POLL} eq "y") {
|
||||||
|
$se = "socketengine_poll";
|
||||||
|
}
|
||||||
elsif (($has_ports) && ($config{USE_PORTS} eq "y")) {
|
elsif (($has_ports) && ($config{USE_PORTS} eq "y")) {
|
||||||
$se = "socketengine_ports";
|
$se = "socketengine_ports";
|
||||||
}
|
}
|
||||||
|
@ -13,13 +13,13 @@
|
|||||||
|
|
||||||
#include "inspircd.h"
|
#include "inspircd.h"
|
||||||
#include "exitcodes.h"
|
#include "exitcodes.h"
|
||||||
#include "socketengine_epoll.h"
|
#include "socketengine_poll.h"
|
||||||
|
|
||||||
PollEngine::PollEngine(InspIRCd* Instance) : SocketEngine(Instance)
|
PollEngine::PollEngine(InspIRCd* Instance) : SocketEngine(Instance)
|
||||||
{
|
{
|
||||||
// Poll requires no special setup (which is nice).
|
// Poll requires no special setup (which is nice).
|
||||||
CurrentSetSize = 0;
|
CurrentSetSize = 0;
|
||||||
memset(&events, 0, sizeof(struct pollfds * MAX_DESCRIPTORS));
|
// memset(&events, 0, sizeof(struct pollfds) * MAX_DESCRIPTORS);
|
||||||
}
|
}
|
||||||
|
|
||||||
PollEngine::~PollEngine()
|
PollEngine::~PollEngine()
|
||||||
@ -90,43 +90,45 @@ int PollEngine::DispatchEvents()
|
|||||||
{
|
{
|
||||||
int i = poll(events, MAX_DESCRIPTORS, 1000);
|
int i = poll(events, MAX_DESCRIPTORS, 1000);
|
||||||
int fd = 0;
|
int fd = 0;
|
||||||
|
socklen_t codesize = sizeof(int);
|
||||||
|
int errcode;
|
||||||
|
|
||||||
if (i > 0)
|
if (i > 0)
|
||||||
{
|
{
|
||||||
for (fd = 0; fd < i; fd++)
|
for (fd = 0; fd < i; fd++)
|
||||||
{
|
{
|
||||||
if (events[fd].event & POLLHUP)
|
if (events[fd].events & POLLHUP)
|
||||||
{
|
{
|
||||||
if (ref[events[j].data.fd])
|
if (ref[fd])
|
||||||
ref[events[j].data.fd]->HandleEvent(EVENT_ERROR, 0);
|
ref[fd]->HandleEvent(EVENT_ERROR, 0);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (events[fd].event & POLLERR)
|
if (events[fd].events & POLLERR)
|
||||||
{
|
{
|
||||||
// Get error number
|
// 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;
|
errcode = errno;
|
||||||
if (ref[events[j].data.fd])
|
if (ref[fd])
|
||||||
ref[events[j].data.fd]->HandleEvent(EVENT_ERROR, errcode);
|
ref[fd]->HandleEvent(EVENT_ERROR, errcode);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (events[fd].event & POLLOUT)
|
if (events[fd].events & POLLOUT)
|
||||||
{
|
{
|
||||||
// Switch to wanting read again
|
// Switch to wanting read again
|
||||||
// event handlers have to request to write again if they need it
|
// event handlers have to request to write again if they need it
|
||||||
events[fd].event = POLLRDNORM;
|
events[fd].events = POLLRDNORM;
|
||||||
|
|
||||||
|
|
||||||
if (ref[fd])
|
if (ref[fd])
|
||||||
ref[fd]->HandleEvent(EVENT_WRITE);
|
ref[fd]->HandleEvent(EVENT_WRITE);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (events[fd].event & POLLIN)
|
if (events[fd].events & POLLIN)
|
||||||
{
|
{
|
||||||
if (ref[events[j].data.fd])
|
if (ref[fd])
|
||||||
ref[events[j].data.fd]->HandleEvent(EVENT_READ);
|
ref[fd]->HandleEvent(EVENT_READ);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user