@@ -114,19 +114,34 @@ alloc_path (void)
}
void
-free_path (struct path * pp)
+uninitialize_path(struct path *pp)
{
if (!pp)
return;
+ pp->dmstate = PSTATE_UNDEF;
+ pp->uid_attribute = NULL;
+ pp->getuid = NULL;
+
if (checker_selected(&pp->checker))
checker_put(&pp->checker);
if (prio_selected(&pp->prio))
prio_put(&pp->prio);
- if (pp->fd >= 0)
+ if (pp->fd >= 0) {
close(pp->fd);
+ pp->fd = -1;
+ }
+}
+
+void
+free_path (struct path * pp)
+{
+ if (!pp)
+ return;
+
+ uninitialize_path(pp);
if (pp->udev) {
udev_device_unref(pp->udev);
@@ -416,6 +416,7 @@ struct host_group {
struct path * alloc_path (void);
struct pathgroup * alloc_pathgroup (void);
struct multipath * alloc_multipath (void);
+void uninitialize_path(struct path *pp);
void free_path (struct path *);
void free_pathvec (vector vec, enum free_path_mode free_paths);
void free_pathgroup (struct pathgroup * pgp, enum free_path_mode free_paths);
@@ -98,14 +98,7 @@ void orphan_path(struct path *pp, const char *reason)
{
condlog(3, "%s: orphan path, %s", pp->dev, reason);
pp->mpp = NULL;
- pp->dmstate = PSTATE_UNDEF;
- pp->uid_attribute = NULL;
- pp->getuid = NULL;
- prio_put(&pp->prio);
- checker_put(&pp->checker);
- if (pp->fd >= 0)
- close(pp->fd);
- pp->fd = -1;
+ uninitialize_path(pp);
}
void orphan_paths(vector pathvec, struct multipath *mpp, const char *reason)