Commit 56f24f9b authored by Leigh B. Stoller's avatar Leigh B. Stoller

Merge noelvin branch to the head.

parent 0d577bf1
......@@ -79,6 +79,7 @@ CLIENT_MANDIR = @CLIENT_MANDIR@
LOG_TESTBED = @LOG_TESTBED@
EVENTSYS = @EVENTSYS@
ELVIN_COMPAT = @ELVIN_COMPAT@
HAVE_MEZZANINE = @HAVE_MEZZANINE@
GTK_CONFIG = @GTK_CONFIG@
BRAINSTEM_DIR = @BRAINSTEM_DIR@
......
/*
* EMULAB-COPYRIGHT
* Copyright (c) 2005 University of Utah and the Flux Group.
* Copyright (c) 2005, 2007 University of Utah and the Flux Group.
* All rights reserved.
*/
......@@ -10,6 +10,7 @@
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <rpc/rpc.h>
#include <netdb.h>
#include <fcntl.h>
#include <stdio.h>
......@@ -71,7 +72,7 @@ int
main(int argc, char **argv)
{
int sock, ch, rc, retval = EXIT_FAILURE;
int length, port = SERVERPORT;
int port = SERVERPORT;
char *server = BOSSNODE;
struct sockaddr_in sin;
whoami_t whoami;
......
/*
* EMULAB-COPYRIGHT
* Copyright (c) 2000-2003, 2005, 2006 University of Utah and the Flux Group.
* Copyright (c) 2000-2003, 2005, 2006, 2007 University of Utah and the Flux Group.
* All rights reserved.
*/
......@@ -49,7 +49,7 @@ main(int argc, char **argv)
MYSQL_RES *res;
MYSQL_ROW row;
int tcpsock, ch;
int length, i, err = 0;
int length, i;
struct sockaddr_in name;
struct timeval timeout;
struct group *group;
......@@ -134,8 +134,7 @@ main(int argc, char **argv)
int clientsock, length = sizeof(client);
int cc, port;
whoami_t whoami;
unsigned char buf[BUFSIZ], node_id[64];
secretkey_t secretkey;
unsigned char node_id[64];
tipowner_t tipown;
void *reply = &tipown;
size_t reply_size = sizeof(tipown);
......
......@@ -39,6 +39,7 @@
#undef BOSSEVENTPORT
#undef WINSUPPORT
#undef OPSDBSUPPORT
#undef ELVIN_COMPAT
#undef HAVE_SRANDOMDEV
......
......@@ -1446,6 +1446,7 @@ done
#
......@@ -1510,7 +1511,7 @@ STAMPS=0
ARCHIVESUPPORT=0
NFSTRACESUPPORT=0
TBLOGFACIL="local5"
BOSSEVENTPORT=2927
BOSSEVENTPORT=16505
UNIFIED_BOSS_AND_OPS=0
FRISEBEEMCASTADDR="234.5.6"
FRISEBEEMCASTPORT=3564
......@@ -1518,6 +1519,7 @@ MIN_UNIX_UID=10000
MIN_UNIX_GID=6000
DELAYTHRESH=2
PELABSUPPORT=0
ELVIN_COMPAT=0
#
# XXX You really don't want to change these!
......@@ -1713,6 +1715,13 @@ EOF
fi
if test $ELVIN_COMPAT -eq 1; then
cat >> confdefs.h <<EOF
#define ELVIN_COMPAT 1
EOF
fi
if test $PLABSUPPORT -eq 1; then
if test "$PLAB_ROOTBALL" = "change.me"; then
{ echo "configure: error: plab support included but PLAB_ROOTBALL not defined." 1>&2; exit 1; }
......@@ -2097,17 +2106,17 @@ for ac_hdr in ulxmlrpcpp/ulxr_config.h
do
ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
echo "configure:2101: checking for $ac_hdr" >&5
echo "configure:2110: checking for $ac_hdr" >&5
if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
#line 2106 "configure"
#line 2115 "configure"
#include "confdefs.h"
#include <$ac_hdr>
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
{ (eval echo configure:2111: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
{ (eval echo configure:2120: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
if test -z "$ac_err"; then
rm -rf conftest*
......@@ -2146,17 +2155,17 @@ for ac_hdr in linux/videodev.h
do
ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
echo "configure:2150: checking for $ac_hdr" >&5
echo "configure:2159: checking for $ac_hdr" >&5
if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
#line 2155 "configure"
#line 2164 "configure"
#include "confdefs.h"
#include <$ac_hdr>
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
{ (eval echo configure:2160: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
{ (eval echo configure:2169: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
if test -z "$ac_err"; then
rm -rf conftest*
......@@ -2189,7 +2198,7 @@ done
# Extract the first word of "gtk-config", so it can be a program name with args.
set dummy gtk-config; ac_word=$2
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
echo "configure:2193: checking for $ac_word" >&5
echo "configure:2202: checking for $ac_word" >&5
if eval "test \"`echo '$''{'ac_cv_prog_GTK_CONFIG'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
......@@ -2268,7 +2277,7 @@ fi
# SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff"
# ./install, which can be erroneously created by make from ./install.sh.
echo $ac_n "checking for a BSD compatible install""... $ac_c" 1>&6
echo "configure:2272: checking for a BSD compatible install" >&5
echo "configure:2281: checking for a BSD compatible install" >&5
if test -z "$INSTALL"; then
if eval "test \"`echo '$''{'ac_cv_path_install'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
......@@ -2329,7 +2338,7 @@ esac
# Extract the first word of "rsync", so it can be a program name with args.
set dummy rsync; ac_word=$2
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
echo "configure:2333: checking for $ac_word" >&5
echo "configure:2342: checking for $ac_word" >&5
if eval "test \"`echo '$''{'ac_cv_path_RSYNC'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
......@@ -2823,6 +2832,7 @@ s%@MIN_UNIX_UID@%$MIN_UNIX_UID%g
s%@MIN_UNIX_GID@%$MIN_UNIX_GID%g
s%@DELAYTHRESH@%$DELAYTHRESH%g
s%@PELABSUPPORT@%$PELABSUPPORT%g
s%@ELVIN_COMPAT@%$ELVIN_COMPAT%g
s%@TBOPSEMAIL@%$TBOPSEMAIL%g
s%@TBOPSEMAIL_NOSLASH@%$TBOPSEMAIL_NOSLASH%g
s%@TBROBOCOPSEMAIL@%$TBROBOCOPSEMAIL%g
......
......@@ -200,6 +200,7 @@ AC_SUBST(MIN_UNIX_UID)
AC_SUBST(MIN_UNIX_GID)
AC_SUBST(DELAYTHRESH)
AC_SUBST(PELABSUPPORT)
AC_SUBST(ELVIN_COMPAT)
#
# Offer both versions of the email addresses that have the @ escaped
......@@ -263,7 +264,7 @@ STAMPS=0
ARCHIVESUPPORT=0
NFSTRACESUPPORT=0
TBLOGFACIL="local5"
BOSSEVENTPORT=2927
BOSSEVENTPORT=16505
UNIFIED_BOSS_AND_OPS=0
FRISEBEEMCASTADDR="234.5.6"
FRISEBEEMCASTPORT=3564
......@@ -271,6 +272,7 @@ MIN_UNIX_UID=10000
MIN_UNIX_GID=6000
DELAYTHRESH=2
PELABSUPPORT=0
ELVIN_COMPAT=0
#
# XXX You really don't want to change these!
......@@ -369,6 +371,10 @@ if test $OPSDBSUPPORT -eq 1; then
AC_DEFINE_UNQUOTED(OPSDBSUPPORT, 1)
fi
if test $ELVIN_COMPAT -eq 1; then
AC_DEFINE_UNQUOTED(ELVIN_COMPAT, 1)
fi
if test $PLABSUPPORT -eq 1; then
if test "$PLAB_ROOTBALL" = "change.me"; then
AC_MSG_ERROR([plab support included but PLAB_ROOTBALL not defined.])
......
......@@ -46,6 +46,8 @@ ARCHIVESUPPORT=changeme
DISABLE_NSE=1
# This means it is an inner elab!
ELABINELAB=1
# If we can run old images ... depends on whther elvind is installed.
ELVIN_COMPAT=changeme
# The name of the outer boss for inner boss to request services from.
OUTERBOSS_NODENAME=changeme
TBCOOKIESUFFIX=changeme
......
......@@ -10,5 +10,5 @@ TBAPPROVALEMAIL=stoller@flux.utah.edu
TBAUDITEMAIL=stoller@flux.utah.edu
TBSTATEDEMAIL=stoller@fast.cs.utah.edu
TBTESTSUITEEMAIL=stoller@fast.cs.utah.edu
WWW=www.emulab.net/dev/stoller
WWW=www.emulab.net/dev/leebee
THISHOMEBASE=Stoller.Emulab.Net
#
# EMULAB-COPYRIGHT
# Copyright (c) 2000-2006 University of Utah and the Flux Group.
# Copyright (c) 2000-2007 University of Utah and the Flux Group.
# All rights reserved.
#
......@@ -18,7 +18,7 @@ ifneq ($(SYSTEM),CYGWIN_NT-5.1)
SUBDIRS += trafgen
endif
ifeq ($(SYSTEM),FreeBSD)
SUBDIRS += sched delay-agent nsetrafgen stated
SUBDIRS += sched delay-agent stated
endif
all: etc-subdir trafgen-fetch all-subdirs
......
#
# EMULAB-COPYRIGHT
# Copyright (c) 2000-2004 University of Utah and the Flux Group.
# Copyright (c) 2000-2007 University of Utah and the Flux Group.
# All rights reserved.
#
......@@ -18,12 +18,12 @@ include $(TESTBED_SRCDIR)/GNUmakerules
#CFLAGS += -DDEBUG
CFLAGS += -O -g -Wall
CFLAGS += -I. -I${OBJDIR} -I$(SRCDIR)/../lib -I$(TESTBED_SRCDIR)/lib/libtb
CFLAGS += `elvin-config --cflags vin4c`
CFLAGS += -I/usr/local/include
LDFLAGS += -static
LDFLAGS += -L../lib -L${OBJDIR}/lib/libtb
LIBS += -levent -ltb -lcrypto
LIBS += `elvin-config --libs vin4c`
LIBS += -L/usr/local/lib -lpubsub -lm
OBJS = main.o callback.o
......
#
# EMULAB-COPYRIGHT
# Copyright (c) 2002-2006 University of Utah and the Flux Group.
# Copyright (c) 2002-2007 University of Utah and the Flux Group.
# All rights reserved.
#
......@@ -10,7 +10,7 @@ OBJDIR = ../..
SUBDIR = event/example
SYSTEM := $(shell uname -s)
PROGRAMS = tbrecv tbsend tbrecv.py tbsend.py eventdebug.pl dumpevsubs
PROGRAMS = tbrecv tbsend tbrecv.py tbsend.py eventdebug.pl
include $(OBJDIR)/Makeconf
......@@ -21,11 +21,11 @@ include $(TESTBED_SRCDIR)/GNUmakerules
CFLAGS += -DDEBUG
CFLAGS += -O -g -static -Wall
CFLAGS += -I. -I${OBJDIR} -I$(SRCDIR)/../lib -I$(TESTBED_SRCDIR)/lib/libtb
CFLAGS += `elvin-config --cflags vin4c`
CFLAGS += -I/usr/local/include
LDFLAGS += -static -L../lib -L${OBJDIR}/lib/libtb
LIBS += -levent -ltb -lcrypto
LIBS += `elvin-config --libs vin4c`
LIBS += -L/usr/local/lib -lpubsub -lm
ifeq ($(SYSTEM),Linux)
LIBS += -ldl
endif
......
......@@ -13,6 +13,7 @@
#include <ctype.h>
#include <netdb.h>
#include <unistd.h>
#include <string.h>
#include <sys/types.h>
#include <sys/time.h>
#include <sys/socket.h>
......
#
# EMULAB-COPYRIGHT
# Copyright (c) 2000-2006 University of Utah and the Flux Group.
# Copyright (c) 2000-2007 University of Utah and the Flux Group.
# All rights reserved.
#
......@@ -11,11 +11,20 @@ SUBDIR = event/lib
include $(OBJDIR)/Makeconf
PUBSUBFLAGS = -I/usr/local/include
PUBSUBMTFLAGS = -I/usr/local/include
PUBSUBLIB = /usr/local/lib/libpubsub.so
ifeq ($(ELVIN_COMPAT),1)
PUBSUBFLAGS += -DELVIN_COMPAT
PUBSUBMTFLAGS += -DELVIN_COMPAT
endif
SYSTEM := $(shell uname -s)
LIBS = libevent.a
SWIGLIBS =
# Re-entrant, multi-threaded version on FreeBSD, not on Linux or Windows clients.
ifeq ($(SYSTEM),FreeBSD)
ifneq ($(SYSTEM),CYGWIN_NT-5.1)
LIBS += libevent_r.a
SWIGLIBS += event.so _tbevent.so
endif
......@@ -30,11 +39,10 @@ PERLVERS := $(shell $(SRCDIR)/perlvers.pl)
#CFLAGS += -DDEBUG
CFLAGS += -O2 -g -static -I. -Wall
SCFLAGS = $(CFLAGS) `$(ELVIN_CONFIG) --cflags vin4c`
TCFLAGS = $(CFLAGS) `$(ELVIN_CONFIG) --cflags vin4mt`
SCFLAGS = $(CFLAGS) $(PUBSUBFLAGS)
TCFLAGS = $(CFLAGS) $(PUBSUBMTFLAGS)
# Special CFLAGS w/o warnings, for SWIG-generated code
CFLAGS_NOWARN += -O2 -g -static -I.
CFLAGS_NOWARN += `$(ELVIN_CONFIG) --cflags vin4c`
CFLAGS_NOWARN += -O2 -g -static -I. $(PUBSUBFLAGS)
ifeq ($(SYSTEM),Linux)
PCORE = -I/usr/lib/perl5/5.6.1/i386-linux/CORE
PCORE += -I/usr/lib/perl5/5.8.3/i386-linux-thread-multi/CORE
......@@ -113,10 +121,10 @@ event_wrap_py.o: $(SRCDIR)/event_wrap_py.c event.h
$(CC) -c $(CFLAGS_NOWARN) $(PYCORE) $<
event.so: event.o event_wrap.o util.o
ld -shared $^ `$(ELVIN_CONFIG) --libs vin4c` -lcrypto -o event.so
ld -shared $^ $(PUBSUBLIB) -lcrypto -o event.so
_tbevent.so: event.o event_wrap_py.o util.o
ld -shared $^ `$(ELVIN_CONFIG) --libs vin4c` -lcrypto -o $@
ld -shared $^ $(PUBSUBLIB) -lcrypto -o $@
LIB_STUFF = event.pm event.so tbevent.py _tbevent.so
......
/*
* EMULAB-COPYRIGHT
* Copyright (c) 2000-2006 University of Utah and the Flux Group.
* Copyright (c) 2000-2007 University of Utah and the Flux Group.
* All rights reserved.
*/
......@@ -9,6 +9,14 @@
*
* Testbed event library. Currently uses the Elvin publish/
* subscribe system for routing event notifications.
*
* TODO:
* check all pubsub_* call sites to get return value sense correct.
* make sure handle->status (and error args in general) is correct.
* make sure _t types are passed as pointers-to
* deal with hmac_traverse
* implement async_subscribe/unsubscribe in the pubsub code
* implement set_idle_period and set_failover in pubsub code
*/
#include <stdio.h>
......@@ -19,10 +27,15 @@
#include <netdb.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <sys/time.h>
#include <sys/param.h>
#include <time.h>
#include "event.h"
#ifdef ELVIN_COMPAT
#include <pubsub/elvin_hash.h>
#endif
#define ERROR(fmt,...) \
{ fputs(__FUNCTION__,stderr); fprintf(stderr,": " fmt, ## __VA_ARGS__); }
#define INFO(fmt,...) \
......@@ -129,14 +142,14 @@ event_register_withkeydata_withretry(char *name, int threaded,
unsigned char *keydata, int keylen,
int retrycount)
{
extern int pubsub_is_threaded[] __attribute__ ((weak));
event_handle_t handle;
elvin_handle_t server;
elvin_error_t status;
pubsub_handle_t *server;
struct hostent *he;
struct in_addr myip;
unsigned int o1, o2, o3, o4;
int scanres;
FILE *fp;
char *sstr = 0, *pstr = 0, *cp;
int port = PUBSUB_SERVER_PORTNUM;
if (gethostname(hostname, MAXHOSTNAMELEN) == -1) {
ERROR("could not get hostname: %s\n", strerror(errno));
......@@ -151,6 +164,10 @@ event_register_withkeydata_withretry(char *name, int threaded,
memcpy((char *)&myip, he->h_addr, he->h_length);
strcpy(ipaddr, inet_ntoa(myip));
} else {
unsigned int o1, o2, o3, o4;
int scanres;
FILE *fp;
ERROR("could not get IP address from hostname: %s, "
"reading IP from %s.\n", hostname, IPADDRFILE);
/* Try getting the node's ID from BOOTDIR/myip before giving up. */
......@@ -187,93 +204,58 @@ event_register_withkeydata_withretry(char *name, int threaded,
handle->keydata[keylen] = (unsigned char)0;
}
/* Set up the Elvin interface pointers: */
if (threaded) {
/* Set up the interface pointers: */
handle->connect = pubsub_connect;
handle->disconnect = pubsub_disconnect;
#ifdef THREADED
handle->init = elvin_threaded_init_default;
handle->connect = elvin_threaded_connect;
handle->disconnect = elvin_threaded_disconnect;
handle->cleanup = elvin_threaded_cleanup;
handle->mainloop = NULL; /* no mainloop for mt programs */
handle->notify = elvin_threaded_notify;
handle->subscribe = elvin_threaded_add_subscription;
handle->unsubscribe = elvin_threaded_delete_subscription;
assert(threaded == 1);
assert(pubsub_is_threaded != NULL);
handle->mainloop = NULL; /* no mainloop for mt programs */
#else
ERROR("Threaded API not linked in with the program!\n");
goto bad;
assert(threaded == 0);
assert(pubsub_is_threaded == NULL);
handle->mainloop = pubsub_mainloop;
#endif
} else {
handle->init = elvin_sync_init_default;
handle->connect = elvin_sync_connect;
handle->disconnect = elvin_sync_disconnect;
handle->cleanup = elvin_sync_cleanup;
handle->mainloop = elvin_sync_default_mainloop;
handle->notify = elvin_sync_notify;
handle->subscribe = elvin_sync_add_subscription;
handle->unsubscribe = elvin_sync_delete_subscription;
}
/* Initialize the elvin interface: */
status = handle->init();
if (status == NULL) {
ERROR("could not initialize Elvin\n");
goto bad;
}
server = elvin_handle_alloc(status);
if (server == NULL) {
ERROR("elvin_handle_alloc failed: ");
elvin_error_fprintf(stderr, status);
goto bad;
}
handle->notify = pubsub_notify;
handle->subscribe = pubsub_add_subscription;
handle->unsubscribe = pubsub_rem_subscription;
/* Set the discovery scope to "testbed", so that we only interact
with testbed elvin servers. */
if (elvin_handle_set_discovery_scope(server, "testbed", status) == 0) {
ERROR("elvin_handle_set_discovery_scope failed: ");
elvin_error_fprintf(stderr, status);
goto bad;
/* XXX parse server and port from "elvin://host:port" */
cp = strdup(name);
if (cp) {
sstr = strrchr(cp, '/');
}
/* Set the server URL, if we were passed one by the user. */
if (name) {
if (elvin_handle_append_url(server, name, status) == 0) {
ERROR("elvin_handle_append_url failed: ");
elvin_error_fprintf(stderr, status);
goto bad;
}
if (!sstr) {
ERROR("could not parse: %s", name);
goto bad;
}
/* set connection retries */
if (retrycount >= 0) {
if (elvin_handle_set_connection_retries(server, retrycount,
status) == 0) {
ERROR("elvin_handle_set_connection_retries failed: ");
elvin_error_fprintf(stderr, status);
goto bad;
}
*sstr++ = '\0';
pstr = strrchr(sstr, ':');
if (pstr) {
*pstr++ = '\0';
port = atoi(pstr);
}
/* Connect to the elvin server: */
if (handle->connect(server, status) == 0) {
ERROR("could not connect to Elvin server: ");
elvin_error_fprintf(stderr, status);
if (handle->connect(sstr, port, &server) != 0) {
ERROR("could not connect to Elvin server\n");
goto bad;
}
handle->server = server;
handle->status = status;
/*
* Keep track of how many handles we have outstanding
*/
handles_in_use++;
free(cp);
return handle;
bad:
if (handle->keydata)
free(handle->keydata);
free(handle);
free(cp);
return 0;
}
......@@ -293,35 +275,14 @@ event_unregister(event_handle_t handle)
TRACE("unregistering with event system (hostname=\"%s\")\n", hostname);
/* Disconnect from the elvin server: */
if (handle->disconnect(handle->server, handle->status) == 0) {
ERROR("could not disconnect from Elvin server: ");
elvin_error_fprintf(stderr, handle->status);
/* Disconnect from the server: */
if (handle->disconnect(handle->server) != 0) {
ERROR("could not disconnect from Pubsub server\n");
return 0;
}
TRACE("disconnect completed\n");
/* Clean up: */
if (elvin_handle_free(handle->server, handle->status) == 0) {
ERROR("elvin_handle_free failed: ");
elvin_error_fprintf(stderr, handle->status);
return 0;
}
TRACE("free completed\n");
if (handles_in_use == 1) {
if (handle->cleanup(1, handle->status) == 0) {
ERROR("could not clean up Elvin state: ");
elvin_error_fprintf(stderr, handle->status);
return 0;
}
TRACE("cleanup completed\n");
}
handles_in_use--;
if (handle->keydata)
......@@ -331,18 +292,30 @@ event_unregister(event_handle_t handle)
return 1;
}
/*
* Callback for event_poll timeout that just records that the timeout
* happened.
*/
static int
timeout_callback(pubsub_handle_t *handle, pubsub_timeout_t *timeout,
void *data, pubsub_error_t *error)
{
assert(data != 0);
assert(*(int *)data == 0);
*(int *)data = 1;
return 0;
}
/*
* An internal function to handle the two different event_poll calls, without
* making the library user mess around with arguments they don't care about.
*/
int
internal_event_poll(event_handle_t handle, int blocking, unsigned int timeout)
{
extern int depth;
int rv;
elvin_timeout_t elvin_timeout = NULL;
int rv, triggered = 0;
pubsub_timeout_t *pubsub_timeout = NULL;
if (!handle->mainloop) {
ERROR("multithreaded programs cannot use event_poll\n");
......@@ -355,41 +328,42 @@ internal_event_poll(event_handle_t handle, int blocking, unsigned int timeout)
* actually do anything.
*/
if (timeout) {
elvin_timeout = elvin_sync_add_timeout(NULL, timeout, NULL,
NULL, handle->status);
if (!elvin_timeout) {
ERROR("Elvin elvin_sync_add_timeout failed\n");
elvin_error_fprintf(stderr, handle->status);
return elvin_error_get_code(handle->status);
pubsub_timeout = pubsub_add_timeout(handle->server, NULL,
timeout,
timeout_callback,
(void *)&triggered,
&handle->status);
if (!pubsub_timeout) {
ERROR("Elvin pubsub_sync_add_timeout failed\n");
pubsub_error_fprintf(stderr, &handle->status);
return pubsub_error_get_code(&handle->status);
}
}
depth++;
rv = elvin_sync_default_select_and_dispatch(blocking, handle->status);
depth--;
if (rv == 0) {
ERROR("Elvin select_and_dispatch failed\n");
elvin_error_fprintf(stderr, handle->status);
rv = pubsub_dispatch(handle->server, blocking, &handle->status);
if (rv != 0) {
ERROR("Pubsub dispatcher failed\n");
pubsub_error_fprintf(stderr, &handle->status);
}
/* rv = pubsub_error_get_code(&handle->status); */
/*
* Try to remove the timeout - if it didn't go off, we don't want to
* hit it later. We don't check the return value, since, if it did go
* off (and we don't really have a good way of knowing that), it's not
* there any more, so it looks like an error.
*/
if (timeout && elvin_timeout) {
elvin_error_t error;
elvin_sync_remove_timeout(elvin_timeout, error);
}
if (timeout && pubsub_timeout && !triggered)
pubsub_remove_timeout(handle->server, pubsub_timeout,
&handle->status);
return elvin_error_get_code(handle->status);
return rv;
}
/*
* A non-blocking poll of the event system
* A non-blocking poll of the event system.
* XXX not an actual poll, rather a "dispatch at most once".
*/
int
event_poll(event_handle_t handle)
{
......@@ -398,8 +372,8 @@ event_poll(event_handle_t handle)
/*