
On Tue, Nov 01, 2011 at 14:14:54 +0100, Michal Privoznik wrote:
If daemon is using SASL it reads client data into a cache. This cache is big (usually 65KB) and can thus contain 2 or more messages. However, on socket event we can dispatch only one message. So if we read two messages at once, the second will not be dispatched as the socket event goes away with filling the cache. Moreover, when dispatching the cache we need to remember to take care of client max requests limit. --- src/rpc/virnetserverclient.c | 34 +++++++++++++++++++++++++++++++++- 1 files changed, 33 insertions(+), 1 deletions(-)
diff --git a/src/rpc/virnetserverclient.c b/src/rpc/virnetserverclient.c index 1256f0f..69af746 100644 --- a/src/rpc/virnetserverclient.c +++ b/src/rpc/virnetserverclient.c ... @@ -204,6 +220,19 @@ static void virNetServerClientUpdateEvent(virNetServerClientPtr client) mode = virNetServerClientCalculateHandleMode(client);
virNetSocketUpdateIOCallback(client->sock, mode); +#ifdef HAVE_SASL + if (client->nrequests < client->nrequests_max && + client->rx && + virNetSocketHasCachedData(client->sock)) { + if (client->sasl_timer) + virEventUpdateTimeout(client->sasl_timer, 0); + else + client->sasl_timer = virEventAddTimeout(0, + virNetServerClientDispatchReadTimerFunc, + client, + NULL); + } +#endif
Is it all really SASL-only? I think we should remove all the ifdefs (and rename sasl_timer to something like cached_timer) to enable the code everytime virNetSocketHasCachedData returns true. The thing that SASL is currently the only layer that caches data (which may not even be true, I haven't checked), it may change in the future, e.g., when adding libssh2 transport. Jirka