mirror of
https://gitee.com/acl-dev/acl.git
synced 2024-12-03 20:38:11 +08:00
commit
497fb467ba
45
Makefile
45
Makefile
@ -12,14 +12,17 @@ RANLIB = ${ENV_RANLIB}
|
||||
OSNAME = $(shell uname -a)
|
||||
OSTYPE = $(shell uname -a)
|
||||
|
||||
LIB_PATH = ./dist/lib
|
||||
DESTDIR =
|
||||
PREFIX = /usr
|
||||
BIN_PATH = $(DESTDIR)/usr/bin/
|
||||
LIB_PATH = $(DESTDIR)/usr/lib
|
||||
ACL_LIB = $(LIB_PATH)
|
||||
PROTO_LIB = $(LIB_PATH)
|
||||
DICT_LIB = $(LIB_PATH)
|
||||
TLS_LIB = $(LIB_PATH)
|
||||
|
||||
INC_PATH = ./dist/include
|
||||
ACL_INC = $(INC_PATH)/acl
|
||||
INC_PATH = $(DESTDIR)/usr/include
|
||||
ACL_INC = $(INC_PATH)/acl-lib
|
||||
PROTO_INC = $(INC_PATH)/protocol
|
||||
DICT_INC = $(INC_PATH)/dict
|
||||
TLS_INC = $(INC_PATH)/tls
|
||||
@ -78,6 +81,7 @@ ifeq ($(findstring SunOS, $(OSNAME)), SunOS)
|
||||
endif
|
||||
SYSLIB += -liconv
|
||||
endif
|
||||
|
||||
##############################################################################
|
||||
|
||||
.PHONY = check help all_lib all samples all clean install uninstall uninstall_all build_bin build_src build_one
|
||||
@ -115,10 +119,29 @@ clean:
|
||||
@(cd unit_test; make clean)
|
||||
@(cd lib_acl/samples; make clean)
|
||||
@(cd lib_protocol/samples; make clean)
|
||||
@(rm -f libacl.a libacl.so)
|
||||
@(rm -f libacl_all.a libacl.so)
|
||||
# @(cd lib_dict; make clean)
|
||||
# @(cd lib_tls; make clean)
|
||||
|
||||
packinstall:
|
||||
@(echo "")
|
||||
@(echo "begin copy file...")
|
||||
$(shell mkdir -p $(ACL_INC)/acl)
|
||||
$(shell mkdir -p $(ACL_INC)/acl_cpp)
|
||||
$(shell mkdir -p $(BIN_PATH)/)
|
||||
$(shell mkdir -p $(LIB_PATH)/)
|
||||
$(shell mkdir -p $(DESTDIR)/opt/soft/acl-master/)
|
||||
cp -f lib_acl/master/acl_master ./dist/master/libexec/$(RPATH)/
|
||||
(cd dist/master && ./setup.sh $(DESTDIR) /opt/soft/acl-master)
|
||||
cp -f lib_acl/master/acl_master $(BIN_PATH)
|
||||
cp -Rf lib_acl/include/* $(ACL_INC)/acl/
|
||||
cp -Rf lib_acl_cpp/include/acl_cpp/* $(ACL_INC)/acl_cpp/
|
||||
cp -f libacl_all.a $(ACL_LIB)/libacl_all.a
|
||||
#cp -Rf lib_protocol/include/* $(PROTO_INC)/
|
||||
# cp -f lib_dict/lib/lib_dict.a $(DICT_LIB)/$(RPATH)/
|
||||
# cp -Rf lib_dict/include/* $(DICT_INC)/
|
||||
# cp -f lib_tls/lib/lib_tls.a $(TLS_LIB)/$(RPATH)/
|
||||
# cp -Rf lib_tls/include/* $(TLS_INC)/
|
||||
install:
|
||||
@(echo "")
|
||||
@(echo "begin copy file...")
|
||||
@ -126,7 +149,7 @@ install:
|
||||
$(shell mkdir -p $(PROTO_INC))
|
||||
$(shell mkdir -p $(INC_PATH)/acl_cpp)
|
||||
cp -f lib_acl/master/acl_master ./dist/master/libexec/$(RPATH)/
|
||||
cp -f lib_acl/lib/libacl.a $(ACL_LIB)/$(RPATH)/
|
||||
cp -f lib_acl/lib/libacl_all.a $(ACL_LIB)/$(RPATH)/
|
||||
cp -Rf lib_acl/include/* $(ACL_INC)/
|
||||
cp -f lib_protocol/lib/libprotocol.a $(PROTO_LIB)/$(RPATH)/
|
||||
cp -Rf lib_protocol/include/* $(PROTO_INC)/
|
||||
@ -268,15 +291,19 @@ build_one: all_lib
|
||||
@(cd $(RELEASE_PATH)/acl; ar -x libacl.a)
|
||||
@(cd $(RELEASE_PATH)/protocol; ar -x libprotocol.a)
|
||||
@(cd $(RELEASE_PATH)/acl_cpp; ar -x libacl_cpp.a)
|
||||
$(AR) $(ARFL) ./libacl.a $(RELEASE_PATH)/acl/*.o \
|
||||
$(AR) $(ARFL) ./libacl_all.a $(RELEASE_PATH)/acl/*.o \
|
||||
$(RELEASE_PATH)/protocol/*.o $(RELEASE_PATH)/acl_cpp/*.o
|
||||
$(RANLIB) ./libacl.a
|
||||
$(CC) $(LDFLAGS) -o ./libacl.so $(RELEASE_PATH)/acl_cpp/*.o \
|
||||
$(RANLIB) ./libacl_all.a
|
||||
rm -f libacl.a
|
||||
ln -s libacl_all.a libacl.a
|
||||
$(CC) $(LDFLAGS) -o ./libacl_all.so $(RELEASE_PATH)/acl_cpp/*.o \
|
||||
$(RELEASE_PATH)/protocol/*.o $(RELEASE_PATH)/acl/*.o \
|
||||
$(SYSLIB)
|
||||
rm -f libacl.so
|
||||
ln -s libacl_all.so libacl.so
|
||||
@(rm -rf $(RELEASE_PATH))
|
||||
@echo ""
|
||||
@echo "Over, libacl.a and libacl.so were built ok!"
|
||||
@echo "Over, libacl_all.a and libacl_all.so were built ok!"
|
||||
@echo ""
|
||||
|
||||
check:
|
||||
|
3
circle.yml
Normal file
3
circle.yml
Normal file
@ -0,0 +1,3 @@
|
||||
test:
|
||||
override:
|
||||
- make build_one
|
146
dist/master/init.d/master
vendored
Executable file
146
dist/master/init.d/master
vendored
Executable file
@ -0,0 +1,146 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
#set -x
|
||||
# acl_master Start/Stop the acl_master daemon.
|
||||
#
|
||||
# chkconfig: 2345 90 60
|
||||
# description: acl master framework
|
||||
|
||||
### BEGIN INIT INFO
|
||||
# Provides: acl_master crontab
|
||||
# Required-Start: $local_fs $syslog
|
||||
# Required-Stop: $local_fs $syslog
|
||||
# Default-Start: 2345
|
||||
# Default-Stop: 90
|
||||
# Short-Description: acl - master framework to control services
|
||||
|
||||
### END INIT INFO
|
||||
|
||||
RETVAL=0
|
||||
prog="acl_master"
|
||||
HOME_PATH={install_path}
|
||||
exec=$HOME_PATH/libexec/acl_master
|
||||
PROG_NAME=acl_master
|
||||
PID_FILE=$HOME_PATH/var/pid/acl_master.pid
|
||||
EXE_PATH=$HOME_PATH/libexec/$PROG_NAME
|
||||
CONF_PATH=$HOME_PATH/conf
|
||||
LOG_PATH=$HOME_PATH/var/log/acl_master
|
||||
|
||||
lockfile=/var/lock/subsys/acl_master
|
||||
|
||||
# Source function library.
|
||||
. /etc/rc.d/init.d/functions
|
||||
|
||||
|
||||
# A function to find the pid of a program. Looks *only* at the pidfile
|
||||
findpidfileofproc() {
|
||||
local pid
|
||||
|
||||
# Test syntax.
|
||||
if [ "$#" = 0 ] ; then
|
||||
echo $"Usage: pidfileofproc {program}"
|
||||
return 1
|
||||
fi
|
||||
|
||||
__pids_var_run "$1" "$2"
|
||||
[ -n "$pid" ] && echo $pid
|
||||
return 0
|
||||
}
|
||||
|
||||
start() {
|
||||
if [ $UID -ne 0 ] ; then
|
||||
echo "User has insufficient privilege."
|
||||
exit 4
|
||||
fi
|
||||
[ -x $exec ] || exit 5
|
||||
echo -n $"Starting $prog: "
|
||||
daemon $prog -c $CONF_PATH -l $LOG_PATH &
|
||||
sleep 1
|
||||
rh_status_q && success
|
||||
echo
|
||||
retval=$?
|
||||
[ $retval -eq 0 ] && touch $lockfile
|
||||
return $retval
|
||||
}
|
||||
|
||||
stop() {
|
||||
if [ $UID -ne 0 ] ; then
|
||||
echo "User has insufficient privilege."
|
||||
exit 4
|
||||
fi
|
||||
echo -n $"Stopping $prog: "
|
||||
if [ -n "`findpidfileofproc $exec $PID_FILE`" ]; then
|
||||
killproc -p $PID_FILE -d 3 $exec
|
||||
RETVAL=3
|
||||
else
|
||||
failure $"Stopping $prog"
|
||||
fi
|
||||
retval=$?
|
||||
echo
|
||||
[ $retval -eq 0 ] && rm -f $lockfile
|
||||
return $retval
|
||||
}
|
||||
|
||||
restart() {
|
||||
stop
|
||||
start
|
||||
}
|
||||
|
||||
reload() {
|
||||
echo -n $"Reloading $prog: "
|
||||
if [ -n "`findpidfileofproc $exec $PID_FILE`" ]; then
|
||||
killproc $exec -HUP
|
||||
else
|
||||
failure $"Reloading $prog"
|
||||
fi
|
||||
retval=$?
|
||||
echo
|
||||
}
|
||||
|
||||
force_reload() {
|
||||
# new configuration takes effect after restart
|
||||
restart
|
||||
}
|
||||
|
||||
rh_status() {
|
||||
# run checks to determine if the service is running or use generic status
|
||||
status -p $PID_FILE $prog
|
||||
}
|
||||
|
||||
rh_status_q() {
|
||||
rh_status >/dev/null 2>&1
|
||||
}
|
||||
|
||||
|
||||
case "$1" in
|
||||
start)
|
||||
rh_status_q && exit 0
|
||||
$1
|
||||
;;
|
||||
stop)
|
||||
rh_status_q || exit 0
|
||||
$1
|
||||
;;
|
||||
restart)
|
||||
$1
|
||||
;;
|
||||
reload)
|
||||
rh_status_q || exit 7
|
||||
$1
|
||||
;;
|
||||
force-reload)
|
||||
force_reload
|
||||
;;
|
||||
status)
|
||||
rh_status || exit 0
|
||||
;;
|
||||
masterrestart|try-restart)
|
||||
rh_status_q || exit 0
|
||||
restart
|
||||
;;
|
||||
*)
|
||||
echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload}"
|
||||
exit 2
|
||||
esac
|
||||
exit $?
|
||||
|
26
dist/master/setup.sh
vendored
26
dist/master/setup.sh
vendored
@ -120,7 +120,14 @@ then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
INSTALL_PATH=$1
|
||||
if [ $# -eq 2 ]
|
||||
then
|
||||
PREFIX_PATH=$1
|
||||
INSTALL_PATH=$2
|
||||
else
|
||||
INSTALL_PATH=$1
|
||||
PREFIX_PATH=
|
||||
fi
|
||||
|
||||
case $INSTALL_PATH in
|
||||
/*) ;;
|
||||
@ -130,13 +137,14 @@ esac
|
||||
|
||||
echo Installing to $INSTALL_PATH...
|
||||
|
||||
BIN_PATH=$INSTALL_PATH/bin
|
||||
SBIN_PATH=$INSTALL_PATH/sbin
|
||||
CONF_PATH=$INSTALL_PATH/conf
|
||||
SERVICE_PATH=$CONF_PATH/service
|
||||
LIBEXEC_PATH=$INSTALL_PATH/libexec
|
||||
SH_PATH=$INSTALL_PATH/sh
|
||||
VAR_PATH=$INSTALL_PATH/var
|
||||
BIN_PATH=$PREFIX_PATH$INSTALL_PATH/bin
|
||||
SBIN_PATH=$PREFIX_PATH$INSTALL_PATH/sbin
|
||||
CONF_PATH=$PREFIX_PATH$INSTALL_PATH/conf
|
||||
SERVICE_PATH=$PREFIX_PATH$INSTALL_PATH/conf/service
|
||||
LIBEXEC_PATH=$PREFIX_PATH$INSTALL_PATH/libexec
|
||||
INIT_PATH=$PREFIX_PATH/etc/init.d/
|
||||
SH_PATH=$PREFIX_PATH$INSTALL_PATH/sh
|
||||
VAR_PATH=$PREFIX_PATH$INSTALL_PATH/var
|
||||
|
||||
###############################################################################
|
||||
create_all_path()
|
||||
@ -154,6 +162,7 @@ create_all_path()
|
||||
create_path $VAR_PATH/pid
|
||||
create_path $VAR_PATH/private
|
||||
create_path $VAR_PATH/public
|
||||
create_path $INIT_PATH
|
||||
|
||||
chmod 700 $VAR_PATH/private
|
||||
chmod 1777 $VAR_PATH/log
|
||||
@ -168,6 +177,7 @@ copy_all_file()
|
||||
install_file a+x,go-wrx conf $CONF_PATH
|
||||
install_file a+x,go-wrx conf/service $SERVICE_PATH
|
||||
install_file a+x,go-wrx conf/service/samples $SERVICE_PATH/samples
|
||||
install_file a+x,go-wrx init.d/ $INIT_PATH
|
||||
}
|
||||
|
||||
guess_os
|
||||
|
15
dist/master/sh/master.sh
vendored
15
dist/master/sh/master.sh
vendored
@ -117,6 +117,18 @@ reload()
|
||||
fi
|
||||
}
|
||||
|
||||
status()
|
||||
{
|
||||
check_proc
|
||||
if [ "$RUNNING" = "yes" ]; then
|
||||
PID=`sed 1q $PID_FILE | awk '{print $NF}'`
|
||||
echo "$PROG_NAME running ($PID)"
|
||||
else
|
||||
echo "$PROG_NAME not running!"
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
# See how we were called.
|
||||
case "$1" in
|
||||
start)
|
||||
@ -128,6 +140,9 @@ case "$1" in
|
||||
reload)
|
||||
reload
|
||||
;;
|
||||
status)
|
||||
status
|
||||
;;
|
||||
*)
|
||||
echo $"Usage: $0 {start|stop|reload}"
|
||||
;;
|
||||
|
@ -1,6 +1,13 @@
|
||||
修改历史列表:
|
||||
|
||||
------------------------------------------------------------------------
|
||||
591) 2017.6.8
|
||||
591.1) feature: acl_master 服务器框架允许启动时没有应用服务程序,以便于用户
|
||||
动态添加
|
||||
|
||||
590) 2017.6.4
|
||||
590.1) feature: ACL_TOKEN 对象增加针对 acl_foreach 的支持,可以遍历所有的关键词
|
||||
|
||||
589) 2017.6.3
|
||||
589.1) feature: acl_token_tree.c 增加 acl_token_tree_word_remove 方法
|
||||
|
||||
|
@ -6,6 +6,7 @@ extern "C" {
|
||||
#endif
|
||||
#include "acl_define.h"
|
||||
#include "acl_vstring.h"
|
||||
#include "acl_iterator.h"
|
||||
|
||||
#define ACL_PRINT_CHAR(x) \
|
||||
((((x) >= 'a' && (x) <='z') \
|
||||
@ -25,7 +26,9 @@ extern "C" {
|
||||
|| (x) == '\'' || (x) == '"') \
|
||||
? (x) : '-')
|
||||
|
||||
typedef struct ACL_TOKEN {
|
||||
typedef struct ACL_TOKEN ACL_TOKEN;
|
||||
|
||||
struct ACL_TOKEN {
|
||||
unsigned char ch;
|
||||
unsigned int flag;
|
||||
#define ACL_TOKEN_F_NONE 0
|
||||
@ -34,11 +37,14 @@ typedef struct ACL_TOKEN {
|
||||
#define ACL_TOKEN_F_DENY (1 << 2)
|
||||
#define ACL_TOKEN_F_UTF8 (1 << 3)
|
||||
|
||||
#define ACL_TOKEN_WIDTH 255
|
||||
#define ACL_TOKEN_WIDTH 256
|
||||
struct ACL_TOKEN *tokens[ACL_TOKEN_WIDTH];
|
||||
struct ACL_TOKEN *parent;
|
||||
void *ctx;
|
||||
} ACL_TOKEN;
|
||||
|
||||
ACL_TOKEN *(*iter_head)(ACL_ITER*, ACL_TOKEN*);
|
||||
ACL_TOKEN *(*iter_next)(ACL_ITER*, ACL_TOKEN*);
|
||||
};
|
||||
|
||||
#define ACL_TOKEN_TREE_WORD_MATCH(acl_token_tree_in, word_in, acl_token_out) \
|
||||
{ \
|
||||
|
@ -113,7 +113,7 @@ struct ACL_XML {
|
||||
unsigned flag; /**< 标志位: ACL_XML_FLAG_xxx */
|
||||
|
||||
/**< 是否允许一个 xml 文档中有多个根节点,内部缺省为允许 */
|
||||
#define ACL_XML_FLAG_MULTI_ROOT (1 << 0)
|
||||
#define ACL_XML_FLAG_MULTI_ROOT (1 << 0)
|
||||
|
||||
/**< 是否兼容单节点中没有 '/' 情况 */
|
||||
#define ACL_XML_FLAG_IGNORE_SLASH (1 << 1)
|
||||
|
@ -87,7 +87,7 @@ service server {
|
||||
mail_bcc = zhengshuxin@51iker.com
|
||||
auth_user = zsx@renwou.cn
|
||||
auth_pass = 111111
|
||||
warn_mail = ${install_path}/conf/warning_letter.tmpl
|
||||
warn_mail = {install_path}/conf/warning_letter.tmpl
|
||||
|
||||
# 公司正常工作时间
|
||||
work_week_min = 1
|
||||
|
@ -131,9 +131,10 @@ extern void acl_master_refresh(void);
|
||||
*/
|
||||
extern ACL_MASTER_SERV *acl_var_master_head;
|
||||
extern ACL_EVENT *acl_var_master_global_event;
|
||||
extern void acl_master_start_service(ACL_MASTER_SERV *);
|
||||
extern void acl_master_stop_service(ACL_MASTER_SERV *);
|
||||
extern void acl_master_restart_service(ACL_MASTER_SERV *);
|
||||
extern void acl_master_service_init(void);
|
||||
extern void acl_master_service_start(ACL_MASTER_SERV *);
|
||||
extern void acl_master_service_stop(ACL_MASTER_SERV *);
|
||||
extern void acl_master_service_restart(ACL_MASTER_SERV *);
|
||||
|
||||
/*
|
||||
* acl_master_events.c
|
||||
@ -177,6 +178,7 @@ extern void acl_master_avail_less(ACL_MASTER_SERV *, ACL_MASTER_PROC *);
|
||||
* acl_master_spawn.c
|
||||
*/
|
||||
extern struct ACL_BINHASH *acl_var_master_child_table;
|
||||
extern void acl_master_spawn_init(void);
|
||||
extern void acl_master_spawn(ACL_MASTER_SERV *);
|
||||
extern void acl_master_reap_child(void);
|
||||
extern void acl_master_delete_children(ACL_MASTER_SERV *);
|
||||
|
@ -56,7 +56,7 @@ void acl_master_refresh(void)
|
||||
for (servp = &acl_var_master_head; (serv = *servp) != 0; /* void */ ) {
|
||||
if ((serv->flags & ACL_MASTER_FLAG_MARK) != 0) {
|
||||
*servp = serv->next;
|
||||
acl_master_stop_service(serv);
|
||||
acl_master_service_stop(serv);
|
||||
acl_free_master_ent(serv);
|
||||
} else
|
||||
servp = &serv->next;
|
||||
@ -82,7 +82,15 @@ void acl_master_config(void)
|
||||
acl_master_params_load(pathname);
|
||||
acl_myfree(pathname);
|
||||
|
||||
/* create the global acl_var_master_global_event */
|
||||
acl_master_service_init();
|
||||
|
||||
/* create the global acl_var_master_child_table */
|
||||
acl_master_spawn_init();
|
||||
|
||||
/* create IPC PIPE */
|
||||
acl_master_vars_init(acl_var_master_buf_size, acl_var_master_rw_timeout);
|
||||
|
||||
acl_set_master_service_path(acl_var_master_service_dir);
|
||||
|
||||
/*
|
||||
@ -110,7 +118,7 @@ void acl_master_config(void)
|
||||
if (serv == 0) {
|
||||
entry->next = acl_var_master_head;
|
||||
acl_var_master_head = entry;
|
||||
acl_master_start_service(entry);
|
||||
acl_master_service_start(entry);
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -133,13 +141,13 @@ void acl_master_config(void)
|
||||
SWAP(char *, serv->notify_addr, entry->notify_addr);
|
||||
SWAP(char *, serv->notify_recipients, entry->notify_recipients);
|
||||
SWAP(ACL_ARGV *, serv->args, entry->args);
|
||||
acl_master_restart_service(serv);
|
||||
acl_master_service_restart(serv);
|
||||
acl_free_master_ent(entry);
|
||||
}
|
||||
acl_end_master_ent();
|
||||
|
||||
if (service_null)
|
||||
acl_msg_fatal("%s(%d)->%s: no service file in dir %s%s can be used",
|
||||
acl_msg_warn("%s(%d)->%s: no service file in dir %s%s can be used",
|
||||
__FILE__, __LINE__, myname, acl_var_master_service_dir,
|
||||
acl_var_master_scan_subdir ? " and its subdir" : "");
|
||||
}
|
||||
|
@ -29,14 +29,11 @@
|
||||
ACL_MASTER_SERV *acl_var_master_head = NULL;
|
||||
ACL_EVENT *acl_var_master_global_event = NULL;
|
||||
|
||||
/* acl_master_start_service - activate service */
|
||||
/* acl_master_service_init - init service after loading the main.cf */
|
||||
|
||||
void acl_master_start_service(ACL_MASTER_SERV *serv)
|
||||
void acl_master_service_init(void)
|
||||
{
|
||||
const char *myname = "acl_master_start_service";
|
||||
|
||||
if (serv == NULL)
|
||||
acl_msg_fatal("%s(%d): serv null", myname, __LINE__);
|
||||
const char *myname = "acl_master_service_init";
|
||||
|
||||
if (acl_var_master_global_event == NULL)
|
||||
acl_var_master_global_event = acl_event_new_select(
|
||||
@ -44,6 +41,16 @@ void acl_master_start_service(ACL_MASTER_SERV *serv)
|
||||
if (acl_var_master_global_event == NULL)
|
||||
acl_msg_fatal("%s(%d)->%s: acl_event_new null, serr=%s",
|
||||
__FILE__, __LINE__, myname, strerror(errno));
|
||||
}
|
||||
|
||||
/* acl_master_service_start - activate service */
|
||||
|
||||
void acl_master_service_start(ACL_MASTER_SERV *serv)
|
||||
{
|
||||
const char *myname = "acl_master_service_start";
|
||||
|
||||
if (serv == NULL)
|
||||
acl_msg_fatal("%s(%d): serv null", myname, __LINE__);
|
||||
|
||||
/*
|
||||
* Enable connection requests, wakeup timers, and status updates from
|
||||
@ -63,12 +70,12 @@ void acl_master_start_service(ACL_MASTER_SERV *serv)
|
||||
acl_msg_info("%s: service started!", myname);
|
||||
}
|
||||
|
||||
/* acl_master_stop_service - deactivate service */
|
||||
/* acl_master_service_stop - deactivate service */
|
||||
|
||||
void acl_master_stop_service(ACL_MASTER_SERV *serv)
|
||||
void acl_master_service_stop(ACL_MASTER_SERV *serv)
|
||||
{
|
||||
/*
|
||||
* Undo the things that master_start_service() did.
|
||||
* Undo the things that master_service_start() did.
|
||||
*/
|
||||
acl_master_wakeup_cleanup(serv);
|
||||
acl_master_status_cleanup(serv);
|
||||
@ -78,18 +85,9 @@ void acl_master_stop_service(ACL_MASTER_SERV *serv)
|
||||
|
||||
/* acl_master_restart_service - restart service after configuration reload */
|
||||
|
||||
void acl_master_restart_service(ACL_MASTER_SERV *serv)
|
||||
void acl_master_service_restart(ACL_MASTER_SERV *serv)
|
||||
{
|
||||
const char *myname = "acl_master_restart_service";
|
||||
|
||||
if (acl_var_master_global_event == NULL)
|
||||
acl_var_master_global_event = acl_event_new_select(
|
||||
acl_var_master_delay_sec, acl_var_master_delay_usec);
|
||||
if (acl_var_master_global_event == NULL)
|
||||
acl_msg_fatal("%s(%d)->%s: acl_event_new null, serr=%s",
|
||||
__FILE__, __LINE__, myname, strerror(errno));
|
||||
|
||||
/* Undo some of the things that master_start_service() did. */
|
||||
/* Undo some of the things that master_service_start() did. */
|
||||
acl_master_wakeup_cleanup(serv);
|
||||
acl_master_status_cleanup(serv);
|
||||
|
||||
|
@ -41,6 +41,12 @@
|
||||
ACL_BINHASH *acl_var_master_child_table = NULL;
|
||||
static void master_unthrottle(ACL_MASTER_SERV *serv);
|
||||
|
||||
void acl_master_spawn_init(void)
|
||||
{
|
||||
if (acl_var_master_child_table == 0)
|
||||
acl_var_master_child_table = acl_binhash_create(0, 0);
|
||||
}
|
||||
|
||||
/* master_unthrottle_wrapper - in case (char *) != (struct *) */
|
||||
|
||||
static void master_unthrottle_wrapper(int type acl_unused,
|
||||
@ -114,8 +120,6 @@ void acl_master_spawn(ACL_MASTER_SERV *serv)
|
||||
static unsigned _master_generation = 0;
|
||||
static ACL_VSTRING *env_gen = 0;
|
||||
|
||||
if (acl_var_master_child_table == 0)
|
||||
acl_var_master_child_table = acl_binhash_create(0, 0);
|
||||
if (env_gen == 0)
|
||||
env_gen = acl_vstring_alloc(100);
|
||||
|
||||
@ -279,7 +283,7 @@ void acl_master_spawn(ACL_MASTER_SERV *serv)
|
||||
serv->name);
|
||||
}
|
||||
|
||||
return;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -409,6 +413,7 @@ void acl_master_delete_children(ACL_MASTER_SERV *serv)
|
||||
* associated timer request, so we might just as well do it at the end.
|
||||
*/
|
||||
master_throttle(serv);
|
||||
|
||||
info = list = acl_binhash_list(acl_var_master_child_table);
|
||||
for (; *info; info++) {
|
||||
proc = (ACL_MASTER_PROC *) info[0]->value;
|
||||
|
@ -42,6 +42,76 @@ void acl_token_delim_tab_free(char *delim_tab)
|
||||
acl_myfree(delim_tab);
|
||||
}
|
||||
|
||||
static ACL_TOKEN *iter_next(ACL_ITER *it, ACL_TOKEN *token);
|
||||
static ACL_TOKEN *iter_head(ACL_ITER *it, ACL_TOKEN *token)
|
||||
{
|
||||
it->dlen = -1;
|
||||
it->key = NULL;
|
||||
it->klen = -1;
|
||||
|
||||
it->i = 0;
|
||||
it->size = 0;
|
||||
it->ptr = token;
|
||||
|
||||
assert(token->parent == NULL);
|
||||
return iter_next(it, token);
|
||||
}
|
||||
|
||||
static ACL_TOKEN *next_token(ACL_ITER *it, ACL_TOKEN *token)
|
||||
{
|
||||
ACL_TOKEN *parent;
|
||||
unsigned i;
|
||||
|
||||
assert(token);
|
||||
|
||||
/* lookup the first left no null child of the current token */
|
||||
|
||||
for (i = 0; i < ACL_TOKEN_WIDTH; i++) {
|
||||
if (token->tokens[i] != NULL) {
|
||||
it->i = i;
|
||||
it->ptr = token->tokens[i];
|
||||
it->data = token->tokens[i];
|
||||
return token->tokens[i];
|
||||
}
|
||||
}
|
||||
|
||||
/* lookup the right no null brother of the current token */
|
||||
|
||||
i = token->ch + 1;
|
||||
parent = token->parent;
|
||||
|
||||
while (parent != NULL) {
|
||||
for (; i < ACL_TOKEN_WIDTH; i++) {
|
||||
if (parent->tokens[i] != NULL) {
|
||||
it->i = i;
|
||||
it->ptr = parent->tokens[i];
|
||||
it->data = parent->tokens[i];
|
||||
return parent->tokens[i];
|
||||
}
|
||||
}
|
||||
|
||||
i = parent->ch + 1;
|
||||
parent = parent->parent;
|
||||
}
|
||||
|
||||
it->ptr = it->data = NULL;
|
||||
it->i = 0;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static ACL_TOKEN *iter_next(ACL_ITER *it, ACL_TOKEN *token acl_unused)
|
||||
{
|
||||
ACL_TOKEN *curr = (ACL_TOKEN *) it->ptr;
|
||||
|
||||
while (1) {
|
||||
curr = next_token(it, curr);
|
||||
if (curr == NULL)
|
||||
return NULL;
|
||||
if (curr->flag & ACL_TOKEN_F_STOP)
|
||||
return curr;
|
||||
}
|
||||
}
|
||||
|
||||
ACL_TOKEN *acl_token_new(void)
|
||||
{
|
||||
ACL_TOKEN *token = (ACL_TOKEN*) acl_mycalloc(1, sizeof(ACL_TOKEN));
|
||||
@ -51,6 +121,8 @@ ACL_TOKEN *acl_token_new(void)
|
||||
token->tokens[i] = NULL;
|
||||
|
||||
token->ch = '-';
|
||||
token->iter_head = iter_head;
|
||||
token->iter_next = iter_next;
|
||||
return token;
|
||||
}
|
||||
|
||||
@ -224,6 +296,7 @@ void acl_token_tree_word_remove(ACL_TOKEN *tree, const char *word)
|
||||
if (token == NULL)
|
||||
return;
|
||||
|
||||
token->ctx = NULL;
|
||||
|
||||
for (i = 0; i < ACL_TOKEN_WIDTH; i++) {
|
||||
if (token->tokens[i] != NULL) {
|
||||
|
@ -27,3 +27,4 @@ acl_ioctl_server.c
|
||||
17) acl_master 服务器框架的各个服务模板应该支持进程退出前的回调接口,便于应用的善后工作
|
||||
18) acl_master 当子进程的 master_prefork 和空闲退出通知打开时,可能存在冲突
|
||||
19) ACL_VSTREAM: sa_local & sa_peer 需要支持 IPV6 -- 完成
|
||||
20) acl_master 当 master_prefork > 0 时无法禁止服务
|
||||
|
@ -560,7 +560,7 @@ static void usage(int argc, char * argv[])
|
||||
static int __first_name;
|
||||
static va_list __ap_dest;
|
||||
|
||||
static void fiber_main(ACL_FIBER *fiber acl_unused, void *ctx acl_unused)
|
||||
static void fiber_start(void)
|
||||
{
|
||||
const char *myname = "fiber_main";
|
||||
const char *service_name = acl_safe_basename(__argv[0]);
|
||||
@ -769,6 +769,6 @@ void acl_fiber_server_main(int argc, char *argv[],
|
||||
va_copy(__ap_dest, ap);
|
||||
va_end(ap);
|
||||
|
||||
acl_fiber_create(fiber_main, NULL, STACK_SIZE);
|
||||
fiber_start();
|
||||
acl_fiber_schedule();
|
||||
}
|
||||
|
@ -1,3 +1,6 @@
|
||||
51) 2017.6.6
|
||||
51.1) feature: fiber_server.c 在启动协程调度前的过程放在主线程中进行,从而使
|
||||
该段代码的运行栈大小不受协程栈大小的限制
|
||||
|
||||
50) 2017.5.16
|
||||
50.1) feature: fiber_server.c 协程服务器模板增加了平滑退出机制
|
||||
|
20
packaging/Makefile
Normal file
20
packaging/Makefile
Normal file
@ -0,0 +1,20 @@
|
||||
PKG_NAME = acl-libs
|
||||
PKG_VERSION = $(shell grep '^Version:' $(PKG_NAME).spec | awk '{print $$2}')
|
||||
|
||||
PWD = $(shell pwd)
|
||||
|
||||
|
||||
all: rpm
|
||||
|
||||
tar:
|
||||
@./control pack
|
||||
|
||||
rpm: tar
|
||||
@mkdir -p {BUILD,BUILDROOT,SRPMS,SPECS}
|
||||
@rpmbuild --define "_topdir ${PWD}" --define "_sourcedir ${PWD}" --define "_rpmdir ${PWD}" -bb $(PKG_NAME).spec
|
||||
@echo Binary PRM for $(PKG_NAME) has been created under ${PWD}/`rpm --eval '%{_arch}'`
|
||||
|
||||
clean:
|
||||
@rm -rf $(PKG_NAME)-$(PKG_VERSION)
|
||||
@rm -rf $(PKG_NAME)-$(PKG_VERSION).tar.gz
|
||||
@rm -rf BUILD BUILDROOT SRPMS SPECS `rpm --eval '%{_arch}'`
|
70
packaging/acl-libs.spec
Normal file
70
packaging/acl-libs.spec
Normal file
@ -0,0 +1,70 @@
|
||||
Summary: The powerful c/c++ library and server framework
|
||||
Name: acl-libs
|
||||
Version: 3.3.0
|
||||
Release: 1
|
||||
Group: System/Libs
|
||||
License: IBM
|
||||
URL: http://cdnlog-web.qiyi.domain
|
||||
Packager: Zhang Qiang <qiangzhang@qiyi.com>
|
||||
BuildRoot: %{_tmppath}/%{name}-%{version}-root
|
||||
Source: http://example.com/%{name}-%{version}.tar.gz
|
||||
|
||||
%description
|
||||
|
||||
One advanced C/C++ library for Linux/Mac/FreeBSD/Solaris(x86)/Windows/Android/IOS http://zsxxsz.iteye.com/.
|
||||
|
||||
|
||||
%package -n acl-master
|
||||
Summary: acl master framework
|
||||
License: IBM
|
||||
Group: System Environment/Tools
|
||||
Requires(post): /sbin/ldconfig
|
||||
Requires(postun): /sbin/ldconfig
|
||||
|
||||
%description -n acl-master
|
||||
acl master framework
|
||||
|
||||
|
||||
%prep
|
||||
%setup -q
|
||||
|
||||
%build
|
||||
|
||||
make build_one -j 32
|
||||
|
||||
%install
|
||||
|
||||
make packinstall DESTDIR=$RPM_BUILD_ROOT
|
||||
|
||||
%clean
|
||||
rm -rf %{buildroot}
|
||||
|
||||
|
||||
%post -n acl-master
|
||||
/sbin/chkconfig --add master
|
||||
|
||||
%preun -n acl-master
|
||||
if [ "$1" = "0" ]; then
|
||||
service master stop >/dev/null 2>&1 ||:
|
||||
/sbin/chkconfig --del master
|
||||
fi
|
||||
|
||||
%postun -n acl-master
|
||||
if [ "$1" -ge "1" ]; then
|
||||
# TODO: upgrade should be support
|
||||
service master masterrestart > /dev/null 2>&1 ||:
|
||||
fi
|
||||
|
||||
|
||||
%files
|
||||
%defattr(-,root,root,-)
|
||||
# TODO: should be renamed
|
||||
%{_bindir}/acl_master
|
||||
%{_includedir}/acl-lib/acl
|
||||
%{_includedir}/acl-lib/acl_cpp
|
||||
/usr/lib/libacl_all.a
|
||||
|
||||
%files -n acl-master
|
||||
%defattr(-,root,root)
|
||||
/opt/soft
|
||||
/etc/init.d/master
|
32
packaging/control
Executable file
32
packaging/control
Executable file
@ -0,0 +1,32 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -x
|
||||
set -euo pipefail
|
||||
IFS=$'\n\t'
|
||||
|
||||
TAG=HEAD
|
||||
PKG_NAME=acl-libs
|
||||
PKG_VERSION=$(grep '^Version:' ${PKG_NAME}.spec | awk '{print $2}')
|
||||
|
||||
function pack() {
|
||||
cd ..
|
||||
git archive --format=tar --prefix=${PKG_NAME}-${PKG_VERSION}/ ${TAG} | tar xpf -
|
||||
#git show ${TAG} --oneline | head -1 > ${PKG_NAME}-${PKG_VERSION}/commit-id
|
||||
tar zcpf ${PKG_NAME}-${PKG_VERSION}.tar.gz ${PKG_NAME}-${PKG_VERSION}
|
||||
cp ${PKG_NAME}-${PKG_VERSION}.tar.gz packaging
|
||||
cd -
|
||||
}
|
||||
|
||||
function help() {
|
||||
echo "$0 build|pack"
|
||||
}
|
||||
|
||||
if [ "$1" == "" ]; then
|
||||
help
|
||||
elif [ "$1" == "pack" ];then
|
||||
pack
|
||||
elif [ "$1" == "test" ];then
|
||||
run_test
|
||||
else
|
||||
help
|
||||
fi
|
Loading…
Reference in New Issue
Block a user