Hello community,
here is the log from the commit of package pen
checked in at Fri Aug 25 15:01:28 CEST 2006.
--------
--- pen/pen.changes 2006-01-25 21:39:25.000000000 +0100
+++ pen/pen.changes 2006-08-25 14:09:36.000000000 +0200
@@ -1,0 +2,8 @@
+Fri Aug 25 13:43:40 CEST 2006 - joe@suse.de
+
+- update to version 0.17.1
+
+- bugfix: server_by_weight would never consider blacklisted
+ servers, which kept them blacklisted indefinitely
+
+-------------------------------------------------------------------
Old:
----
pen-0.16.0.tar.bz2
New:
----
pen-0.17.1.tar.bz2
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Other differences:
------------------
++++++ pen.spec ++++++
--- /var/tmp/diff_new_pack.5Qj1r7/_old 2006-08-25 15:01:10.000000000 +0200
+++ /var/tmp/diff_new_pack.5Qj1r7/_new 2006-08-25 15:01:10.000000000 +0200
@@ -1,11 +1,11 @@
#
-# spec file for package pen (Version 0.16.0)
+# spec file for package pen (Version 0.17.1)
#
-# Copyright (c) 2005 SUSE LINUX Products GmbH, Nuernberg, Germany.
+# Copyright (c) 2006 SUSE LINUX Products GmbH, Nuernberg, Germany.
# This file and all modifications and additions to the pristine
# package are under the same license as the package itself.
#
-# Please submit bugfixes or comments via http://bugs.opensuse.org
+# Please submit bugfixes or comments via http://bugs.opensuse.org/
#
# norootforbuild
@@ -15,7 +15,7 @@
Group: Productivity/Clustering/HA
Summary: A simple load balancer for tcp based protocols
URL: http://siag.nu/pen/
-Version: 0.16.0
+Version: 0.17.1
Release: 1
Source0: %{name}-%{version}.tar.bz2
Source1: %{name}.cfg
@@ -105,6 +105,10 @@
%config(noreplace) /etc/%{name}.cfg
%changelog -n pen
+* Fri Aug 25 2006 - joe@suse.de
+- update to version 0.17.1
+- bugfix: server_by_weight would never consider blacklisted
+ servers, which kept them blacklisted indefinitely
* Wed Jan 25 2006 - mls@suse.de
- converted neededforbuild to BuildRequires
* Fri Dec 16 2005 - joe@suse.de
++++++ pen-0.16.0.tar.bz2 -> pen-0.17.1.tar.bz2 ++++++
diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore old/pen-0.16.0/ChangeLog new/pen-0.17.1/ChangeLog
--- old/pen-0.16.0/ChangeLog 2005-12-15 11:42:23.000000000 +0100
+++ new/pen-0.17.1/ChangeLog 2006-06-27 09:34:49.000000000 +0200
@@ -1,4 +1,12 @@
+060627 Bugfix by Chris Elsworth: server_by_weight would never
+ consider blacklisted servers, which kept them blacklisted
+ indefinitely.
+
+051230 Added code by Chris Elsworth for kqueue support. Configure
+ with --with-kqueue to enable.
+ Released 0.17.0.
+
051215 Changed the configure option for ssl to
--with-experimental-only-ssl.
Released 0.16.0.
diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore old/pen-0.16.0/INSTALL new/pen-0.17.1/INSTALL
--- old/pen-0.16.0/INSTALL 2005-12-15 11:41:43.000000000 +0100
+++ new/pen-0.17.1/INSTALL 2005-12-30 11:02:09.000000000 +0100
@@ -27,6 +27,11 @@
is ready for reading or writing. This option enables an alternative method,
using the poll() function. THIS IS CURRENTLY EXPERIMENTAL!
+ --with-kqueue use kqueue() if available
+
+The kqueue interface for event notification is available on *bsd
+and offers better performance than either select() or poll().
+
--with-experimental-only-ssl=DIR use SSL (default /usr/local/ssl)
Another experimental feature, which allows Pen to be built with
diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore old/pen-0.16.0/config.h.in new/pen-0.17.1/config.h.in
--- old/pen-0.16.0/config.h.in 2005-12-15 11:42:56.000000000 +0100
+++ new/pen-0.17.1/config.h.in 2006-06-24 11:46:12.000000000 +0200
@@ -16,6 +16,9 @@
/* Define to 1 if you have the header file. */
#undef HAVE_INTTYPES_H
+/* #undef HAVE_KQUEUE */
+#undef HAVE_KQUEUE
+
/* Define to 1 if you have the `nsl' library (-lnsl). */
#undef HAVE_LIBNSL
diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore old/pen-0.16.0/configure new/pen-0.17.1/configure
--- old/pen-0.16.0/configure 2005-12-15 11:42:35.000000000 +0100
+++ new/pen-0.17.1/configure 2006-06-24 11:16:40.000000000 +0200
@@ -854,6 +854,7 @@
--without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no)
--with-daemon use daemon() if available
--with-poll use poll() if available
+ --with-kqueue use kqueue() if available
--with-fd_setsize=N set FD_SETSIZE to N (see INSTALL)
--with-experimental-only-ssl=DIR use SSL (default /usr/local/ssl)
--with-docdir=DIR install docs in DIR [PREFIX/doc/pen]
@@ -1615,7 +1616,7 @@
# Define the identity of the package.
PACKAGE=pen
- VERSION=0.16.0
+ VERSION=0.17.1
cat >>confdefs.h <<_ACEOF
@@ -4969,6 +4970,111 @@
fi
fi;
+# Check whether --with-kqueue or --without-kqueue was given.
+if test "${with_kqueue+set}" = set; then
+ withval="$with_kqueue"
+ if test "$withval" != "no"; then
+ echo "$as_me:$LINENO: checking for kqueue" >&5
+echo $ECHO_N "checking for kqueue... $ECHO_C" >&6
+if test "${ac_cv_func_kqueue+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+/* Define kqueue to an innocuous variant, in case declares kqueue.
+ For example, HP-UX 11i declares gettimeofday. */
+#define kqueue innocuous_kqueue
+
+/* System header to define __stub macros and hopefully few prototypes,
+ which can conflict with char kqueue (); below.
+ Prefer to if __STDC__ is defined, since
+ exists even on freestanding compilers. */
+
+#ifdef __STDC__
+# include
+#else
+# include
+#endif
+
+#undef kqueue
+
+/* Override any gcc2 internal prototype to avoid an error. */
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+/* We use char because int might match the return type of a gcc2
+ builtin and then its argument prototype would still apply. */
+char kqueue ();
+/* The GNU C library defines this for functions which it implements
+ to always fail with ENOSYS. Some functions are actually named
+ something starting with __ and the normal name is an alias. */
+#if defined (__stub_kqueue) || defined (__stub___kqueue)
+choke me
+#else
+char (*f) () = kqueue;
+#endif
+#ifdef __cplusplus
+}
+#endif
+
+int
+main ()
+{
+return f != kqueue;
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+ (eval $ac_link) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_c_werror_flag"
+ || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest$ac_exeext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ ac_cv_func_kqueue=yes
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_cv_func_kqueue=no
+fi
+rm -f conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+fi
+echo "$as_me:$LINENO: result: $ac_cv_func_kqueue" >&5
+echo "${ECHO_T}$ac_cv_func_kqueue" >&6
+if test $ac_cv_func_kqueue = yes; then
+
+cat >>confdefs.h <<\_ACEOF
+#define HAVE_KQUEUE 1
+_ACEOF
+
+fi
+
+ fi
+fi;
+
# Check whether --with-fd_setsize or --without-fd_setsize was given.
if test "${with_fd_setsize+set}" = set; then
withval="$with_fd_setsize"
diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore old/pen-0.16.0/configure.in new/pen-0.17.1/configure.in
--- old/pen-0.16.0/configure.in 2005-12-15 11:40:51.000000000 +0100
+++ new/pen-0.17.1/configure.in 2006-06-24 11:16:25.000000000 +0200
@@ -2,7 +2,7 @@
AC_INIT
AC_CONFIG_SRCDIR([README])
AM_CONFIG_HEADER(config.h)
-AM_INIT_AUTOMAKE(pen, 0.16.0)
+AM_INIT_AUTOMAKE(pen, 0.17.1)
dnl Checks for programs.
AC_PROG_CC
@@ -52,6 +52,12 @@
AC_CHECK_FUNC(poll,
AC_DEFINE([HAVE_POLL], 1, [#undef HAVE_POLL]))
fi ])
+AC_ARG_WITH(kqueue,
+ [ --with-kqueue use kqueue() if available],
+ [ if test "$withval" != "no"; then
+ AC_CHECK_FUNC(kqueue,
+ AC_DEFINE([HAVE_KQUEUE], 1, [#undef HAVE_KQUEUE]))
+ fi ])
AC_ARG_WITH(fd_setsize,
[ --with-fd_setsize=N set FD_SETSIZE to N (see INSTALL)],
[ if test "$withval" != "no"; then
diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore old/pen-0.16.0/pen.1 new/pen-0.17.1/pen.1
--- old/pen-0.16.0/pen.1 2005-11-02 20:39:59.000000000 +0100
+++ new/pen-0.17.1/pen.1 2005-12-30 11:00:10.000000000 +0100
@@ -76,6 +76,12 @@
-H
Adds X-Forwarded-For header to http requests.
.TP
+-P
+Use poll() for event notification.
+.TP
+-Q
+Use kqueue() for event notification (BSD).
+.TP
-W
Use weight for server selection.
.TP
diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore old/pen-0.16.0/pen.c new/pen-0.17.1/pen.c
--- old/pen-0.16.0/pen.c 2005-12-15 11:03:19.000000000 +0100
+++ new/pen-0.17.1/pen.c 2006-06-24 11:11:48.000000000 +0200
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2000-2005 Ulric Eriksson
+ Copyright (C) 2000-2006 Ulric Eriksson
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -42,6 +42,9 @@
#ifdef HAVE_POLL
#include
#endif /* HAVE_POLL */
+#ifdef HAVE_KQUEUE
+#include
+#endif
#include
#include
#include
@@ -84,6 +87,9 @@
int downn, upn;
int clt;
int index; /* server index */
+#ifdef HAVE_KQUEUE
+ int i; /* connection index */
+#endif
#ifdef HAVE_SSL
SSL *ssl;
#endif
@@ -149,6 +155,7 @@
static int do_stats = 0;
static int do_restart_log = 0;
static int use_poll = 0;
+static int use_kqueue = 0;
static int http = 0;
static int client_acl, control_acl;
@@ -1049,6 +1056,13 @@
#endif
conns[i].clt = clt;
conns[i].index = index;
+#ifdef HAVE_KQUEUE
+ /* kqueue can store a pointer to arbitrary data with each
+ * event, but it must be a pointer. We store a pointer to
+ * conns[i]. copy_up/down then require i again, which we
+ * can't get without storing i within the struct itself. */
+ conns[i].i = i;
+#endif
current = index;
} else {
if (debuglevel)
@@ -1281,7 +1295,7 @@
return -1;
}
upfd = socket(AF_INET, SOCK_STREAM, 0);
- if (upfd < 0) error("Error opening socket");
+ if (upfd < 0) error("Error opening socket: %d", errno);
memset(&serv_addr, 0, sizeof serv_addr);
serv_addr.sin_family = AF_INET;
serv_addr.sin_addr.s_addr = servers[index].addr.s_addr;
@@ -1721,10 +1735,11 @@
int best_server = -1;
int best_load = -1;
int i, load;
+ int now = (int)time(NULL);
if (debuglevel) debug("server_by_weight()");
for (i = 0; i < nservers; i++) {
- if (servers[i].status != 0 || servers[i].weight == 0) {
+ if (now-servers[i].status < blacklist_time || servers[i].weight == 0) {
continue;
}
load = servers[i].c/servers[i].weight;
@@ -2263,15 +2278,220 @@
}
#endif /* HAVE_POLL */
+#ifdef HAVE_KQUEUE
+
+static void dump_kevent(struct kevent *kev, int nfds)
+{
+ int i;
+ struct kevent *kptr;
+ for (i = 0; i < nfds; i++) {
+ kptr = &kev[i];
+ debug("kev[%d]: ", i,
+ kptr->ident, kptr->filter, kptr->flags,
+ kptr->fflags, kptr->data, kptr->udata);
+ }
+
+}
+
+static void mainloop_kqueue(void)
+{
+ int downfd, clilen;
+ int kq;
+ struct kevent *kev, *kptr;
+ connection *conn;
+ struct sockaddr_in cli_addr;
+ int i, j, nfds;
+ short downevents, upevents;
+
+ loopflag = 1;
+
+ kq = kqueue();
+ if (kq == -1)
+ {
+ perror("kqueue");
+ error("Error creating kernel queue");
+ }
+
+ kev = pen_malloc((connections_max*2+2)*sizeof *kev);
+
+ if (debuglevel) debug("mainloop_kqueue()");
+ while (loopflag) {
+ int n;
+
+ if (do_stats) {
+ if (webfile) webstats();
+ else textstats();
+ do_stats=0;
+ }
+ if (do_restart_log) {
+ if (logfp) {
+ fclose(logfp);
+ logfp = fopen(logfile, "a");
+ if (!logfp)
+ error("Can't open logfile %s", logfile);
+ }
+ read_cfg(cfgfile);
+ do_restart_log=0;
+ }
+ kptr = kev;
+ nfds = 0;
+
+ /* FIXME: these two don't need to be done every loop;
+ * they'll persist until the sockets are closed. But moving
+ * them outside the loop adds complications (kptr initial
+ * setting etc) */
+ EV_SET(kptr++, listenfd, EVFILT_READ, EV_ADD, 0, 0, 0);
+ nfds++;
+ if (ctrlfd != -1) {
+ EV_SET(kptr++, ctrlfd, EVFILT_READ, EV_ADD, 0, 0, 0);
+ nfds++;
+ }
+
+ /* add sockets from open connections */
+ if (debuglevel) debug("filling kqueue structure");
+ for (i = 0; i < connections_max; i++) {
+ if (conns[i].downfd == -1) continue;
+ upevents = downevents = 0;
+
+ if (conns[i].upn == 0)
+ {
+ EV_SET(kptr++, conns[i].downfd, EVFILT_READ,
+ EV_ADD | EV_ONESHOT, 0, 0, &conns[i]);
+ nfds++;
+ }
+ else
+ {
+ EV_SET(kptr++, conns[i].upfd, EVFILT_WRITE,
+ EV_ADD | EV_ONESHOT, 0, 0, &conns[i]);
+ nfds++;
+ }
+
+ if (conns[i].downn == 0)
+ {
+ EV_SET(kptr++, conns[i].upfd, EVFILT_READ,
+ EV_ADD | EV_ONESHOT, 0, 0, &conns[i]);
+ nfds++;
+ }
+ else
+ {
+ EV_SET(kptr++, conns[i].downfd, EVFILT_WRITE,
+ EV_ADD | EV_ONESHOT, 0, 0, &conns[i]);
+ nfds++;
+ }
+ }
+
+ if (debuglevel) dump_kevent(kev, nfds);
+
+ /* Wait for a connection from a client process. */
+ n = kevent(kq, kev, nfds, kev, nfds, NULL);
+ if (debuglevel) debug("n = %d", n);
+ if (n < 0 && errno != EINTR) {
+ perror("kevent");
+ error("Error on kevent");
+ }
+ if (n <= 0) continue;
+
+ if (debuglevel) debug("checking kqueue structure");
+ if (debuglevel) dump_kevent(kev, n);
+
+ for(j = 0 ; j < n ; j++)
+ {
+ kptr = &kev[j];
+
+ /* check listener */
+ if (kptr->ident == listenfd)
+ {
+ clilen = sizeof cli_addr;
+ downfd = accept(listenfd,
+ (struct sockaddr *) &cli_addr, &clilen);
+ if (downfd < 0) {
+ if (debuglevel) perror("accept");
+ continue;
+ }
+ if (clilen == 0) {
+ if (debuglevel) perror("clilen");
+ continue;
+ }
+ add_client(downfd, &cli_addr);
+ continue;
+ }
+
+ /* check control port */
+ if (ctrlfd != -1 && kptr->ident == ctrlfd)
+ {
+ clilen = sizeof cli_addr;
+ downfd = accept(ctrlfd,
+ (struct sockaddr *) &cli_addr, &clilen);
+ if (downfd < 0) {
+ if (debuglevel) perror("accept");
+ continue;
+ }
+ if (clilen == 0) {
+ if (debuglevel) perror("clilen");
+ continue;
+ }
+ do_ctrl(downfd, &cli_addr);
+ continue;
+ }
+
+ /* check sockets from open connections */
+ conn = (connection *)kptr->udata;
+ if (conn->downfd == -1) continue;
+
+ if (conn->downfd != kptr->ident)
+ downevents = 0;
+ else
+ downevents = kptr->filter;
+
+ if (conn->upfd != kptr->ident)
+ upevents = 0;
+ else
+ upevents = kptr->filter;
+
+ i = conn->i;
+ if (debuglevel) {
+ debug("conn = %d, upevents = %d, downevents = %d",
+ i, upevents, downevents);
+ }
+
+ if (downevents == EVFILT_READ) {
+ if (copy_up(i) < 0) {
+ close_conn(i);
+ continue;
+ }
+ }
+ if (upevents == EVFILT_READ) {
+ if (copy_down(i) < 0) {
+ close_conn(i);
+ continue;
+ }
+ }
+ if (downevents == EVFILT_WRITE) {
+ if (flush_down(i) < 0) {
+ close_conn(i);
+ continue;
+ }
+ }
+ if (upevents == EVFILT_WRITE) {
+ if (flush_up(i) < 0) {
+ close_conn(i);
+ continue;
+ }
+ }
+ }
+ }
+}
+#endif /* HAVE_KQUEUE */
+
static int options(int argc, char **argv)
{
int c;
char b[1024];
#ifdef HAVE_SSL
- char *opt = "B:C:F:S:T:b:c:e:j:l:o:p:t:u:w:x:DHPWXadfhnrsE:K:G:A:ZRL:";
+ char *opt = "B:C:F:S:T:b:c:e:j:l:o:p:t:u:w:x:DHPQWXadfhnrsE:K:G:A:ZRL:";
#else
- char *opt = "B:C:F:S:T:b:c:e:j:l:o:p:t:u:w:x:DHPWXadfhnrs";
+ char *opt = "B:C:F:S:T:b:c:e:j:l:o:p:t:u:w:x:DHPQWXadfhnrs";
#endif
while ((c = getopt(argc, argv, opt)) != -1) {
@@ -2291,6 +2511,9 @@
case 'H':
http = 1;
break;
+ case 'Q':
+ use_kqueue = 1;
+ break;
case 'P':
use_poll = 1;
break;
@@ -2482,12 +2705,19 @@
fclose(pidfp);
}
+#ifdef HAVE_KQUEUE
+ if (use_kqueue) mainloop_kqueue();
+#else
+ if (use_kqueue) error("You don't have kqueue()");
+#endif /* HAVE_KQUEUE */
+
#ifdef HAVE_POLL
if (use_poll) mainloop_poll();
#else
if (use_poll) error("You don't have poll()");
#endif /* HAVE_POLL */
- if (!use_poll) mainloop_select();
+
+ if (!use_kqueue && !use_poll) mainloop_select();
if (debuglevel) debug("Exiting, cleaning up...");
if (logfp) fclose(logfp);
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Remember to have fun...
---------------------------------------------------------------------
To unsubscribe, e-mail: opensuse-commit+unsubscribe@opensuse.org
For additional commands, e-mail: opensuse-commit+help@opensuse.org