svn commit: r220270 - head/sbin/hastd

2011-04-02 Thread Pawel Jakub Dawidek
Author: pjd
Date: Sat Apr  2 09:22:06 2011
New Revision: 220270
URL: http://svn.freebsd.org/changeset/base/220270

Log:
  Allow to disable sends or receives on a socket using shutdown(2) by
  interpreting NULL 'data' argument passed to proto_common_send() or
  proto_common_recv() as a will to do so.
  
  MFC after:1 month

Modified:
  head/sbin/hastd/proto_common.c

Modified: head/sbin/hastd/proto_common.c
==
--- head/sbin/hastd/proto_common.c  Sat Apr  2 08:45:13 2011
(r220269)
+++ head/sbin/hastd/proto_common.c  Sat Apr  2 09:22:06 2011
(r220270)
@@ -82,6 +82,17 @@ proto_common_send(int sock, const unsign
size_t sendsize;
 
PJDLOG_ASSERT(sock = 0);
+
+   if (data == NULL) {
+   /* The caller is just trying to decide about direction. */
+
+   PJDLOG_ASSERT(size == 0);
+
+   if (shutdown(sock, SHUT_RD) == -1)
+   return (errno);
+   return (0);
+   }
+
PJDLOG_ASSERT(data != NULL);
PJDLOG_ASSERT(size  0);
 
@@ -141,6 +152,17 @@ proto_common_recv(int sock, unsigned cha
ssize_t done;
 
PJDLOG_ASSERT(sock = 0);
+
+   if (data == NULL) {
+   /* The caller is just trying to decide about direction. */
+
+   PJDLOG_ASSERT(size == 0);
+
+   if (shutdown(sock, SHUT_WR) == -1)
+   return (errno);
+   return (0);
+   }
+
PJDLOG_ASSERT(data != NULL);
PJDLOG_ASSERT(size  0);
 
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org


Re: svn commit: r220270 - head/sbin/hastd

2011-04-02 Thread Pawel Jakub Dawidek
On Sat, Apr 02, 2011 at 09:22:06AM +, Pawel Jakub Dawidek wrote:
 Author: pjd
 Date: Sat Apr  2 09:22:06 2011
 New Revision: 220270
 URL: http://svn.freebsd.org/changeset/base/220270
 
 Log:
   Allow to disable sends or receives on a socket using shutdown(2) by
   interpreting NULL 'data' argument passed to proto_common_send() or
   proto_common_recv() as a will to do so.
   
   MFC after:  1 month

This should've been 1 week here in the next two commits.

-- 
Pawel Jakub Dawidek   http://www.wheelsystems.com
FreeBSD committer http://www.FreeBSD.org
Am I Evil? Yes, I Am! http://yomoli.com


pgpYIudbJw3gq.pgp
Description: PGP signature