userbd: modernize process_connection() fd possession logic
This commit is contained in:
@@ -425,16 +425,16 @@ static int vl_method_get_memberships(Varlink *link, JsonVariant *parameters, Var
|
||||
JSON_BUILD_PAIR("groupName", JSON_BUILD_STRING(last_group_name))));
|
||||
}
|
||||
|
||||
static int process_connection(VarlinkServer *server, int fd) {
|
||||
static int process_connection(VarlinkServer *server, int _fd) {
|
||||
_cleanup_close_ int fd = TAKE_FD(_fd); /* always take possesion */
|
||||
_cleanup_(varlink_close_unrefp) Varlink *vl = NULL;
|
||||
int r;
|
||||
|
||||
r = varlink_server_add_connection(server, fd, &vl);
|
||||
if (r < 0) {
|
||||
fd = safe_close(fd);
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to add connection: %m");
|
||||
}
|
||||
|
||||
TAKE_FD(fd);
|
||||
vl = varlink_ref(vl);
|
||||
|
||||
for (;;) {
|
||||
|
||||
Reference in New Issue
Block a user