bug-hurd
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

pflocal's ports, references and S_socket_name()


From: Samuel Thibault
Subject: pflocal's ports, references and S_socket_name()
Date: Tue, 22 Jul 2008 02:00:59 +0100
User-agent: Mutt/1.5.12-2006-07-14

Hello,

We are having troubles with tcl, basically
a=`tclsh`
does not return, because the pipe says there is still a writer (although
tclsh is dead).

It looks like it is a reference which is not dropped in
pflocal/socket.c:S_socket_name() (which tclsh calls on stdout):

error_t
S_socket_name (struct sock_user *user,
               mach_port_t *addr_port, mach_msg_type_name_t *addr_port_type)
{
  error_t err;
  struct addr *addr;

  if (!user)
    return EOPNOTSUPP;

  err = sock_get_addr (user->sock, &addr);
  if (err)
    return err;

  *addr_port = ports_get_right (addr);
  *addr_port_type = MACH_MSG_TYPE_MAKE_SEND;

  return 0;
}

In similar code in pflocal, there is an additional ports_port_deref
(addr); because "We only want one ref, for the send right."  Isn't
that the case here as well?  If I add it the test above works fine,
but since I'm not very used to port management I don't know if
there may be other issues to be aware of.  The same would apply to
S_socket_fabricate_address(), see patch below.

Samuel

2008-07-22  Samuel Thibault  <samuel.thibault@ens-lyon.org>

        * pf.c (S_socket_fabricate_address): Drop one reference from
        addr since we only take the send right.
        * socket.c (S_socket_name): Likewise.

Index: pflocal/pf.c
===================================================================
RCS file: /cvsroot/hurd/hurd/pflocal/pf.c,v
retrieving revision 1.15
diff -u -p -r1.15 pf.c
--- pflocal/pf.c        9 Aug 2000 21:13:53 -0000       1.15
+++ pflocal/pf.c        22 Jul 2008 00:54:47 -0000
@@ -108,6 +108,7 @@ S_socket_fabricate_address (mach_port_t 
 
   *addr_port = ports_get_right (addr);
   *addr_port_type = MACH_MSG_TYPE_MAKE_SEND;
+  ports_port_deref (addr);
 
   return 0;
 }
Index: pflocal/socket.c
===================================================================
RCS file: /cvsroot/hurd/hurd/pflocal/socket.c,v
retrieving revision 1.24
diff -u -p -r1.24 socket.c
--- pflocal/socket.c    29 Aug 2005 09:41:21 -0000      1.24
+++ pflocal/socket.c    22 Jul 2008 00:54:47 -0000
@@ -245,6 +245,7 @@ S_socket_name (struct sock_user *user,
 
   *addr_port = ports_get_right (addr);
   *addr_port_type = MACH_MSG_TYPE_MAKE_SEND;
+  ports_port_deref (addr);
 
   return 0;
 }




reply via email to

[Prev in Thread] Current Thread [Next in Thread]