Skip to content

Commit bf914cc

Browse files
committed
src/bindings: introduce free_initpid() helper
Signed-off-by: Alexander Mikhalitsyn <aleksandr.mikhalitsyn@canonical.com>
1 parent 8eb063e commit bf914cc

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

src/bindings.c

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,12 @@ static bool initpid_still_valid(struct pidns_store *entry)
192192
return ret == 1;
193193
}
194194

195+
static void free_initpid(struct pidns_store *entry)
196+
{
197+
close_prot_errno_disarm(entry->init_pidfd);
198+
free_disarm(entry);
199+
}
200+
195201
/* Must be called under store_lock */
196202
static void remove_initpid(struct pidns_store *entry)
197203
{
@@ -207,17 +213,15 @@ static void remove_initpid(struct pidns_store *entry)
207213
ino_hash = HASH(entry->ino);
208214
if (pidns_hash_table[ino_hash] == entry) {
209215
pidns_hash_table[ino_hash] = entry->next;
210-
close_prot_errno_disarm(entry->init_pidfd);
211-
free_disarm(entry);
216+
free_initpid(entry);
212217
return;
213218
}
214219

215220
it = pidns_hash_table[ino_hash];
216221
while (it) {
217222
if (it->next == entry) {
218223
it->next = entry->next;
219-
close_prot_errno_disarm(entry->init_pidfd);
220-
free_disarm(entry);
224+
free_initpid(entry);
221225
return;
222226
}
223227
it = it->next;
@@ -267,8 +271,7 @@ static void prune_initpid_store(void)
267271
else
268272
pidns_hash_table[i] = entry->next;
269273
entry = entry->next;
270-
close_prot_errno_disarm(cur->init_pidfd);
271-
free_disarm(cur);
274+
free_initpid(cur);
272275
} else {
273276
lxcfs_debug("Kept cache entry for pid %d in init pid cache", cur->initpid);
274277

@@ -302,8 +305,7 @@ static void clear_initpid_store(void)
302305
else
303306
pidns_hash_table[i] = entry->next;
304307
entry = entry->next;
305-
close_prot_errno_disarm(cur->init_pidfd);
306-
free_disarm(cur);
308+
free_initpid(cur);
307309
}
308310
}
309311
}

0 commit comments

Comments
 (0)