Merge branch 'unstable' of github.com:/antirez/redis into unstable

This commit is contained in:
antirez 2016-06-15 12:15:46 +02:00
commit ca54335f40
3 changed files with 83 additions and 36 deletions

View File

@ -55,7 +55,7 @@ endif
FINAL_CFLAGS=$(STD) $(WARN) $(OPT) $(DEBUG) $(CFLAGS) $(REDIS_CFLAGS) -I../deps/geohash-int FINAL_CFLAGS=$(STD) $(WARN) $(OPT) $(DEBUG) $(CFLAGS) $(REDIS_CFLAGS) -I../deps/geohash-int
FINAL_LDFLAGS=$(LDFLAGS) $(REDIS_LDFLAGS) $(DEBUG) FINAL_LDFLAGS=$(LDFLAGS) $(REDIS_LDFLAGS) $(DEBUG)
FINAL_LIBS=-lm -ldl FINAL_LIBS=-lm
DEBUG=-g -ggdb DEBUG=-g -ggdb
ifeq ($(uname_S),SunOS) ifeq ($(uname_S),SunOS)
@ -65,17 +65,27 @@ ifeq ($(uname_S),SunOS)
FINAL_LIBS+= -ldl -lnsl -lsocket -lresolv -lpthread -lrt FINAL_LIBS+= -ldl -lnsl -lsocket -lresolv -lpthread -lrt
else else
ifeq ($(uname_S),Darwin) ifeq ($(uname_S),Darwin)
# Darwin (nothing to do) # Darwin
FINAL_LIBS+= -ldl
else else
ifeq ($(uname_S),AIX) ifeq ($(uname_S),AIX)
# AIX # AIX
FINAL_LDFLAGS+= -Wl,-bexpall FINAL_LDFLAGS+= -Wl,-bexpall
FINAL_LIBS+= -pthread -lcrypt -lbsd FINAL_LIBS+=-ldl -pthread -lcrypt -lbsd
else
ifeq ($(uname_S),OpenBSD)
# OpenBSD
FINAL_LIBS+= -lpthread
else
ifeq ($(uname_S),FreeBSD)
# FreeBSD
FINAL_LIBS+= -lpthread
else else
# All the other OSes (notably Linux) # All the other OSes (notably Linux)
FINAL_LDFLAGS+= -rdynamic FINAL_LDFLAGS+= -rdynamic
FINAL_LIBS+= -pthread FINAL_LIBS+=-ldl -pthread
endif
endif
endif endif
endif endif
endif endif

View File

