From f841438e951fca51fa926795e551a45ae60c3a63 Mon Sep 17 00:00:00 2001 From: Miles Bader Date: Sat, 27 Jan 1996 16:49:22 +0000 Subject: (diskfs_set_sync_interval): Use ports_create_port instead of ports_allocate_port. Deal with ports_inhibit_class_rpcs returning an error. (periodic_sync): Pass in the MSG_ID arg to ports_begin_rpc, and deal with any error returned. --- libdiskfs/sync-interval.c | 34 +++++++++++++++++++++------------- 1 file changed, 21 insertions(+), 13 deletions(-) diff --git a/libdiskfs/sync-interval.c b/libdiskfs/sync-interval.c index c86eba6a..c2b578a8 100644 --- a/libdiskfs/sync-interval.c +++ b/libdiskfs/sync-interval.c @@ -1,6 +1,6 @@ /* Support for periodic syncing - Copyright (C) 1995 Free Software Foundation, Inc. + Copyright (C) 1995, 1996 Free Software Foundation, Inc. Written by Miles Bader @@ -49,12 +49,17 @@ diskfs_set_sync_interval (int interval) { error_t err = 0; - if (!pi) - pi = ports_allocate_port (diskfs_port_bucket, - sizeof (struct port_info), - diskfs_control_class); + if (! pi) + { + err = ports_create_port (diskfs_control_class, diskfs_port_bucket, + sizeof (struct port_info), &pi); + if (err) + return err; + } - ports_inhibit_port_rpcs (pi); + err = ports_inhibit_port_rpcs (pi); + if (err) + return err; /* Here we just set the new thread; any existing thread will notice when it wakes up and go away silently. */ @@ -88,11 +93,12 @@ periodic_sync (int interval) { for (;;) { + error_t err; struct rpc_info link; /* This acts as a lock against creation of a new sync thread while we are in the process of syncing. */ - ports_begin_rpc (pi, &link); + err = ports_begin_rpc (pi, 0, &link); if (periodic_sync_thread != cthread_self ()) { @@ -101,12 +107,14 @@ periodic_sync (int interval) return; } - rwlock_reader_lock (&diskfs_fsys_lock); - diskfs_sync_everything (0); - diskfs_set_hypermetadata (0, 0); - rwlock_reader_unlock (&diskfs_fsys_lock); - - ports_end_rpc (pi, &link); + if (! err) + { + rwlock_reader_lock (&diskfs_fsys_lock); + diskfs_sync_everything (0); + diskfs_set_hypermetadata (0, 0); + rwlock_reader_unlock (&diskfs_fsys_lock); + ports_end_rpc (pi, &link); + } /* Wait until next time. */ sleep (interval); -- cgit v1.2.3