Unreal3.2/src/s_bsd.c dizindeki modulde, aşağıdaki satırdan düzenlemeleri yapabilirsin.
Kod: Kodu kopyalamak için üzerine çift tıklayın!
/*
** read_packet
**
** Read a 'packet' of data from a connection
and process it. Read in 8k
** chunks to give a better performance
rating (for server connections).
** Do some tricky stuff for client connections to make sure they don't do
** any flooding >:-)
-avalon
*/
#ifndef USE_POLL
static int read_packet(aClient *cptr, fd_set
*rfd)
{
int dolen = 0, length = 0, done;
time_t now =
TStime();
if (FD_ISSET(cptr->fd, rfd)
&&
!(IsPerson(cptr) &&
DBufLength(&cptr->recvQ) >
6090))
{
SET_ERRNO(0);
#ifdef
USE_SSL
if (cptr->flags &
FLAGS_SSL)
length = ircd_SSL_read(cptr,
readbuf,
sizeof(readbuf));
else
#endif
length =
recv(cptr->fd, readbuf, sizeof(readbuf), 0);
cptr->lasttime
= now;
if (cptr->lasttime >
cptr->since)
cptr->since =
cptr->lasttime;
cptr->flags &= ~(FLAGS_PINGSENT |
FLAGS_NONL);
/*
* If not ready, fake it so it
isnt closed
*/
if (length < 0 && ERRNO
== P_EWOULDBLOCK)
return 1;
if
(length <= 0)
return
length;
}
/*
** For server connections,
we process as many as we can without
** worrying about the
time of day or anything :)
*/
if (IsServer(cptr) ||
IsConnecting(cptr) || IsHandshake(cptr))
{
if (length
> 0)
if ((done = dopacket(cptr, readbuf,
length)))
return
done;
}
else
{
/*
** Before we even think of parsing what we just read,
stick
** it on the end of the receive queue and do
it when its
** turn comes around.
*/
if (!dbuf_put(&cptr->recvQ, readbuf,
length))
return exit_client(cptr, cptr, cptr, "dbuf_put
fail");
if (IsPerson(cptr) && DBufLength(&cptr->recvQ)
>
get_recvq(cptr))
{
sendto_snomask(SNO_FLOOD,
"*** Flood -- %s!%s@%s (%d) exceeds %d
recvQ",
cptr->name[0] ? cptr->name
: "*",
cptr->user ?
cptr->user->username : "*",
cptr->user ? cptr->user->realhost :
"*",
DBufLength(&cptr->recvQ),
get_recvq(cptr));
return exit_client(cptr, cptr, cptr,
"Excess Flood");
}
while (DBufLength(&cptr->recvQ) &&
!NoNewLine(cptr) &&
((cptr->status
< STAT_UNKNOWN) || (cptr->since - now <
10)))
{
/*
** If it has become registered as a Service or
Server
** then skip the per-message parsing
below.
*/
if
(IsServer(cptr))
{
dolen =
dbuf_get(&cptr->recvQ,
readbuf,
sizeof(readbuf));
if (dolen <=
0)
break;
if ((done
= dopacket(cptr, readbuf, dolen)))
return
done;
break;
}
dolen
= dbuf_getmsg(&cptr->recvQ,
readbuf,
sizeof(readbuf));
/*
**
Devious looking...whats it do ? well..if a
client
** sends a *long* message without any
CR or LF, then
** dbuf_getmsg fails and we
pull it out using this
** loop which just gets
the next 512 bytes and then
** deletes the
rest of the buffer contents.
**
-avalon
*/
while (dolen <=
0)
{
if (dolen <
0)
return exit_client(cptr, cptr,
cptr,
"dbuf_getmsg
fail");
if (DBufLength(&cptr->recvQ) <
510)
{
cptr->flags
|=
FLAGS_NONL;
break;
}
dolen
= dbuf_get(&cptr->recvQ, readbuf, 511);
if
(dolen > 0 &&
DBufLength(&cptr->recvQ))
DBufClear(&cptr->recvQ);
}
if (dolen > 0
&&
(dopacket(cptr, readbuf,
dolen) == FLUSH_BUFFER))
return
FLUSH_BUFFER;
}
}
return 1;
}
#else
/*
handle taking care of the client's recvq here */
static int
do_client_queue(aClient *cptr)
{
int dolen = 0, done;
while (DBufLength(&cptr->recvQ) && !NoNewLine(cptr)
&&
((cptr->status < STAT_UNKNOWN) ||
(cptr->since - now < 10)))
{
/* If it's become
registered as a server, just parse the whole block */
if
(IsServer(cptr))
{
dolen
=
dbuf_get(&cptr->recvQ, readbuf,
sizeof(readbuf));
if (dolen <=
0)
break;
if ((done =
dopacket(cptr, readbuf, dolen)))
return
done;
break;
}
#if defined(MAXBUFFERS)
dolen
=
dbuf_getmsg(&cptr->recvQ,
readbuf,
rcvbufmax *
sizeof(char));
#else
dolen = dbuf_getmsg(&cptr->recvQ,
readbuf, sizeof(readbuf));
#endif
if (dolen <= 0)
{
if
(dolen < 0)
return exit_client(cptr, cptr,
cptr,
"dbuf_getmsg fail");
if (DBufLength(&cptr->recvQ) <
510)
{
cptr->flags |=
FLAGS_NONL;
break;
}
/*
The buffer is full (more than 512 bytes) and it has no \n
* Some user is trying to trick us. Kill their recvq.
*/
DBufClear(&cptr->recvQ);
break;
}
else
if (dopacket(cptr, readbuf, dolen) == FLUSH_BUFFER)
return
FLUSH_BUFFER;
}
return 1;
}
#define MAX_CLIENT_RECVQ 8192 /* 4 dbufs */
static int read_packet(aClient *cptr)
{
int length = 0,
done;
/* If data is ready, and the user is either not a person or
*
is a person and has a recvq of less than MAX_CLIENT_RECVQ,
* read from
this client
*/
if (!(IsPerson(cptr) &&
DBufLength(&cptr->recvQ) >
MAX_CLIENT_RECVQ))
{
errno = 0;
#ifdef USE_SSL
if (cptr->flags &
FLAGS_SSL)
length = ircd_SSL_read((SSL
*)cptr->ssl, readbuf,
sizeof(readbuf));
else
#endif
length =
recv(cptr->fd, readbuf, sizeof(readbuf), 0);
cptr->lasttime
= now;
if (cptr->lasttime >
cptr->since)
cptr->since =
cptr->lasttime;
cptr->flags &= ~(FLAGS_PINGSENT |
FLAGS_NONL);
/*
* If not ready, fake it so it
isnt closed
*/
if (length < 0
&& ((ERRNO == P_EWOULDBLOCK) || ERRNO ==
P_EAGAIN)))
return 1;
if (length <=
0)
return length;
}
/*
* For server connections, we process as many as we can
without
* worrying about the time of day or anything :)
*/
if (IsServer(cptr) || IsConnecting(cptr) ||
IsHandshake(cptr))
{
if (length >
0)
if ((done = dopacket(cptr, readbuf,
length)))
return
done;
}
else
{
/*
*
Before we even think of parsing what we just read, stick
* it on
the end of the receive queue and do it when its turn
* comes
around. */
if (!dbuf_put(&cptr->recvQ, readbuf,
length))
return exit_client(cptr, cptr, cptr, "dbuf_put
fail");
if (IsPerson(cptr) &&
#ifdef
NO_OPER_FLOOD
!IsAnOper(cptr)
&&
#endif
DBufLength(&cptr->recvQ) >
get_recvq(cptr))
{
sendto_snomask(SNO_FLOOD,
"Flood -- %s!%s@%s (%d) Exceeds %d
RecvQ",
cptr->name[0] ? cptr->name
: "*",
cptr->user ?
cptr->user->username : "*",
cptr->user ? cptr->user->realhost :
"*",
DBufLength(&cptr->recvQ),
get_recvq(cptr));
return exit_client(cptr, cptr, cptr,
"Excess Flood");
}
return
do_client_queue(cptr);
}
return 1;
}
#endif