int readers;
/** any users writing over this connection? */
int writers;
+ /** any users using this connection at all? */
+ int users;
/** condvar to wait for usage */
condvar_t *cond;
} entry_t;
{
entry->writers++;
}
+ entry->users++;
found = entry;
break;
}
if (entry->id == id)
{
candidate = TRUE;
- if (entry->readers || entry->writers)
+ if (entry->readers || entry->writers || entry->users)
{
entry->cond->wait(entry->cond, this->mutex);
break;
{
entry->writers--;
}
+ entry->users--;
entry->cond->signal(entry->cond);
this->mutex->unlock(this->mutex);
}
.queue = array_create(sizeof(chunk_t), 0),
.cond = condvar_create(CONDVAR_TYPE_DEFAULT),
.readers = 1,
+ .users = 1,
);
this->mutex->lock(this->mutex);
{
entry_t *entry;
- entry = find_entry(sel->this, NULL, sel->id, FALSE, TRUE);
+ /* we don't modify the in- or outbound queue, so don't lock the entry in
+ * reader or writer mode */
+ entry = find_entry(sel->this, NULL, sel->id, FALSE, FALSE);
if (entry)
{
entry->stream->on_write(entry->stream, on_write, sel->this);
- put_entry(sel->this, entry, FALSE, TRUE);
+ put_entry(sel->this, entry, FALSE, FALSE);
}
return JOB_REQUEUE_NONE;
}