o Fix my HAVE_KQUEUE support bugs.

o Add support `service flare[id] reload'.
o Sleep until flarei daemon starting.
  To disable flarei_sleepwait="0" to /etc/rc.conf.
This commit is contained in:
Norikatsu Shigemura 2010-05-30 15:05:18 +00:00
parent c8d9eb10e5
commit 904936bbb0
Notes: svn2git 2021-03-31 03:12:20 +00:00
svn path=/head/; revision=255324
4 changed files with 32 additions and 13 deletions

View file

@ -7,7 +7,7 @@
PORTNAME= flare
PORTVERSION= 1.0.9
PORTREVISION= 1
PORTREVISION= 2
CATEGORIES= databases
MASTER_SITES= http://labs.gree.jp/data/source/
EXTRACT_SUFX= .tgz
@ -22,8 +22,7 @@ LICENSE= GPLv2
LICENSE_FILE= ${WRKSRC}/COPYING
GNU_CONFIGURE= yes
# There is a stability and performance issue, so temporary disabled HAVE_KQUEUE.
CONFIGURE_ENV= CPPFLAGS="-I${LOCALBASE}/include" LDFLAGS=-L${LOCALBASE}/lib
CONFIGURE_ENV= CPPFLAGS="-I${LOCALBASE}/include -DHAVE_KQUEUE" LDFLAGS=-L${LOCALBASE}/lib
USE_RC_SUBR= flared.sh flarei.sh
SUB_FILES= pkg-message

View file

@ -16,6 +16,8 @@ name=flared
rcvar=`set_rcvar`
command=%%PREFIX%%/bin/${name}
extra_commands="reload"
load_rc_config ${name}
case "${flared_flags}" in

View file

@ -10,6 +10,7 @@ flarei_enable=${flarei_enable-"NO"}
flarei_config=${flarei_conffile-"%%PREFIX%%/etc/flarei.conf"}
flarei_pidfile=${flarei_pidfile-"/var/run/flarei.pid"}
flarei_flags="--daemonize"
flarei_sleepwait="2"
. /etc/rc.subr
@ -17,6 +18,13 @@ name=flarei
rcvar=`set_rcvar`
command=%%PREFIX%%/bin/${name}
extra_commands="reload"
start_postcmd="flarei_poststart"
flarei_poststart () {
sleep "${flarei_sleepwait}"
}
load_rc_config ${name}
case "${flarei_flags}" in

View file

@ -1,5 +1,5 @@
--- src/lib/server.cc.orig 2009-10-09 19:08:47.000000000 +0900
+++ src/lib/server.cc 2010-05-30 06:10:23.363742550 +0900
+++ src/lib/server.cc 2010-05-30 23:58:14.924160278 +0900
@@ -21,6 +21,9 @@
#ifdef HAVE_EPOLL
_epoll_socket(0),
@ -51,27 +51,37 @@
return 0;
}
@@ -208,6 +231,10 @@
@@ -204,10 +227,14 @@
vector<shared_connection> server::wait() {
vector<shared_connection> connection_list;
-#ifdef HAVE_EPOLL
+#if defined(HAVE_EPOLL)
const char* poll_type = "epoll_wait"; // just for logging
struct epoll_event ev_list[this->max_listen_socket];
int n = epoll_wait(this->_epoll_socket, ev_list, this->max_listen_socket, -1);
+#elifdef HAVE_KQUEUE
+#elif defined(HAVE_KQUEUE)
+ const char* poll_type = "kqueue_wait"; // just for logging
+ struct kevent kev;
+ int n = kevent(this->_kqueue_socket, &kev, 1, NULL, 0, NULL);
+ struct kevent kev[this->max_listen_socket];
+ int n = kevent(this->_kqueue_socket, NULL, 0, kev, this->max_listen_socket, NULL);
#else
const char* poll_type = "select"; // just for logging
fd_set fds;
@@ -230,6 +257,8 @@
#ifdef HAVE_EPOLL
@@ -227,9 +254,12 @@
}
// accpet anyway
-#ifdef HAVE_EPOLL
+#if defined(HAVE_EPOLL)
for (int i = 0; i < n; i++) {
int listen_socket = ev_list[i].data.fd;
+#elifdef HAVE_KQUEUE
+ int listen_socket = kev.ident;
+#elif defined(HAVE_KQUEUE)
+ for (int i = 0; i < n; i++) {
+ int listen_socket = kev[i].ident;
#else
for (int i = 0; i < this->_listen_socket_index; i++) {
if (!FD_ISSET(this->_listen_socket[i], &fds)) {
@@ -369,6 +398,32 @@
@@ -369,6 +399,32 @@
return 0;
}
#endif