summaryrefslogtreecommitdiff
path: root/src/udev
diff options
context:
space:
mode:
authorTom Gundersen <teg@jklm.no>2013-10-29 15:15:53 +0100
committerTom Gundersen <teg@jklm.no>2013-10-29 16:12:11 +0100
commit97f2d76d4f4dfab8b0629c09926a05a1e5621125 (patch)
tree3b6042e8487f4b02bc7dc74233dd9f65b5bd1801 /src/udev
parentdabfa9d1efd0d1a7e0507d69f9789bc6404ff786 (diff)
path_check_timestamp: only keep the most recent timestamp
There is no point in keeping one timestamp for each directory, as we only ever care about the most recent one.
Diffstat (limited to 'src/udev')
-rw-r--r--src/udev/net/link-config.c15
-rw-r--r--src/udev/udev-rules.c8
2 files changed, 6 insertions, 17 deletions
diff --git a/src/udev/net/link-config.c b/src/udev/net/link-config.c
index 0b5916be4c..598f93e384 100644
--- a/src/udev/net/link-config.c
+++ b/src/udev/net/link-config.c
@@ -46,7 +46,7 @@ struct link_config_ctx {
sd_rtnl *rtnl;
char **link_dirs;
- usec_t *link_dirs_ts_usec;
+ usec_t link_dirs_ts_usec;
};
int link_config_ctx_new(link_config_ctx **ret) {
@@ -89,12 +89,6 @@ int link_config_ctx_new(link_config_ctx **ret) {
return -ENOMEM;
}
- ctx->link_dirs_ts_usec = calloc(strv_length(ctx->link_dirs), sizeof(usec_t));
- if(!ctx->link_dirs_ts_usec) {
- link_config_ctx_free(ctx);
- return -ENOMEM;
- }
-
*ret = ctx;
return 0;
}
@@ -126,7 +120,6 @@ void link_config_ctx_free(link_config_ctx *ctx) {
sd_rtnl_unref(ctx->rtnl);
strv_free(ctx->link_dirs);
- free(ctx->link_dirs_ts_usec);
link_configs_free(ctx);
free(ctx);
@@ -183,8 +176,8 @@ int link_config_load(link_config_ctx *ctx) {
link_configs_free(ctx);
- /* update timestamps */
- paths_check_timestamp(ctx->link_dirs, ctx->link_dirs_ts_usec, true);
+ /* update timestamp */
+ paths_check_timestamp(ctx->link_dirs, &ctx->link_dirs_ts_usec, true);
r = conf_files_list_strv(&files, ".link", NULL, (const char **)ctx->link_dirs);
if (r < 0) {
@@ -202,7 +195,7 @@ int link_config_load(link_config_ctx *ctx) {
}
bool link_config_should_reload(link_config_ctx *ctx) {
- return paths_check_timestamp(ctx->link_dirs, ctx->link_dirs_ts_usec, false);
+ return paths_check_timestamp(ctx->link_dirs, &ctx->link_dirs_ts_usec, false);
}
static bool match_config(link_config *match, struct udev_device *device) {
diff --git a/src/udev/udev-rules.c b/src/udev/udev-rules.c
index 58da79b876..4437d80529 100644
--- a/src/udev/udev-rules.c
+++ b/src/udev/udev-rules.c
@@ -49,7 +49,7 @@ struct uid_gid {
struct udev_rules {
struct udev *udev;
char **dirs;
- usec_t *dirs_ts_usec;
+ usec_t dirs_ts_usec;
int resolve_names;
/* every key in the rules file becomes a token */
@@ -1653,9 +1653,6 @@ struct udev_rules *udev_rules_new(struct udev *udev, int resolve_names)
}
strv_uniq(rules->dirs);
- rules->dirs_ts_usec = calloc(strv_length(rules->dirs), sizeof(usec_t));
- if(!rules->dirs_ts_usec)
- return udev_rules_unref(rules);
udev_rules_check_timestamp(rules);
r = conf_files_list_strv(&files, ".rules", NULL, (const char **)rules->dirs);
@@ -1711,14 +1708,13 @@ struct udev_rules *udev_rules_unref(struct udev_rules *rules)
free(rules->uids);
free(rules->gids);
strv_free(rules->dirs);
- free(rules->dirs_ts_usec);
free(rules);
return NULL;
}
bool udev_rules_check_timestamp(struct udev_rules *rules)
{
- return paths_check_timestamp(rules->dirs, rules->dirs_ts_usec, true);
+ return paths_check_timestamp(rules->dirs, &rules->dirs_ts_usec, true);
}
static int match_key(struct udev_rules *rules, struct token *token, const char *val)