* Condvar to wait for callback termination
*/
condvar_t *condvar;
+
+ /**
+ * TRUE when the service is terminated
+ */
+ bool terminated;
};
/**
private_stream_service_t *this = data->this;
this->mutex->lock(this->mutex);
- if (this->active-- == this->cncrncy)
+ if (this->active-- == this->cncrncy && !this->terminated)
{
/* leaving concurrency limit, restart accept()ing. */
lib->watcher->add(lib->watcher, this->fd,
.this = this,
);
- if (data->fd != -1)
+ if (data->fd != -1 && !this->terminated)
{
this->mutex->lock(this->mutex);
if (++this->active == this->cncrncy)
METHOD(stream_service_t, destroy, void,
private_stream_service_t *this)
{
+ this->mutex->lock(this->mutex);
+ this->terminated = TRUE;
+ this->mutex->unlock(this->mutex);
on_accept(this, NULL, NULL, this->prio, this->cncrncy);
close(this->fd);
this->mutex->destroy(this->mutex);