@ -775,6 +775,10 @@ void bitcountCommand(client *c) {
/* Convert negative indexes */ /* Convert negative indexes */
if (start < 0) start = strlen+start; if (start < 0) start = strlen+start;
if (end < 0) end = strlen+end; if (end < 0) end = strlen+end;
if ((start < 0) && (end < 0) && (start > end)) {
addReply(c,shared.czero);
return;
}
if (start < 0) start = 0; if (start < 0) start = 0;
if (end < 0) end = 0; if (end < 0) end = 0;
if (end >= strlen) end = strlen-1; if (end >= strlen) end = strlen-1;

View File

@ -25,9 +25,25 @@
# #
################################################################################ ################################################################################
# #
# Interactive service installer for redis server # Service installer for redis server, runs interactively by default.
# this generates a redis config file and an /etc/init.d script, and installs them #
# this scripts should be run as root # To run this script non-interactively (for automation/provisioning purposes),
# feed the variables into the script. Any missing variables will be prompted!
# Tip: Environment variables also support command substitution (see REDIS_EXECUTABLE)
#
# Example:
#
# sudo REDIS_PORT=1234 \
# REDIS_CONFIG_FILE=/etc/redis/1234.conf \
# REDIS_LOG_FILE=/var/log/redis_1234.log \
# REDIS_DATA_DIR=/var/lib/redis/1234 \
# REDIS_EXECUTABLE=`command -v redis-server` ./utils/install_server.sh
#
# This generates a redis config file and an /etc/init.d script, and installs them.
#
# /!\ This script should be run as root
#
################################################################################
die () { die () {
echo "ERROR: $1. Aborting!" echo "ERROR: $1. Aborting!"
@ -42,6 +58,7 @@ SCRIPTPATH=$(dirname $SCRIPT)
#Initial defaults #Initial defaults
_REDIS_PORT=6379 _REDIS_PORT=6379
_MANUAL_EXECUTION=false
echo "Welcome to the redis service installer" echo "Welcome to the redis service installer"
echo "This script will help you easily set up a running redis server" echo "This script will help you easily set up a running redis server"
@ -53,13 +70,18 @@ if [ "$(id -u)" -ne 0 ] ; then
exit 1 exit 1
fi fi
if ! echo $REDIS_PORT | egrep -q '^[0-9]+$' ; then
_MANUAL_EXECUTION=true
#Read the redis port #Read the redis port
read -p "Please select the redis port for this instance: [$_REDIS_PORT] " REDIS_PORT read -p "Please select the redis port for this instance: [$_REDIS_PORT] " REDIS_PORT
if ! echo $REDIS_PORT | egrep -q '^[0-9]+$' ; then if ! echo $REDIS_PORT | egrep -q '^[0-9]+$' ; then
echo "Selecting default: $_REDIS_PORT" echo "Selecting default: $_REDIS_PORT"
REDIS_PORT=$_REDIS_PORT REDIS_PORT=$_REDIS_PORT
fi fi
fi
if [ -z "$REDIS_CONFIG_FILE" ] ; then
_MANUAL_EXECUTION=true
#read the redis config file #read the redis config file
_REDIS_CONFIG_FILE="/etc/redis/$REDIS_PORT.conf" _REDIS_CONFIG_FILE="/etc/redis/$REDIS_PORT.conf"
read -p "Please select the redis config file name [$_REDIS_CONFIG_FILE] " REDIS_CONFIG_FILE read -p "Please select the redis config file name [$_REDIS_CONFIG_FILE] " REDIS_CONFIG_FILE
@ -67,7 +89,10 @@ if [ -z "$REDIS_CONFIG_FILE" ] ; then
REDIS_CONFIG_FILE=$_REDIS_CONFIG_FILE REDIS_CONFIG_FILE=$_REDIS_CONFIG_FILE
echo "Selected default - $REDIS_CONFIG_FILE" echo "Selected default - $REDIS_CONFIG_FILE"
fi fi
fi
if [ -z "$REDIS_LOG_FILE" ] ; then
_MANUAL_EXECUTION=true
#read the redis log file path #read the redis log file path
_REDIS_LOG_FILE="/var/log/redis_$REDIS_PORT.log" _REDIS_LOG_FILE="/var/log/redis_$REDIS_PORT.log"
read -p "Please select the redis log file name [$_REDIS_LOG_FILE] " REDIS_LOG_FILE read -p "Please select the redis log file name [$_REDIS_LOG_FILE] " REDIS_LOG_FILE
@ -75,8 +100,10 @@ if [ -z "$REDIS_LOG_FILE" ] ; then
REDIS_LOG_FILE=$_REDIS_LOG_FILE REDIS_LOG_FILE=$_REDIS_LOG_FILE
echo "Selected default - $REDIS_LOG_FILE" echo "Selected default - $REDIS_LOG_FILE"
fi fi
fi
if [ -z "$REDIS_DATA_DIR" ] ; then
_MANUAL_EXECUTION=true
#get the redis data directory #get the redis data directory
_REDIS_DATA_DIR="/var/lib/redis/$REDIS_PORT" _REDIS_DATA_DIR="/var/lib/redis/$REDIS_PORT"
read -p "Please select the data directory for this instance [$_REDIS_DATA_DIR] " REDIS_DATA_DIR read -p "Please select the data directory for this instance [$_REDIS_DATA_DIR] " REDIS_DATA_DIR
@ -84,7 +111,10 @@ if [ -z "$REDIS_DATA_DIR" ] ; then
REDIS_DATA_DIR=$_REDIS_DATA_DIR REDIS_DATA_DIR=$_REDIS_DATA_DIR
echo "Selected default - $REDIS_DATA_DIR" echo "Selected default - $REDIS_DATA_DIR"
fi fi
fi
if [ ! -x "$REDIS_EXECUTABLE" ] ; then
_MANUAL_EXECUTION=true
#get the redis executable path #get the redis executable path
_REDIS_EXECUTABLE=`command -v redis-server` _REDIS_EXECUTABLE=`command -v redis-server`
read -p "Please select the redis executable path [$_REDIS_EXECUTABLE] " REDIS_EXECUTABLE read -p "Please select the redis executable path [$_REDIS_EXECUTABLE] " REDIS_EXECUTABLE
@ -96,6 +126,7 @@ if [ ! -x "$REDIS_EXECUTABLE" ] ; then
exit 1 exit 1
fi fi
fi fi
fi
#check the default for redis cli #check the default for redis cli
CLI_EXEC=`command -v redis-cli` CLI_EXEC=`command -v redis-cli`
@ -112,7 +143,9 @@ echo "Data dir : $REDIS_DATA_DIR"
echo "Executable : $REDIS_EXECUTABLE" echo "Executable : $REDIS_EXECUTABLE"
echo "Cli Executable : $CLI_EXEC" echo "Cli Executable : $CLI_EXEC"
if $_MANUAL_EXECUTION == true ; then
read -p "Is this ok? Then press ENTER to go on or Ctrl-C to abort." _UNUSED_ read -p "Is this ok? Then press ENTER to go on or Ctrl-C to abort." _UNUSED_
fi
mkdir -p `dirname "$REDIS_CONFIG_FILE"` || die "Could not create redis config directory" mkdir -p `dirname "$REDIS_CONFIG_FILE"` || die "Could not create redis config directory"
mkdir -p `dirname "$REDIS_LOG_FILE"` || die "Could not create redis log dir" mkdir -p `dirname "$REDIS_LOG_FILE"` || die "Could not create redis log dir"