Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 31 May 1996 22:08:33 -0700 (PDT)
From:      Bill Paul <wpaul>
To:        CVS-committers, cvs-all, cvs-lib
Subject:   cvs commit:  src/lib/libc/yp yplib.c
Message-ID:  <199606010508.WAA08865@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help
wpaul       96/05/31 22:08:33

  Modified:    lib/libc/yp  yplib.c
  Log:
  Make _yp_dobind() a litle smarter:
  
  Now that we preserve RPC handles instead of rebuilding them each time
  a ypcln function is called, we have to be careful about keeping our sockets
  in a sane state. It's possible that the caller may call a ypclnt
  function, and then decide to close all its file descriptors. This would
  also close the socket descriptor held by the yplib code. Worse, it
  could re-open the same descriptor number for its own use. If it then calls
  another ypclnt function, the subsequent RPC will fail because the socket
  will either be gone or replaced with Something Completely Different. The
  yplib code will recover by rebinding, but it doing so it may wreck the
  descriptor which now belongs to the caller.
  
  To fix this, _yp_dobind() needs to label the descriptor somehow so
  that it can test it later to make sure it hasn't been altered between
  ypclnt calls. It does this by binding the socket, thus associating a port
  number with it. It then saves this port number in the dom_local_port member
  of the dom_binding structure for the given domain. When _yp_dobind() is
  called again (which it is at the start of each ypclnt function), it checks
  to see if the domain is already bound, and if it is, it does a getsockname()
  on the socket and compares the port number to the one it saved. If the
  getsockname() fails, or the port number doesn't match, it abandons the
  socket and sets up a new client handle.
  
  This still incurs some syscall overhead, which is what I was trying to
  avoid, but it's still not as bad as before.
  
  Revision  Changes    Path
  1.20      +43 -2     src/lib/libc/yp/yplib.c



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199606010508.WAA08865>