}
}
-static void socket_enter_running(Socket *s, int cfd) {
+static void socket_enter_running(Socket *s, int cfd_in) {
+ /* Note that this call takes possession of the connection fd passed. It either has to assign it
+ * somewhere or close it. */
+ _cleanup_close_ int cfd = cfd_in;
+
_cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
int r;
- /* Note that this call takes possession of the connection fd passed. It either has to assign it somewhere or
- * close it. */
-
assert(s);
/* We don't take connections anymore if we are supposed to shut down anyway */
if (cfd >= 0)
goto refuse;
- else
- flush_ports(s);
+ flush_ports(s);
return;
}
if (s->max_connections_per_source > 0) {
r = socket_acquire_peer(s, cfd, &p);
if (ERRNO_IS_DISCONNECT(r))
- goto notconn;
+ return;
if (r < 0) /* We didn't have enough resources to acquire peer information, let's fail. */
goto fail;
if (r > 0 && p->n_ref > s->max_connections_per_source) {
r = socket_load_service_unit(s, cfd, &service);
if (ERRNO_IS_DISCONNECT(r))
- goto notconn;
+ return;
if (r < 0)
goto fail;
r = service_set_socket_fd(SERVICE(service), cfd, s, s->selinux_context_from_net);
if (ERRNO_IS_DISCONNECT(r))
- goto notconn;
+ return;
if (r < 0)
goto fail;
unit_add_to_dbus_queue(UNIT(s));
}
+ TAKE_FD(cfd);
return;
refuse:
s->n_refused++;
-notconn:
- safe_close(cfd);
return;
fail:
bus_error_message(&error, r));
socket_enter_stop_pre(s, SOCKET_FAILURE_RESOURCES);
- safe_close(cfd);
}
static void socket_run_next(Socket *s) {