mm_ctx_delete(&ctx->pool);
free(ctx);
+ session2_unhandle(s);
return ret;
}
{
if (session->closing)
return kr_error(ECANCELED);
+ if (session->ref_count >= INT_MAX)
+ return kr_error(ETOOMANYREFS);
if (kr_fails_assert(session->proto < KR_PROTO_COUNT))
return kr_error(EFAULT);
.finished_cb = cb,
.finished_cb_baton = baton
};
+ session->ref_count++;
if (had_comm_param) {
struct comm_addr_storage *addrst = &ctx->comm_addr_storage;
if (comm->src_addr) {
ret = uv_timer_init(uv_default_loop(), &s->timer);
kr_require(!ret);
s->timer.data = s;
- s->uv_count++; /* Session owns the timer */
+ s->ref_count++; /* Session owns the timer */
/* Initialize the layer's session data */
for (size_t i = 0; i < grp->num_layers; i++) {
void session2_unhandle(struct session2 *s)
{
- if (kr_fails_assert(s->uv_count > 0)) {
+ if (kr_fails_assert(s->ref_count > 0)) {
session2_free(s);
return;
}
- s->uv_count--;
- if (s->uv_count <= 0)
+ s->ref_count--;
+ if (s->ref_count <= 0)
session2_free(s);
}
struct wire_buf wire_buf;
uint32_t log_id; /**< Session ID for logging. */
- int uv_count; /**< Number of unclosed libUV handles owned by this
- * session. */
+ int ref_count; /**< Number of unclosed libUV handles owned by this
+ * session + iteration contexts referencing the session. */
/** Communication information. Typically written into by one of the
* first layers facilitating transport protocol processing.
layer_param, layer_param_count, outgoing);
s->transport.io.handle = handle;
handle->data = s;
- s->uv_count++; /* Session owns the handle */
+ s->ref_count++; /* Session owns the handle */
return s;
}