vici: Invoke dispatcher outside of connection log, allowing events from commands

This commit is contained in:
Martin Willi 2014-02-10 17:04:35 +01:00
parent 252025210f
commit 293431269b
1 changed files with 13 additions and 4 deletions

View File

@ -346,10 +346,6 @@ static bool do_read(private_vici_socket_t *this, entry_t *entry,
entry->in.done += len;
}
this->inbound(this->user, entry->id, entry->in.buf);
chunk_clear(&entry->in.buf);
entry->in.hdrlen = entry->in.done = 0;
return TRUE;
}
@ -359,6 +355,7 @@ static bool do_read(private_vici_socket_t *this, entry_t *entry,
CALLBACK(on_read, bool,
entry_t *entry, stream_t *stream)
{
chunk_t data = chunk_empty;
bool ret;
entry->mutex->lock(entry->mutex);
@ -367,8 +364,20 @@ CALLBACK(on_read, bool,
{
disconnect(entry->this, entry->id);
}
if (entry->in.buf.len == entry->in.done)
{
data = entry->in.buf;
entry->in.buf = chunk_empty;
entry->in.hdrlen = entry->in.done = 0;
}
entry->mutex->unlock(entry->mutex);
if (data.len)
{
entry->this->inbound(entry->this->user, entry->id, data);
chunk_clear(&data);
}
return ret;
}