packet.c fixed

This commit is contained in:
Valery Yatsko 2008-04-02 21:23:29 +04:00
parent e967e868c4
commit d91ce397ba

View file

@ -228,7 +228,7 @@ flood_recalc(void *unused)
* read_packet - Read a 'packet' of data from a connection and process it.
*/
void
read_packet(int fd, void *data)
read_packet(rb_fde_t * F, void *data)
{
struct Client *client_p = data;
struct LocalUser *lclient_p = client_p->localClient;
@ -239,6 +239,9 @@ read_packet(int fd, void *data)
#ifdef USE_IODEBUG_HOOKS
hook_data_int hdata;
#endif
while(1)
{
if(IsAnyDead(client_p))
return;
@ -247,16 +250,20 @@ read_packet(int fd, void *data)
* I personally think it makes the code too hairy to make sane.
* -- adrian
*/
length = client_p->localClient->F->read_impl(client_p->localClient->F, readBuf, READBUF_SIZE);
length = rb_read(client_p->localClient->F, readBuf, READBUF_SIZE);
if(length <= 0)
{
if((length == -1) && ignoreErrno(errno))
if(rb_ignore_errno(errno))
{
rb_setselect(client_p->localClient->F->fd, FDLIST_IDLECLIENT,
COMM_SELECT_READ, read_packet, client_p, 0);
rb_setselect(client_p->localClient->F,
RB_SELECT_READ, read_packet, client_p);
} else
error_exit_client(client_p, length);
return;
}
if(length == 0)
{
error_exit_client(client_p, length);
return;
}
@ -304,16 +311,12 @@ read_packet(int fd, void *data)
}
}
/* If we get here, we need to register for another COMM_SELECT_READ */
if(PARSE_AS_SERVER(client_p))
/* bail if short read */
if(length < READBUF_SIZE)
{
rb_setselect(client_p->localClient->F->fd, FDLIST_SERVER, COMM_SELECT_READ,
read_packet, client_p, 0);
rb_setselect(client_p->localClient->F, RB_SELECT_READ, read_packet, client_p);
return;
}
else
{
rb_setselect(client_p->localClient->F->fd, FDLIST_IDLECLIENT,
COMM_SELECT_READ, read_packet, client_p, 0);
}
}