diff options
Diffstat (limited to 'hostmux')
-rw-r--r-- | hostmux/Makefile | 3 | ||||
-rw-r--r-- | hostmux/hostmux.h | 4 | ||||
-rw-r--r-- | hostmux/mux.c | 30 | ||||
-rw-r--r-- | hostmux/node.c | 2 | ||||
-rw-r--r-- | hostmux/stubs.c | 2 |
5 files changed, 21 insertions, 20 deletions
diff --git a/hostmux/Makefile b/hostmux/Makefile index b139922f..939a9f62 100644 --- a/hostmux/Makefile +++ b/hostmux/Makefile @@ -24,6 +24,7 @@ target = hostmux SRCS = hostmux.c mux.c leaf.c node.c stubs.c OBJS = $(SRCS:.c=.o) -HURDLIBS = netfs fshelp iohelp threads ports ihash shouldbeinlibc +HURDLIBS = netfs fshelp iohelp ports ihash shouldbeinlibc +OTHERLIBS = -lpthread include ../Makeconf diff --git a/hostmux/hostmux.h b/hostmux/hostmux.h index 98ef04ac..e6cfb767 100644 --- a/hostmux/hostmux.h +++ b/hostmux/hostmux.h @@ -22,7 +22,7 @@ #define __HOSTMUX_H__ #include <hurd/netfs.h> -#include <rwlock.h> +#include <pthread.h> #include <maptime.h> #include <features.h> @@ -40,7 +40,7 @@ struct hostmux { /* The host hodes in this mux. */ struct hostmux_name *names; - struct rwlock names_lock; + pthread_rwlock_t names_lock; /* The next inode number we'll use; protected by NAMES_LOCK. */ ino_t next_fileno; diff --git a/hostmux/mux.c b/hostmux/mux.c index dd976c57..737240af 100644 --- a/hostmux/mux.c +++ b/hostmux/mux.c @@ -80,11 +80,11 @@ netfs_attempt_lookup (struct iouser *user, struct node *dir, fshelp_touch (&dir->nn_stat, TOUCH_ATIME, hostmux_maptime); } - mutex_unlock (&dir->lock); + pthread_mutex_unlock (&dir->lock); if (err) *node = 0; else - mutex_lock (&(*node)->lock); + pthread_mutex_lock (&(*node)->lock); return err; } @@ -123,7 +123,7 @@ netfs_get_dirents (struct iouser *cred, struct node *dir, if (dir->nn->name) return ENOTDIR; - rwlock_reader_lock (&dir->nn->mux->names_lock); + pthread_rwlock_rdlock (&dir->nn->mux->names_lock); /* Find the first entry. */ for (first_name = dir->nn->mux->names, count = 2; @@ -204,7 +204,7 @@ netfs_get_dirents (struct iouser *cred, struct node *dir, break; } - rwlock_reader_unlock (&dir->nn->mux->names_lock); + pthread_rwlock_unlock (&dir->nn->mux->names_lock); fshelp_touch (&dir->nn_stat, TOUCH_ATIME, hostmux_maptime); @@ -240,10 +240,10 @@ lookup_cached (struct hostmux *mux, const char *host, int purge, if (strcasecmp (host, nm->name) == 0) { - spin_lock (&netfs_node_refcnt_lock); + pthread_spin_lock (&netfs_node_refcnt_lock); if (nm->node) nm->node->references++; - spin_unlock (&netfs_node_refcnt_lock); + pthread_spin_unlock (&netfs_node_refcnt_lock); if (nm->node) { @@ -295,13 +295,13 @@ lookup_addrinfo (struct hostmux *mux, const char *host, struct addrinfo *he, return err; } - rwlock_writer_lock (&mux->names_lock); + pthread_rwlock_wrlock (&mux->names_lock); if (lookup_cached (mux, host, 1, node)) /* An entry for HOST has already been created between the time we last looked and now (which is possible because we didn't lock MUX). Just throw away our version and return the one already in the cache. */ { - rwlock_writer_unlock (&mux->names_lock); + pthread_rwlock_unlock (&mux->names_lock); nm->node->nn->name = 0; /* Avoid touching the mux name list. */ netfs_nrele (nm->node); /* Free the tentative new node. */ free_name (nm); /* And the name it was under. */ @@ -312,7 +312,7 @@ lookup_addrinfo (struct hostmux *mux, const char *host, struct addrinfo *he, nm->fileno = mux->next_fileno++; /* Now that we hold the lock... */ nm->next = mux->names; mux->names = nm; - rwlock_writer_unlock (&mux->names_lock); + pthread_rwlock_unlock (&mux->names_lock); } return 0; @@ -333,9 +333,9 @@ lookup_host (struct hostmux *mux, const char *host, struct node **node) hints.ai_socktype = SOCK_DGRAM; hints.ai_protocol = IPPROTO_IP; - rwlock_reader_lock (&mux->names_lock); + pthread_rwlock_rdlock (&mux->names_lock); was_cached = lookup_cached (mux, host, 0, node); - rwlock_reader_unlock (&mux->names_lock); + pthread_rwlock_unlock (&mux->names_lock); if (was_cached) return 0; @@ -381,14 +381,14 @@ netfs_attempt_chown (struct iouser *cred, struct node *node, uid_t uid, uid_t gi node->nn_stat.st_gid = gid; /* Change the owner of each leaf node. */ - rwlock_reader_lock (&mux->names_lock); + pthread_rwlock_rdlock (&mux->names_lock); for (nm = mux->names; nm; nm = nm->next) if (nm->node) { nm->node->nn_stat.st_uid = uid; nm->node->nn_stat.st_gid = gid; } - rwlock_reader_unlock (&mux->names_lock); + pthread_rwlock_unlock (&mux->names_lock); fshelp_touch (&node->nn_stat, TOUCH_CTIME, hostmux_maptime); } @@ -418,11 +418,11 @@ netfs_attempt_chauthor (struct iouser *cred, struct node *node, uid_t author) node->nn_stat.st_author = author; /* Change the owner of each leaf node. */ - rwlock_reader_lock (&mux->names_lock); + pthread_rwlock_rdlock (&mux->names_lock); for (nm = mux->names; nm; nm = nm->next) if (nm->node) nm->node->nn_stat.st_author = author; - rwlock_reader_unlock (&mux->names_lock); + pthread_rwlock_unlock (&mux->names_lock); fshelp_touch (&node->nn_stat, TOUCH_CTIME, hostmux_maptime); } diff --git a/hostmux/node.c b/hostmux/node.c index d6edc53e..7167300f 100644 --- a/hostmux/node.c +++ b/hostmux/node.c @@ -46,7 +46,7 @@ netfs_attempt_create_file (struct iouser *user, struct node *dir, char *name, mode_t mode, struct node **node) { *node = 0; - mutex_unlock (&dir->lock); + pthread_mutex_unlock (&dir->lock); return EOPNOTSUPP; } diff --git a/hostmux/stubs.c b/hostmux/stubs.c index f5dd9b67..1d94f219 100644 --- a/hostmux/stubs.c +++ b/hostmux/stubs.c @@ -120,7 +120,7 @@ netfs_attempt_mkfile (struct iouser *user, struct node *dir, mode_t mode, struct node **node) { *node = 0; - mutex_unlock (&dir->lock); + pthread_mutex_unlock (&dir->lock); return EOPNOTSUPP; } |