From 480862ac2dbb48d380f1cf6b29857dca1d80e260 Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Sun, 3 Dec 2000 04:40:31 +0000 Subject: 2000-12-02 Roland McGrath * node-times.c (diskfs_set_node_times): Make individual flag checks race-proof so we don't lose any flag settings. --- libdiskfs/node-times.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) (limited to 'libdiskfs') 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; } -- cgit v1.2.3