Allow for resizing of MAXBUF above/below 512 via non-interactive configure. (Some crazy mofo on the forums asked for this, good luck its your funeral :p)

THIS IS UNSUPPORTED BY US IF YOU CHANGE IT, WE WON'T EVEN TELL YOU HOW :)


git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@7022 e03df62e-2008-0410-955e-edbf42e46eb7
This commit is contained in:
brain 2007-05-14 16:31:49 +00:00
parent 730d2a2c2a
commit cbb888a470
4 changed files with 40 additions and 33 deletions

6
configure vendored
View File

@ -47,6 +47,7 @@ GetOptions (
'with-ident-length=i' => \$opt_ident,
'with-quit-length=i' => \$opt_quit,
'with-topic-length=i' => \$opt_topic,
'with-maxbuf=i' => \$opt_maxbuf,
'with-kick-length=i' => \$opt_kick,
'with-gecos-length=i' => \$opt_gecos,
'with-away-length=i' => \$opt_away,
@ -95,6 +96,7 @@ my $non_interactive = (
(defined $opt_nokqueue) ||
(defined $opt_noepoll) ||
(defined $opt_noports) ||
(defined $opt_maxbuf) ||
(defined $opt_use_gnutls)
);
my $interactive = !$non_interactive;
@ -244,6 +246,7 @@ $config{MAX_TOPIC} = "307"; # max topic size
$config{MAX_KICK} = "255"; # max kick message size
$config{MAX_GECOS} = "128"; # max GECOS size
$config{MAX_AWAY} = "200"; # max AWAY size
$config{MAXBUF} = "512"; # Max buffer size
if (defined $opt_ident)
{
$config{MAX_IDENT} = $opt_ident;
@ -982,8 +985,9 @@ sub writefiles {
#define OPTIMISATION $config{OPTIMITEMP}
#define LIBRARYDIR "$config{LIBRARY_DIR}"
#define SYSTEM "$incos"
#define MAXBUF 514
EOF
print FILEHANDLE "#define MAXBUF " . ($config{MAXBUF}+2) . "\n";
if ($config{OSNAME} =~ /SunOS/i) {
print FILEHANDLE "#define IS_SOLARIS\n";
}

View File

@ -257,6 +257,9 @@ InspIRCd 1.0.x, are also allowed.
--with-away-length=[n] Specify max length of away [150]
--with-max-modes=[n] Specify max modes per line which
have parameters [20]
--with-maxbuf=[n] Change the per message buffer size [512]
DO NOT ALTER THIS OPTION WITHOUT GOOD REASON
AS IT *WILL* BREAK CLIENTS!!!
--prefix=[directory] Base directory to install into (if defined,
can automatically define config, module, bin
and library dirs as subdirectories of prefix)

View File

@ -107,7 +107,7 @@ void InspIRCd::ProcessUser(userrec* cu)
}
else
{
current->WriteServ("NOTICE %s :Your previous line was too long and was not delivered (Over 512chars) Please shorten it.", current->nick);
current->WriteServ("NOTICE %s :Your previous line was too long and was not delivered (Over %d chars) Please shorten it.", current->nick, MAXBUF-2);
current->recvq = "";
}
}
@ -177,8 +177,8 @@ void InspIRCd::ProcessUser(userrec* cu)
std::string single_line = current->GetBuffer();
current->bytes_in += single_line.length();
current->cmds_in++;
if (single_line.length() > 512)
single_line.resize(512);
if (single_line.length() > MAXBUF - 2) /* MAXBUF is 514 to allow for neccessary line terminators */
single_line.resize(MAXBUF - 2); /* So to trim to 512 here, we use MAXBUF - 2 */
EventHandler* old_comp = this->SE->GetRef(currfd);

View File

@ -690,8 +690,8 @@ void userrec::AddWriteBuf(const std::string &data)
try
{
if (data.length() > 512)
sendq.append(data.substr(0,510)).append("\r\n");
if (data.length() > MAXBUF - 2) /* MAXBUF has a value of 514, to account for line terminators */
sendq.append(data.substr(0,MAXBUF - 4)).append("\r\n"); /* MAXBUF-4 = 510 */
else
sendq.append(data);
}