svn commit: r220270 - head/sbin/hastd
Pawel Jakub Dawidek
pjd at FreeBSD.org
Sat Apr 2 09:22:07 UTC 2011
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);
More information about the svn-src-all
mailing list