From 749d16ba3030aa0bdb548c50b21f73259c5b6f5c Mon Sep 17 00:00:00 2001 From: Norbert Warmuth Date: Sat, 9 Jan 1999 23:08:41 +0000 Subject: [PATCH] Sat Jan 9 19:15:00 1999 Norbert Warmuth * vfs/vfs.c (vfs_timeout_handler): Guard from recursive invocation. Sat Jan 9 19:13:28 1999 Norbert Warmuth * vfs/sfs.c (sfs_free): Fixed wrong linked list handling (head was lost after the first iteration). (sfs_getid): dito, return value was wrong. --- vfs/ChangeLog | 11 +++++++++++ vfs/sfs.c | 33 ++++++++++++++++----------------- vfs/vfs.c | 8 ++++++++ 3 files changed, 35 insertions(+), 17 deletions(-) diff --git a/vfs/ChangeLog b/vfs/ChangeLog index e42c74617..0915d955e 100644 --- a/vfs/ChangeLog +++ b/vfs/ChangeLog @@ -1,3 +1,14 @@ +Sat Jan 9 19:15:00 1999 Norbert Warmuth + + * vfs.c (vfs_timeout_handler): Guard from recursive invocation. + +Sat Jan 9 19:13:28 1999 Norbert Warmuth + + * sfs.c (sfs_free): Fixed wrong linked list handling (head was + lost after the first iteration). + + (sfs_getid): dito, return value was wrong. + Sat Jan 9 22:49:02 1999 Timur I. Bakeyev * vfs.c (parse_ls_lga): Rewrite function to make it more stright. diff --git a/vfs/sfs.c b/vfs/sfs.c index 15643e2ef..c4d3e1c2e 100644 --- a/vfs/sfs.c +++ b/vfs/sfs.c @@ -201,21 +201,20 @@ static int sfs_readlink (vfs *me, char *path, char *buf, int size) return readlink (path, buf, size); } -#define CUR (*cur) static vfsid sfs_getid (vfs *me, char *path, struct vfs_stamping **parent) { /* FIXME: what should I do? */ vfs *v; vfsid id; struct vfs_stamping *par; - struct cachedfile **cur = &head; + struct cachedfile *cur = head; - while (CUR) { - if ((!strcmp( path, CUR->name )) && - (vfs_uid == CUR->uid)) + while (cur) { + if ((!strcmp( path, cur->name )) && + (vfs_uid == cur->uid)) break; - CUR = CUR->next; + cur = cur->next; } - if (!CUR) + if (!cur) vfs_die( "sfs_getid of noncached thingie?" ); *parent = NULL; @@ -240,19 +239,19 @@ static vfsid sfs_getid (vfs *me, char *path, struct vfs_stamping **parent) static void sfs_free (vfsid id) { struct cachedfile *which = (struct cachedfile *) id; - struct cachedfile **cur = &head; + struct cachedfile *cur, *prev; - unlink( CUR->cache ); - while (CUR) { - if (CUR == which) - break; - CUR = CUR->next; - } - if (!CUR) + for (cur = head, prev = 0; cur && cur != which; prev = cur, cur = cur->next) + ; + if (!cur) vfs_die( "Free of thing which is unknown to me\n" ); - *cur = CUR->next; + unlink (cur->cache); + + if (prev) + prev->next = cur->next; + else + head = cur->next; } -#undef CUR static void sfs_fill_names (vfs *me, void (*func)(char *)) { diff --git a/vfs/vfs.c b/vfs/vfs.c index b68fac392..47db1c3ac 100644 --- a/vfs/vfs.c +++ b/vfs/vfs.c @@ -1150,9 +1150,16 @@ timeoutcmp (struct timeval *t1, struct timeval *t2) void vfs_timeout_handler (void) { + static int locked; struct timeval time; struct vfs_stamping *stamp, *st; + /* Avoid recursive invocation, e.g. when one of the free functions + calls message_1s */ + if (locked) + return; + locked = 1; + gettimeofday (&time, NULL); time.tv_sec -= vfs_timeout; @@ -1165,6 +1172,7 @@ vfs_timeout_handler (void) } else stamp = stamp->next; } + locked = 0; } void