From eee4d4133d6f7ccbda6bbddfabf7746054ad36d1 Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Mon, 7 Feb 2000 02:25:57 +0000 Subject: 2000-02-06 Roland McGrath * socket.c (make_sock_user): Take new argument CONSUME. * pfinet.h: Update decl. * io-ops.c (S_io_reauthenticate, S_io_restrict_auth, S_io_duplicate): Callers changed, these all pass false. * socket-ops.c (S_socket_create, S_socket_accept): Callers changed, these ones pass true. --- pfinet/io-ops.c | 6 +++--- pfinet/pfinet.h | 2 +- pfinet/socket-ops.c | 4 ++-- pfinet/socket.c | 8 +++++--- 4 files changed, 11 insertions(+), 9 deletions(-) (limited to 'pfinet') diff --git a/pfinet/io-ops.c b/pfinet/io-ops.c index c4cfc253..90671c17 100644 --- a/pfinet/io-ops.c +++ b/pfinet/io-ops.c @@ -334,7 +334,7 @@ S_io_reauthenticate (struct sock_user *user, aux_gids = agbuf; __mutex_lock (&global_lock); - newuser = make_sock_user (user->sock, 0, 1); + newuser = make_sock_user (user->sock, 0, 1, 0); auth = getauth (); newright = ports_get_right (newuser); @@ -406,7 +406,7 @@ S_io_restrict_auth (struct sock_user *user, if (uids[i] == 0) isroot = 1; - newuser = make_sock_user (user->sock, isroot, 0); + newuser = make_sock_user (user->sock, isroot, 0, 0); *newobject = ports_get_right (newuser); *newobject_type = MACH_MSG_TYPE_MAKE_SEND; ports_port_deref (newuser); @@ -424,7 +424,7 @@ S_io_duplicate (struct sock_user *user, return EOPNOTSUPP; __mutex_lock (&global_lock); - newuser = make_sock_user (user->sock, user->isroot, 0); + newuser = make_sock_user (user->sock, user->isroot, 0, 0); *newobject = ports_get_right (newuser); *newobject_type = MACH_MSG_TYPE_MAKE_SEND; ports_port_deref (newuser); diff --git a/pfinet/pfinet.h b/pfinet/pfinet.h index b5c551d8..35c76570 100644 --- a/pfinet/pfinet.h +++ b/pfinet/pfinet.h @@ -57,7 +57,7 @@ struct sock_addr void ethernet_initialize (void); int ethernet_demuxer (mach_msg_header_t *, mach_msg_header_t *); void setup_ethernet_device (char *); -struct sock_user *make_sock_user (struct socket *, int, int); +struct sock_user *make_sock_user (struct socket *, int, int, int); error_t make_sockaddr_port (struct socket *, int, mach_port_t *, mach_msg_type_name_t *); void init_devices (void); diff --git a/pfinet/socket-ops.c b/pfinet/socket-ops.c index bcfa7f45..d6edce7e 100644 --- a/pfinet/socket-ops.c +++ b/pfinet/socket-ops.c @@ -68,7 +68,7 @@ S_socket_create (struct trivfs_protid *master, sock_release (sock); else { - user = make_sock_user (sock, master->isroot, 0); + user = make_sock_user (sock, master->isroot, 0, 1); *port = ports_get_right (user); *porttype = MACH_MSG_TYPE_MAKE_SEND; ports_port_deref (user); @@ -136,7 +136,7 @@ S_socket_accept (struct sock_user *user, if (!err) { - newuser = make_sock_user (newsock, user->isroot, 0); + newuser = make_sock_user (newsock, user->isroot, 0, 1); *new_port = ports_get_right (newuser); *new_port_type = MACH_MSG_TYPE_MAKE_SEND; ports_port_deref (newuser); diff --git a/pfinet/socket.c b/pfinet/socket.c index 52bd37ff..82935a57 100644 --- a/pfinet/socket.c +++ b/pfinet/socket.c @@ -59,9 +59,10 @@ sock_alloc (void) } /* Create a sock_user structure, initialized from SOCK and ISROOT. - If NOINSTALL is set, don't put it in the portset. */ + If NOINSTALL is set, don't put it in the portset. + We increment SOCK->refcnt iff CONSUME is zero. */ struct sock_user * -make_sock_user (struct socket *sock, int isroot, int noinstall) +make_sock_user (struct socket *sock, int isroot, int noinstall, int consume) { error_t err; struct sock_user *user; @@ -81,7 +82,8 @@ make_sock_user (struct socket *sock, int isroot, int noinstall) in the original Linux structure), because there can be multiple ports (struct sock_user, aka protids) pointing to the same socket. The socket lives until all the ports die. */ - ++sock->refcnt; + if (! consume) + ++sock->refcnt; user->isroot = isroot; user->sock = sock; return user; -- cgit v1.2.3