Skip to content

Commit

Permalink
Merged branch 'master' of git://git.tokkee.org/sysdb.
Browse files Browse the repository at this point in the history
  • Loading branch information
tokkee committed Jun 27, 2014
2 parents 49a7df2 + a08b303 commit 4436642
Show file tree
Hide file tree
Showing 8 changed files with 110 additions and 116 deletions.
35 changes: 21 additions & 14 deletions src/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -114,11 +114,18 @@ sysdb_LDADD = libsysdb_scanner.la libsysdbclient.la @READLINE_LIBS@
endif

sysdbd_SOURCES = tools/sysdbd/main.c include/sysdb.h \
tools/sysdbd/configfile.c tools/sysdbd/configfile.h
tools/sysdbd/configfile.c tools/sysdbd/configfile.h \
$(libsysdb_la_SOURCES)
sysdbd_CFLAGS = $(AM_CFLAGS) -DBUILD_DATE="\"$$( date --utc '+%F %T' ) (UTC)\""
sysdbd_LDFLAGS = -export-dynamic
sysdbd_LDADD = libsysdb.la liboconfig/liboconfig.la
sysdbd_DEPENDENCIES = liboconfig/liboconfig.la
sysdbd_CPPFLAGS = $(AM_CPPFLAGS) $(LTDLINCL)
sysdbd_LDFLAGS = $(AM_LDFLAGS) -export-dynamic -pthread
sysdbd_LDADD = libsysdb_fe_parser.la liboconfig/liboconfig.la \
$(LIBLTDL) -lrt
sysdbd_DEPENDENCIES = libsysdb_fe_parser.la liboconfig/liboconfig.la

if BUILD_WITH_LIBDBI
sysdbd_LDADD += -ldbi
endif

sdbconfdir = $(sysconfdir)/sysdb
dist_sdbconf_DATA = tools/sysdbd/sysdbd.conf.sample
Expand All @@ -138,40 +145,40 @@ if BUILD_PLUGIN_CNAMEDNS
pkgcnamelib_LTLIBRARIES += plugins/cname/dns.la
plugins_cname_dns_la_SOURCE = plugins/cname/dns.c
plugins_cname_dns_la_LDFLAGS = $(AM_LDFLAGS) -module -avoid-version
libsysdb_la_LIBADD += -dlopen plugins/cname/dns.la
libsysdb_la_DEPENDENCIES += plugins/cname/dns.la
sysdbd_LDADD += -dlopen plugins/cname/dns.la
sysdbd_DEPENDENCIES += plugins/cname/dns.la
endif

if BUILD_PLUGIN_COLLECTD
pkgbackendcollectdlib_LTLIBRARIES += backend/collectd/unixsock.la
backend_collectd_unixsock_la_SOURCES = backend/collectd/unixsock.c
backend_collectd_unixsock_la_LDFLAGS = $(AM_LDFLAGS) -module -avoid-version
libsysdb_la_LIBADD += -dlopen backend/collectd/unixsock.la
libsysdb_la_DEPENDENCIES += backend/collectd/unixsock.la
sysdbd_LDADD += -dlopen backend/collectd/unixsock.la
sysdbd_DEPENDENCIES += backend/collectd/unixsock.la
endif

if BUILD_PLUGIN_MKLIVESTATUS
pkgbackendlib_LTLIBRARIES += backend/mk-livestatus.la
backend_mk_livestatus_la_SOURCES = backend/mk-livestatus.c
backend_mk_livestatus_la_LDFLAGS = $(AM_LDFLAGS) -module -avoid-version
libsysdb_la_LIBADD += -dlopen backend/mk-livestatus.la
libsysdb_la_DEPENDENCIES += backend/mk-livestatus.la
sysdbd_LDADD += -dlopen backend/mk-livestatus.la
sysdbd_DEPENDENCIES += backend/mk-livestatus.la
endif

