diff options
author | pjd <pjd@FreeBSD.org> | 2011-01-31 18:32:17 +0000 |
---|---|---|
committer | pjd <pjd@FreeBSD.org> | 2011-01-31 18:32:17 +0000 |
commit | d916d2edb510181e3ab25256b84c439c5e1b8498 (patch) | |
tree | f3795a28e12aabbbc327a4d51170b148a1f2dbb2 /sbin/hastd/proto_common.c | |
parent | 34c6c0a73948c51ae253cd9f5821beeee63cb4ca (diff) | |
download | FreeBSD-src-d916d2edb510181e3ab25256b84c439c5e1b8498.zip FreeBSD-src-d916d2edb510181e3ab25256b84c439c5e1b8498.tar.gz |
- Use pjdlog for assertions and aborts as this will log assert/abort message
to syslog if we run in background.
- Asserts in proto.c that method we want to call is implemented and remove
dummy methods from protocols implementation that are only there to abort
the program with nice message.
MFC after: 1 week
Diffstat (limited to 'sbin/hastd/proto_common.c')
-rw-r--r-- | sbin/hastd/proto_common.c | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/sbin/hastd/proto_common.c b/sbin/hastd/proto_common.c index 84680c2b..89c637d 100644 --- a/sbin/hastd/proto_common.c +++ b/sbin/hastd/proto_common.c @@ -33,11 +33,11 @@ __FBSDID("$FreeBSD$"); #include <sys/types.h> #include <sys/socket.h> -#include <assert.h> #include <errno.h> #include <stdlib.h> #include <strings.h> +#include "pjdlog.h" #include "proto_impl.h" /* Maximum size of packet we want to use when sending data. */ @@ -51,6 +51,10 @@ proto_common_send(int fd, const unsigned char *data, size_t size) ssize_t done; size_t sendsize; + PJDLOG_ASSERT(fd >= 0); + PJDLOG_ASSERT(data != NULL); + PJDLOG_ASSERT(size > 0); + do { sendsize = size < MAX_SEND_SIZE ? size : MAX_SEND_SIZE; done = send(fd, data, sendsize, MSG_NOSIGNAL); @@ -73,6 +77,10 @@ proto_common_recv(int fd, unsigned char *data, size_t size) { ssize_t done; + PJDLOG_ASSERT(fd >= 0); + PJDLOG_ASSERT(data != NULL); + PJDLOG_ASSERT(size > 0); + do { done = recv(fd, data, size, MSG_WAITALL); } while (done == -1 && errno == EINTR); |