Skip to content

Commit

Permalink
discover/sysinfo: Add system_info_reinit()
Browse files Browse the repository at this point in the history
Currently over reinit events the system info is not affected. However
network and block device information can change over reinit, so clear
this information.

Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
  • Loading branch information
sammj committed Jul 11, 2017
1 parent f03763a commit 417265c
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
2 changes: 2 additions & 0 deletions discover/device-handler.c
Original file line number Diff line number Diff line change
Expand Up @@ -1407,6 +1407,8 @@ static void device_handler_reinit_sources(struct device_handler *handler)
return;
}

system_info_reinit();

udev_reinit(handler->udev);

network_shutdown(handler->network);
Expand Down
18 changes: 18 additions & 0 deletions discover/sysinfo.c
Original file line number Diff line number Diff line change
Expand Up @@ -139,3 +139,21 @@ void system_info_init(struct discover_server *s)
sysinfo = talloc_zero(server, struct system_info);
platform_get_sysinfo(sysinfo);
}

/* Only reset device information. Platform information is static */
void system_info_reinit(void)
{
unsigned int i;

for (i = 0; i < sysinfo->n_blockdevs; i++)
talloc_free(sysinfo->blockdevs[i]);
talloc_free(sysinfo->blockdevs);
sysinfo->blockdevs = NULL;
sysinfo->n_blockdevs = 0;

for (i = 0; i < sysinfo->n_interfaces; i++)
talloc_free(sysinfo->interfaces[i]);
talloc_free(sysinfo->interfaces);
sysinfo->interfaces = NULL;
sysinfo->n_interfaces = 0;
}
1 change: 1 addition & 0 deletions discover/sysinfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ void system_info_register_blockdev(const char *name, const char *uuid,
const char *mountpoint);

void system_info_init(struct discover_server *server);
void system_info_reinit(void);

#endif /* SYSINFO_H */

0 comments on commit 417265c

Please sign in to comment.