summaryrefslogtreecommitdiff
path: root/pfinet
diff options
context:
space:
mode:
authorRoland McGrath <roland@gnu.org>2000-02-07 02:25:57 +0000
committerRoland McGrath <roland@gnu.org>2000-02-07 02:25:57 +0000
commiteee4d4133d6f7ccbda6bbddfabf7746054ad36d1 (patch)
tree078264899234c898542fbf816e0119a5a2f44ecd /pfinet
parent96b2a9a9c243bf9d93b3b2737aef62e281000097 (diff)
2000-02-06 Roland McGrath <roland@baalperazim.frob.com>
* 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.
Diffstat (limited to 'pfinet')
-rw-r--r--pfinet/io-ops.c6
-rw-r--r--pfinet/pfinet.h2
-rw-r--r--pfinet/socket-ops.c4
-rw-r--r--pfinet/socket.c8
4 files changed, 11 insertions, 9 deletions
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;