summaryrefslogtreecommitdiff
path: root/libdiskfs
diff options
context:
space:
mode:
authorRoland McGrath <roland@gnu.org>2000-12-03 04:40:31 +0000
committerRoland McGrath <roland@gnu.org>2000-12-03 04:40:31 +0000
commit480862ac2dbb48d380f1cf6b29857dca1d80e260 (patch)
tree13294fe77315570116e91ad289759e4a5db10abb /libdiskfs
parent1c389d6fbea8d2b9ce89a98fecb11979df65ff89 (diff)
2000-12-02 Roland McGrath <roland@frob.com>
* node-times.c (diskfs_set_node_times): Make individual flag checks race-proof so we don't lose any flag settings.
Diffstat (limited to 'libdiskfs')
-rw-r--r--libdiskfs/node-times.c19
1 files changed, 13 insertions, 6 deletions
diff --git a/libdiskfs/node-times.c b/libdiskfs/node-times.c
index 3931ffb0..fa3a20a7 100644
--- a/libdiskfs/node-times.c
+++ b/libdiskfs/node-times.c
@@ -1,5 +1,5 @@
-/*
- Copyright (C) 1994,96,99 Free Software Foundation, Inc.
+/* Process st_?time updates marked for a diskfs node.
+ Copyright (C) 1994,96,99,2000 Free Software Foundation, Inc.
This file is part of the GNU Hurd.
@@ -34,6 +34,11 @@ diskfs_set_node_times (struct node *np)
maptime_read (diskfs_mtime, &t);
+ /* We are careful to test and reset each of these individually, so there
+ is no race condition where a dn_set_?time flag setting gets lost. It
+ is not a problem to have the kind of race where the flag is set after
+ we've tested it and done nothing--as long as the flag remains set so
+ the update will happen at the next call. */
if (np->dn_set_mtime)
{
#ifdef notyet
@@ -43,6 +48,8 @@ diskfs_set_node_times (struct node *np)
np->dn_stat.st_mtime = t.tv_sec;
np->dn_stat.st_mtime_usec = t.tv_usec;
#endif
+ np->dn_stat_dirty = 1;
+ np->dn_set_mtime = 0;
}
if (np->dn_set_atime)
{
@@ -53,6 +60,8 @@ diskfs_set_node_times (struct node *np)
np->dn_stat.st_atime = t.tv_sec;
np->dn_stat.st_atime_usec = t.tv_usec;
#endif
+ np->dn_stat_dirty = 1;
+ np->dn_set_atime = 0;
}
if (np->dn_set_ctime)
{
@@ -63,9 +72,7 @@ diskfs_set_node_times (struct node *np)
np->dn_stat.st_ctime = t.tv_sec;
np->dn_stat.st_ctime_usec = t.tv_usec;
#endif
+ np->dn_stat_dirty = 1;
+ np->dn_set_ctime = 0;
}
-
- if (np->dn_set_mtime || np->dn_set_atime || np->dn_set_ctime)
- np->dn_stat_dirty = 1;
- np->dn_set_mtime = np->dn_set_atime = np->dn_set_ctime = 0;
}