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 commit is contained in:
parent
2a49afacd1
commit
3a0b818f59
@ -82,6 +82,17 @@ proto_common_send(int sock, const unsigned char *data, size_t size, int fd)
|
||||
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 char *data, size_t size, int *fdp)
|
||||
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);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user