From bb98fd8c85fa3292b95134d727864c090c29d783 Mon Sep 17 00:00:00 2001 From: Alexander Barton Date: Sun, 25 Jan 2004 16:06:34 +0000 Subject: [PATCH] The type of service (TOS) of all sockets is set to "interactive" now. --- ChangeLog | 3 ++- NEWS | 4 +++- src/ngircd/conn.c | 48 +++++++++++++++++++++++++++++++++-------------- 3 files changed, 39 insertions(+), 16 deletions(-) diff --git a/ChangeLog b/ChangeLog index 793c22ae..aa2feea0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -12,6 +12,7 @@ ngIRCd CVSHEAD + - The type of service (TOS) of all sockets is set to "interactive" now. - Added short command line option "-t" as alternative to "--configtest". - Added optional support for "IDENT" lookups on incoming connections. You have to enable this function with the ./configure switch "--with-ident". @@ -492,4 +493,4 @@ ngIRCd 0.0.1, 31.12.2001 -- -$Id: ChangeLog,v 1.221 2003/12/29 14:53:26 alex Exp $ +$Id: ChangeLog,v 1.222 2004/01/25 16:06:35 alex Exp $ diff --git a/NEWS b/NEWS index a7fa785f..b6afc1f4 100644 --- a/NEWS +++ b/NEWS @@ -12,6 +12,8 @@ ngIRCd CVSHEAD + - The type of service (TOS) of all sockets is set to "interactive" now. + - Added short command line option "-t" as alternative to "--configtest". - Added optional support for "IDENT" lookups on incoming connections. You have to enable this function with the ./configure switch "--with-ident". The default is not to do IDENT lookups. @@ -180,4 +182,4 @@ ngIRCd 0.0.1, 31.12.2001 -- -$Id: NEWS,v 1.61 2003/12/27 13:01:12 alex Exp $ +$Id: NEWS,v 1.62 2004/01/25 16:06:34 alex Exp $ diff --git a/src/ngircd/conn.c b/src/ngircd/conn.c index 7b9dcdb3..351a2459 100644 --- a/src/ngircd/conn.c +++ b/src/ngircd/conn.c @@ -1,6 +1,6 @@ /* * ngIRCd -- The Next Generation IRC Daemon - * Copyright (c)2001-2003 by Alexander Barton (alex@barton.de) + * Copyright (c)2001-2004 by Alexander Barton (alex@barton.de) * * 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 @@ -16,7 +16,7 @@ #include "portab.h" -static char UNUSED id[] = "$Id: conn.c,v 1.129 2003/12/27 13:01:12 alex Exp $"; +static char UNUSED id[] = "$Id: conn.c,v 1.130 2004/01/25 16:06:35 alex Exp $"; #include "imp.h" #include @@ -33,18 +33,22 @@ static char UNUSED id[] = "$Id: conn.c,v 1.129 2003/12/27 13:01:12 alex Exp $"; #include #include +#ifdef HAVE_NETINET_IP_H +# include +#endif + #ifdef HAVE_ARPA_INET_H -#include +# include #else -#define PF_INET AF_INET +# define PF_INET AF_INET #endif #ifdef HAVE_STDINT_H -#include /* e.g. for Mac OS X */ +# include /* e.g. for Mac OS X */ #endif #ifdef TCPWRAP -#include /* for TCP Wrappers */ +# include /* for TCP Wrappers */ #endif #include "defines.h" @@ -64,7 +68,7 @@ static char UNUSED id[] = "$Id: conn.c,v 1.129 2003/12/27 13:01:12 alex Exp $"; #include "tool.h" #ifdef RENDEZVOUS -#include "rendezvous.h" +# include "rendezvous.h" #endif #include "exp.h" @@ -1549,24 +1553,40 @@ Init_Conn_Struct( CONN_ID Idx ) LOCAL BOOLEAN Init_Socket( INT Sock ) { - /* Socket-Optionen setzen */ + /* Initialize socket (set options) */ - INT on = 1; + INT value; -#ifdef O_NONBLOCK /* A/UX kennt das nicht? */ +#ifdef O_NONBLOCK /* unknown on A/UX */ if( fcntl( Sock, F_SETFL, O_NONBLOCK ) != 0 ) { - Log( LOG_CRIT, "Can't enable non-blocking mode: %s!", strerror( errno )); + Log( LOG_CRIT, "Can't enable non-blocking mode for socket: %s!", strerror( errno )); close( Sock ); return FALSE; } #endif - if( setsockopt( Sock, SOL_SOCKET, SO_REUSEADDR, &on, (socklen_t)sizeof( on )) != 0) + + /* Don't block this port after socket shutdown */ + value = 1; + if( setsockopt( Sock, SOL_SOCKET, SO_REUSEADDR, &value, (socklen_t)sizeof( value )) != 0 ) { - Log( LOG_ERR, "Can't set socket options: %s!", strerror( errno )); - /* dieser Fehler kann ignoriert werden. */ + Log( LOG_ERR, "Can't set socket option SO_REUSEADDR: %s!", strerror( errno )); + /* ignore this error */ } + /* Set type of service (TOS) */ +#if defined(IP_TOS) && defined(IPTOS_LOWDELAY) + value = IPTOS_LOWDELAY; +#ifdef DEBUG + Log( LOG_DEBUG, "Setting option IP_TOS on socket %d to IPTOS_LOWDELAY (%d).", Sock, value ); +#endif + if( setsockopt( Sock, SOL_IP, IP_TOS, &value, (socklen_t)sizeof( value )) != 0 ) + { + Log( LOG_ERR, "Can't set socket option IP_TOS: %s!", strerror( errno )); + /* ignore this error */ + } +#endif + return TRUE; } /* Init_Socket */ -- 2.39.2