v->defer_event_source = sd_event_source_disable_unref(v->defer_event_source);
}
+static void varlink_clear_current(Varlink *v) {
+ assert(v);
+
+ /* Clears the currently processed incoming message */
+ v->current = json_variant_unref(v->current);
+}
+
static void varlink_clear(Varlink *v) {
assert(v);
v->input_buffer = mfree(v->input_buffer);
v->output_buffer = mfree(v->output_buffer);
- v->current = json_variant_unref(v->current);
+ varlink_clear_current(v);
v->event = sd_event_unref(v->event);
}
log_debug_errno(r, "Reply callback returned error, ignoring: %m");
}
- v->current = json_variant_unref(v->current);
+ varlink_clear_current(v);
if (v->state == VARLINK_PROCESSING_REPLY) {
case VARLINK_PROCESSED_METHOD: /* Method call is fully processed */
case VARLINK_PROCESSING_METHOD_ONEWAY: /* ditto */
- v->current = json_variant_unref(v->current);
+ varlink_clear_current(v);
varlink_set_state(v, VARLINK_IDLE_SERVER);
break;
assert(v->n_pending == 0); /* n_pending can't be > 0 if we are in VARLINK_IDLE_CLIENT state */
- v->current = json_variant_unref(v->current);
+ varlink_clear_current(v);
r = varlink_sanitize_parameters(¶meters);
if (r < 0)
/* We just replied to a method call that was let hanging for a while (i.e. we were outside of
* the varlink_dispatch_method() stack frame), which means with this reply we are ready to
* process further messages. */
- v->current = json_variant_unref(v->current);
+ varlink_clear_current(v);
varlink_set_state(v, VARLINK_IDLE_SERVER);
} else
/* We replied to a method call from within the varlink_dispatch_method() stack frame), which
return varlink_log_errno(v, r, "Failed to enqueue json message: %m");
if (IN_SET(v->state, VARLINK_PENDING_METHOD, VARLINK_PENDING_METHOD_MORE)) {
- v->current = json_variant_unref(v->current);
+ varlink_clear_current(v);
varlink_set_state(v, VARLINK_IDLE_SERVER);
} else
varlink_set_state(v, VARLINK_PROCESSED_METHOD);