Commit 294ddf1f authored by Per Cederqvist's avatar Per Cederqvist
Browse files

(parse_unparsed): Return true if anything was sent back to the client.

	Don't call isc_flush().
(read_from_connection): Call isc_flush() once if parse_unparsed()
	returned true at least once.
parent 1151eae0
/*
* $Id: connections.c,v 0.99 2003/07/13 11:56:27 ceder Exp $
* $Id: connections.c,v 0.100 2003/07/13 22:19:46 ceder Exp $
* Copyright (C) 1991-2002 Lysator Academic Computer Association.
*
* This file is part of the LysKOM server.
......@@ -415,9 +415,10 @@ reply(Connection *client,
/*
* Try to parse enough data from client->unparsed to call a function.
* If more data is needed set client->more_to_parse to FALSE.
* If more data is needed set client->more_to_parse to FALSE. Returns
* TRUE if anything was (or might have been) written to the client.
*/
static void
static Bool
parse_unparsed(Connection *client)
{
Success status;
......@@ -433,30 +434,32 @@ parse_unparsed(Connection *client)
client->penalty += param.penalty_per_call;
free_parsed(client);
end_of_atomic();
break;
return TRUE;
case KOM_PROTOCOL_ERR:
s_clear(&client->string0);
free_parsed(client);
isc_puts("%% LysKOM protocol error.\n", client->isc_session);
isc_flush(client->isc_session);
BUG(("%%%% Protocol error.\n"));
client->penalty += param.max_penalty;
s_clear(&client->unparsed);
client->first_to_parse = 0;
client->more_to_parse = FALSE;
end_of_atomic();
break;
return TRUE;
case KOM_MSG_INCOMPLETE:
client->more_to_parse = FALSE;
break;
return FALSE;
case KOM_LOGOUT:
add_to_kill_list(client);
client->more_to_parse = FALSE;
break;
return TRUE;
default:
restart_kom("Bad longjmp return value.\n");
}
/*NOTREACHED*/
}
......@@ -793,6 +796,7 @@ static void
read_from_connection(Connection *conn)
{
Bool would_block = FALSE;
Bool need_flush = FALSE;
adjust_penalty(conn);
......@@ -800,7 +804,7 @@ read_from_connection(Connection *conn)
{
while (conn->more_to_parse
&& !go_and_die && conn->penalty < param.max_penalty)
parse_unparsed(conn);
need_flush |= parse_unparsed(conn);
if (go_and_die || conn->penalty >= param.max_penalty)
break;
......@@ -835,6 +839,9 @@ read_from_connection(Connection *conn)
}
}
if (need_flush)
isc_flush(conn->isc_session);
/* Delete the parsed part of 'unparsed' */
if (s_trim_left(&conn->unparsed, conn->first_to_parse) != OK)
restart_kom("parse_unparsed: s_trim_left\n");
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment