- check for doxygen
- no RLIMIT_MSGQUEUE on bsd
- change ENODATA to ENOMSG
Signed-off-by: Angus Salkeld <asalkeld(a)redhat.com>
---
configure.ac | 6 ++++--
docs/Makefile.am | 8 +++++++-
lib/ipc_posix_mq.c | 25 +++++++++++++++----------
lib/ipc_us.c | 6 ++++--
lib/ringbuffer.c | 4 ++--
tests/bmc.c | 3 +++
6 files changed, 35 insertions(+), 17 deletions(-)
diff --git a/configure.ac b/configure.ac
index b7e431b..90e01ac 100644
--- a/configure.ac
+++ b/configure.ac
@@ -54,6 +54,8 @@ AC_PROG_LN_S
AC_PROG_INSTALL
AC_PROG_MAKE_SET
AC_CHECK_PROGS([PKGCONFIG], [pkg-config])
+AC_CHECK_PROG(HAVE_DOXYGEN, doxygen, have_doxygen="yes",
have_doxygen="no")
+AM_CONDITIONAL(HAVE_DOXYGEN, test "${have_doxygen}" = "yes")
## local helper functions
@@ -96,7 +98,7 @@ AC_HEADER_SYS_WAIT
AC_CHECK_HEADERS([arpa/inet.h fcntl.h inttypes.h limits.h locale.h netdb.h netinet/in.h
nl_types.h stdint.h \
stdlib.h string.h sys/ioctl.h sys/param.h sys/socket.h \
- time.h sys/time.h syslog.h unistd.h sys/types.h getopt.h malloc.h \
+ time.h sys/time.h syslog.h unistd.h sys/types.h sys/stat.h getopt.h malloc.h \
sys/sockio.h sys/un.h utmpx.h errno.h dlfcn.h dirent.h fnmatch.h])
# Checks for typedefs, structures, and compiler characteristics.
@@ -211,7 +213,7 @@ case "$host_os" in
AC_DEFINE_UNQUOTED([MAP_ANONYMOUS], [MAP_ANON],
[Shared memory define for Darwin platform])
OS_CFLAGS=""
- OS_CPPFLAGS="-I/usr/local/include"
+ OS_CPPFLAGS="-I/usr/include -I/usr/local/include"
OS_LDFLAGS="-L/usr/local/lib"
OS_DYFLAGS="-export-dynamic"
DARWIN_OPTS=""
diff --git a/docs/Makefile.am b/docs/Makefile.am
index 06c976e..389160b 100644
--- a/docs/Makefile.am
+++ b/docs/Makefile.am
@@ -20,13 +20,14 @@
MAINTAINERCLEANFILES = Makefile.in
EXTRA_DIST = man.dox html.dox
+if HAVE_DOXYGEN
inc_dir = $(top_srcdir)/include/qb
dependant_headers = $(wildcard $(inc_dir)/qb*.h)
dist_man_MANS = man3/qbhash.h.3 man3/qbipcc.h.3 man3/qbipcs.h.3 man3/qblogsys.h.3 \
man3/qbplugin.h.3 man3/qbqueue.h.3 man3/qbtsafe.h.3 man3/qbwthread.h.3 \
man3/qbhdb.h.3 man3/qbipc_common.h.3 man3/qblist.h.3 man3/qbplugin_comp.h.3 \
man3/qbpoll.h.3 man3/qbtimer.h.3 man3/qbutil.h.3
-#$(addsuffix .3,$(subst $(inc_dir),man3,$(dependant_headers)))
+
$(dist_man_MANS): man.dox $(dependant_headers)
mkdir -p man3
@@ -36,6 +37,11 @@ doxygen: html.dox
mkdir -p html
doxygen html.dox
+else
+doxygen:
+ @echo WARNING: no doxygen to build man pages!
+endif
+
clean-generic:
rm -rf html man3
diff --git a/lib/ipc_posix_mq.c b/lib/ipc_posix_mq.c
index 9af7174..95de6ef 100644
--- a/lib/ipc_posix_mq.c
+++ b/lib/ipc_posix_mq.c
@@ -41,8 +41,10 @@ static int32_t posix_mq_increase_limits(size_t max_msg_size,
int32_t msgsize_max;
char size_str[10];
int32_t res = 0;
+#ifdef QB_LINUX
struct rlimit rlim;
int32_t q_limit;
+#endif /* QB_LINUX */
proc_fd = fopen("/proc/sys/fs/mqueue/msgsize_max", "r+");
if (proc_fd > 0) {
@@ -63,6 +65,7 @@ static int32_t posix_mq_increase_limits(size_t max_msg_size,
}
fclose(proc_fd);
+#ifdef QB_LINUX
if (getrlimit(RLIMIT_MSGQUEUE, &rlim) != 0) {
qb_util_log(LOG_ERR, "getrlimit failed");
return -1;
@@ -74,24 +77,26 @@ static int32_t posix_mq_increase_limits(size_t max_msg_size,
qb_util_log(LOG_ERR, "setrlimit failed");
return -1;
}
+#endif /* QB_LINUX */
return 0;
}
-static int32_t posix_mq_create(const char* mq_name, size_t max_msg_size,
+static mqd_t posix_mq_create(const char* mq_name, size_t max_msg_size,
int32_t flags)
{
struct mq_attr attr;
- int32_t res = 0;
+ mqd_t res = 0;
int32_t q_len = 10;
+ mode_t m = 0600;
attr.mq_flags = O_NONBLOCK;
attr.mq_maxmsg = q_len;
attr.mq_msgsize = max_msg_size;
mq_unlink(mq_name);
- res = mq_open(mq_name, flags, 0600, &attr);
- if (res == -1) {
+ res = mq_open(mq_name, flags, m, &attr);
+ if (res == (mqd_t)-1) {
perror(mq_name);
}
@@ -214,7 +219,7 @@ int32_t qb_ipcc_pmq_connect(struct qb_ipcc_connection * c)
snprintf(c->u.pmq.request.name, NAME_MAX, "/%s", c->name);
c->u.pmq.request.q = mq_open(c->u.pmq.request.name,
O_WRONLY | O_NONBLOCK);
- if (c->u.pmq.request.q == -1) {
+ if (c->u.pmq.request.q == (mqd_t)-1) {
perror("mq_open:REQUEST");
return -1;
}
@@ -230,7 +235,7 @@ int32_t qb_ipcc_pmq_connect(struct qb_ipcc_connection * c)
c->max_msg_size,
O_RDONLY | O_CREAT | O_EXCL | O_NONBLOCK);
- if (c->u.pmq.response.q == -1) {
+ if (c->u.pmq.response.q == (mqd_t)-1) {
perror("mq_open:RESPONSE");
goto cleanup_request;
}
@@ -244,7 +249,7 @@ int32_t qb_ipcc_pmq_connect(struct qb_ipcc_connection * c)
c->max_msg_size,
O_RDONLY | O_CREAT | O_EXCL | O_NONBLOCK);
- if (c->u.pmq.dispatch.q == -1) {
+ if (c->u.pmq.dispatch.q == (mqd_t)-1) {
perror("mq_open:DISPATCH");
goto cleanup_request_response;
}
@@ -329,7 +334,7 @@ static int32_t qb_ipcs_pmq_connect(struct qb_ipcs_service *s,
strcpy(c->u.pmq.response.name, init->response_mq);
c->u.pmq.response.q = mq_open(c->u.pmq.response.name,
O_WRONLY | O_NONBLOCK);
- if (c->u.pmq.response.q == -1) {
+ if (c->u.pmq.response.q == (mqd_t)-1) {
res = errno;
perror("mq_open:RESPONSE");
return res;
@@ -345,7 +350,7 @@ static int32_t qb_ipcs_pmq_connect(struct qb_ipcs_service *s,
c->u.pmq.dispatch.q = mq_open(c->u.pmq.dispatch.name,
O_WRONLY | O_NONBLOCK);
- if (c->u.pmq.dispatch.q == -1) {
+ if (c->u.pmq.dispatch.q == (mqd_t)-1) {
res = errno;
perror("mq_open:DISPATCH");
goto cleanup_response;
@@ -421,7 +426,7 @@ int32_t qb_ipcs_pmq_create(struct qb_ipcs_service *s)
posix_mq_increase_limits(s->max_msg_size, 10);
s->u.q = posix_mq_create(mq_name, s->max_msg_size,
(O_RDONLY | O_CREAT | O_EXCL | O_NONBLOCK));
- if (s->u.q == -1) {
+ if (s->u.q == (mqd_t)-1) {
perror("posix_mq_create:REQUEST");
return -1;
}
diff --git a/lib/ipc_us.c b/lib/ipc_us.c
index 45dee69..2682dee 100644
--- a/lib/ipc_us.c
+++ b/lib/ipc_us.c
@@ -26,7 +26,9 @@
#ifdef HAVE_SYS_UN_H
#include <sys/un.h>
#endif /* HAVE_SYS_UN_H */
-
+#ifdef HAVE_SYS_STAT_H
+#include <sys/stat.h>
+#endif
#include <qb/qbipcs.h>
#include <qb/qbpoll.h>
#include "util_int.h"
@@ -447,7 +449,7 @@ int32_t qb_ipcs_us_publish(struct qb_ipcs_service * s)
SOCKETDIR);
goto error_close;
}
- sprintf(un_addr.sun_path, "%s/%s", SOCKETDIR, name);
+ sprintf(un_addr.sun_path, "%s/%s", SOCKETDIR, s->name);
unlink(un_addr.sun_path);
}
#endif
diff --git a/lib/ringbuffer.c b/lib/ringbuffer.c
index 009d23e..989eefe 100644
--- a/lib/ringbuffer.c
+++ b/lib/ringbuffer.c
@@ -491,7 +491,7 @@ ssize_t qb_rb_chunk_peek(qb_ringbuffer_t * rb, void **data_out,
int32_t timeout)
*data_out = &rb->shared_data[read_pt + QB_RB_CHUNK_HEADER_WORDS];
if (chunk_magic != QB_RB_CHUNK_MAGIC) {
- errno = ENODATA;
+ errno = ENOMSG;
return -1;
} else {
return chunk_size;
@@ -524,7 +524,7 @@ qb_rb_chunk_read(qb_ringbuffer_t * rb, void *data_out, size_t len,
}
if (_qb_rb_space_used_locked_(rb) == 0) {
rb->unlock_fn(rb);
- errno = ENODATA;
+ errno = ENOMSG;
return -1;
}
diff --git a/tests/bmc.c b/tests/bmc.c
index b618bf0..2296559 100644
--- a/tests/bmc.c
+++ b/tests/bmc.c
@@ -18,6 +18,7 @@
* You should have received a copy of the GNU Lesser General Public License
* along with libqb. If not, see <
http://www.gnu.org/licenses/>.
*/
+#include "config.h"
#include <unistd.h>
#include <sys/types.h>
#include <sys/socket.h>
@@ -40,6 +41,7 @@ static qb_ipcc_connection_t *conn;
static struct timeval tv1, tv2, tv_elapsed;
+#ifndef QB_BSD
#define timersub(a, b, result) \
do { \
(result)->tv_sec = (a)->tv_sec - (b)->tv_sec; \
@@ -49,6 +51,7 @@ do { \
(result)->tv_usec += 1000000; \
} \
} while (0)
+#endif
static void bm_start(void)
{
--
1.7.2.2