if BUILD_PLUGIN_PUPPETSTORECONFIGS
pkgbackendpuppetlib_LTLIBRARIES += backend/puppet/store-configs.la
backend_puppet_store_configs_la_SOURCES = backend/puppet/store-configs.c
backend_puppet_store_configs_la_LDFLAGS = $(AM_LDFLAGS) -module -avoid-version
libsysdb_la_LIBADD += -dlopen backend/puppet/store-configs.la
libsysdb_la_DEPENDENCIES += backend/puppet/store-configs.la
sysdbd_LDADD += -dlopen backend/puppet/store-configs.la
sysdbd_DEPENDENCIES += backend/puppet/store-configs.la
endif

if BUILD_PLUGIN_SYSLOG
pkglib_LTLIBRARIES += plugins/syslog.la
plugins_syslog_la_SOURCE = plugins/syslog.c
plugins_syslog_la_LDFLAGS = $(AM_LDFLAGS) -module -avoid-version
libsysdb_la_LIBADD += -dlopen plugins/syslog.la
libsysdb_la_DEPENDENCIES += plugins/syslog.la
sysdbd_LDADD += -dlopen plugins/syslog.la
sysdbd_DEPENDENCIES += plugins/syslog.la
endif

include/client/sysdb.h: include/client/sysdb.h.in ../version
Expand Down
16 changes: 16 additions & 0 deletions src/client/sock.c
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,22 @@ sdb_client_sockfd(sdb_client_t *client)
return client->fd;
} /* sdb_client_sockfd */

int
sdb_client_shutdown(sdb_client_t *client, int how)
{
if (! client) {
errno = ENOTSOCK;
return -1;
}

if (client->fd < 0) {
errno = EBADF;
return -1;
}

return shutdown(client->fd, how);
} /* sdb_client_shutdown */

void
sdb_client_close(sdb_client_t *client)
{
Expand Down
12 changes: 9 additions & 3 deletions src/core/plugin.c
Original file line number Diff line number Diff line change
Expand Up @@ -1113,12 +1113,11 @@ sdb_plugin_log(int prio, const char *msg)
sdb_llist_iter_t *iter;
int ret = -1;

_Bool logged = 0;

if (! msg)
return 0;

if (! sdb_llist_len(log_list))
return fprintf(stderr, "[%s] %s\n", SDB_LOG_PRIO_TO_STRING(prio), msg);

iter = sdb_llist_get_iter(log_list);
while (sdb_llist_iter_has_next(iter)) {
sdb_plugin_log_cb callback;
Expand All @@ -1131,8 +1130,15 @@ sdb_plugin_log(int prio, const char *msg)
tmp = callback(prio, msg, SDB_PLUGIN_CB(obj)->cb_user_data);
if (tmp > ret)
ret = tmp;

if (SDB_PLUGIN_CB(obj)->cb_ctx)
logged = 1;
/* else: this is an internally registered callback */
}
sdb_llist_iter_destroy(iter);

if (! logged)
return fprintf(stderr, "[%s] %s\n", SDB_LOG_PRIO_TO_STRING(prio), msg);
return ret;
} /* sdb_plugin_log */

Expand Down
4 changes: 1 addition & 3 deletions src/core/store-private.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ typedef struct {
typedef struct {
sdb_store_base_t super;

sdb_llist_t *children;
sdb_llist_t *services;
sdb_llist_t *attributes;
} sdb_store_obj_t;
#define SDB_STORE_OBJ(obj) ((sdb_store_obj_t *)(obj))
Expand Down Expand Up @@ -174,8 +174,6 @@ typedef struct {
typedef struct {
sdb_store_matcher_t super;
char *name;
/* XXX: this needs to be more flexible;
* add support for type-specific operators */
string_matcher_t value;
} attr_matcher_t;
#define ATTR_M(m) ((attr_matcher_t *)(m))
Expand Down
Loading

0 comments on commit 4436642

Please sign in to comment.