diff --git a/.gitignore b/.gitignore index 2e1d9d9bc42f255158cc43a20ac69e7f2fddcdea..ea326996e071150019666fc2a92001f5d356d1c9 100644 --- a/.gitignore +++ b/.gitignore @@ -8,10 +8,17 @@ _release_feeder config.mk lcov *.o +*.a *.d *.snap *.xlog -tarantool_version.h test/var test/lib/*.pyc test/lib/*/*.pyc +Makefile +CMakeFiles +CMakeCache.txt +cmake_install.cmake +core/tarantool_silverbox +core/tarantool_feeder +include/config.h diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..55a45a585ef95afd2ce745efe0372abaf91b12b6 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,170 @@ +cmake_minimum_required(VERSION 2.6) +project(Tarantool) +include(CheckLibraryExists) +include(CheckIncludeFile) +find_program(ECHO echo) +find_program(CAT cat) +find_program(GIT git) +find_program(RAGEL ragel) +find_program(CONFETTI confetti) + +# +# Set default build type to Debug. This is to ease a developer's +# life. Release binaries are built by BuildBot automatically anyway. +# +if(NOT CMAKE_BUILD_TYPE) + set(CMAKE_BUILD_TYPE Debug CACHE STRING + "Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel." + FORCE) +endif() + +# +# Perform operating-system specific configuration. +# +if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux") + set(TARGET_OS_LINUX 1) +# +# Enable GNU glibc extentions. + set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_GNU_SOURCE") +# +# On 32-bit systems, support files larger than 2GB +# (see man page for feature_test_macros). + set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_FILE_OFFSET_BITS=64") +elseif (${CMAKE_SYSTEM_NAME} STREQUAL "FreeBSD") + set(TARGET_OS_FREEBSD 1) +else() + message (FATAL_ERROR "Unsupported platform -- ${CMAKE_SYSTEM_NAME}") +endif() + +# +# Tarantool uses 'coro' (coroutines) library # to implement +# cooperative multi-tasking. Since coro.h is included +# universally, define the underlying implementation switch +# in top level CMakeLists.txt, to ensure a consistent header +# file layout across the entire project. +# +if (${CMAKE_SYSTEM_PROCESSOR} MATCHES "86") + set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DCORO_ASM") +else() + set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DCORO_SJLJ") + set_target_properties(coro PROPERTIES COMPILE_FLAGS "-DCORO_SJLJ") +endif() +# +# Perform build type specific configuration. +# +set (CMAKE_C_FLAGS_DEBUG "-ggdb -O0") +set (CMAKE_C_FLAGS_RELWITHDEBUGINFO "-ggdb -O2") +set (CMAKE_C_FLAGS_RELEASE "-DNDEBUG -DNVALGRIND") + +# +# Enable 'make tags' target. +# +add_custom_target(tags + COMMAND ctags -R -e -f TAGS + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} + ) + +# +# Define TARANTOOL_VERSION -- a string constant with tarantool version. +# +execute_process (COMMAND ${GIT} describe HEAD + OUTPUT_VARIABLE TARANTOOL_VERSION + OUTPUT_STRIP_TRAILING_WHITESPACE + ) + +# +# Set flags for all include files: those maintained by us and +# coming from third parties. +# We must set -fno-omit-frame-pointer here, since we rely +# on frame pointer when getting a backtrace, and it must +# be used consistently across all object files. +# The same reasoning applies to -fno-stack-protector switch. +# +set (CMAKE_C_FLAGS + "${CMAKE_C_FLAGS} -fno-omit-frame-pointer -fno-stack-protector") +# +# Tarantool code is written in GNU C dialect. +# Additionally, compile it with more strict flags than the rest +# of the code. +# +if (${CMAKE_BUILD_TYPE} STREQUAL "None") + set (core_cflags "-std=gnu99") +else() + set (core_cflags "-std=gnu99 -Wall -Wextra -Werror") + set (core_cflags "${core_cflags} -Wno-sign-compare -Wno-strict-aliasing") +endif() + +# +# Specify where to look for include files. +# +include_directories("${PROJECT_SOURCE_DIR}") +include_directories("${PROJECT_SOURCE_DIR}/include") +include_directories("${PROJECT_BINARY_DIR}/include") + +# +# Now handle all configuration options. +# +option(ENABLE_GCOV "Enable integration with gcov, a code coverage program" ON) +if (ENABLE_GCOV) + check_library_exists (gcov __gcov_flush "" HAVE_GCOV) + if (NOT HAVE_GCOV) + message (FATAL_ERROR + "ENABLE_GCOV option requested but gcov library is not found") + endif() +endif() + +option(ENABLE_TRACE "Enable debug trace of tarantool_silverbox execution to +a file specified in TARANTOOL_TRACE environment variable" ON) + +option(ENABLE_BACKTRACE "Enable output of fiber backtrace information in 'show +fiber' administrative command. Only works on x86 architectures, if compiled +with gcc. If GNU binutils and binutils-dev libraries are installed, backtrace +is output with resolved function (symbol) names. Otherwise only frame +addresses are printed." ${CMAKE_COMPILER_IS_GNUCC}) + +if (ENABLE_BACKTRACE) + if (NOT ${CMAKE_COMPILER_IS_GNUCC} OR + NOT (${CMAKE_SYSTEM_PROCESSOR} MATCHES "86")) + # We only know this option to work with gcc + # on x86 architecture. + message (FATAL_ERROR "ENABLE_BACKTRACE option is set but the system is not x86 based (${CMAKE_SYSTEM_PROCESSOR}) or the compiler is not GNU GCC (${CMAKE_C_COMPILER}).") + endif() +# Use GNU bfd if present. + check_library_exists (bfd bfd_init "" HAVE_BFD_LIB) + check_include_file(bfd.h HAVE_BFD_H) + if (HAVE_BFD_LIB AND HAVE_BFD_H) + set (HAVE_BFD 1) + message (STATUS "Found GNU bfd headers and libs, enabling symbol ") + message (STATUS "resolve in backtraces.") + elseif (NOT HAVE_BFD_LIB) + message (STATUS "Not found GNU bfd binaries, no symbol resolve.") + elseif (NOT HAVE_BFD_H) + message (STATUS "Not found GNU bfd headers, no symbol resolve. ") + message (STATUS "Consider installing binutils-dev.") + endif() +endif() + + +add_subdirectory(core) +add_subdirectory(third_party) +add_subdirectory(test) + +# +# Output compile-time defines into config.h. Do it at the end +# of the script to make sure all variables are set. +# +configure_file( + "${PROJECT_SOURCE_DIR}/include/config.h.cmake" + "${PROJECT_BINARY_DIR}/include/config.h" + ) + +message (STATUS "") +message (STATUS "Successfully configured Tarantool on ${CMAKE_SYSTEM_NAME}-${CMAKE_SYSTEM_PROCESSOR}, build type '${CMAKE_BUILD_TYPE}'. ") +message (STATUS "Please check out CMakeCache.txt to view or modify configuration results.") +message (STATUS "") +message (STATUS "*** The following options are on in this configuration: ***") +message (STATUS "ENABLE_GCOV: ${ENABLE_GCOV}") +message (STATUS "ENABLE_TRACE: ${ENABLE_TRACE}") +message (STATUS "ENABLE_BACKTRACE: ${ENABLE_BACKTRACE}") +message (STATUS "Backtrace is with symbol resolve: ${HAVE_BFD}") +message (STATUS "") diff --git a/Makefile b/Makefile deleted file mode 100644 index b0bdb07f6bce010d2017450af1643315e57d07f4..0000000000000000000000000000000000000000 --- a/Makefile +++ /dev/null @@ -1,62 +0,0 @@ - -# This makefile based on ideas from http://make.paulandlesley.org/ -# Thanks to Paul D. Smith <psmith@gnu.org> - -ECHO=/bin/echo -CAT=/bin/cat - -# make magic -SUB_MAKE:=$(filter _%,$(notdir $(CURDIR))) -OBJDIR:=$(shell $(ECHO) $(filter _%,$(MAKECMDGOALS)) | tr ' ' '\n' | cut -d/ -f1 | sort | uniq) -ifeq (,$(SUB_MAKE)) - ifneq (,$(OBJDIR)) - .SUFFIXES: - MAKEFLAGS += -rR --no-print-directory VPATH=$(CURDIR) - FILTERED_MAKECMDGOALS=$(subst $@/,,$(filter $@/%,$(MAKECMDGOALS))) - module=$(subst tarantool_,,$(FILTERED_MAKECMDGOALS)) - .PHONY: $(OBJDIR) - $(OBJDIR): - +@mkdir -p $@ - +@$(MAKE) -C $@ -f $(CURDIR)/Makefile SRCDIR=$(CURDIR) OBJDIR=$@ module=$(module) $(FILTERED_MAKECMDGOALS) - - Makefile: ; - %.mk :: ; - % :: $(OBJDIR) ; @: - else - SRCDIR:=$(CURDIR) - include $(SRCDIR)/scripts/rules.mk - endif -else - include $(SRCDIR)/scripts/rules.mk -endif - -.PHONY: test -test: - cd ./test && ./test-run.py - - -ifeq ("$(origin module)", "command line") -.PHONY: clean -clean: - @echo " CLEAN $(module)" - @rm -rf $(obj) $(dep) tarantool_$(module) _* lcov -else -.PHONY: clean -clean: - @for mod in mod/*; do $(MAKE) --no-print-directory module=`basename $$mod` clean; done -endif -.PHONY: TAGS -TAGS: - ctags -R -e -f TAGS - - -ifeq ("$(origin V)", "command line") - VERBOSE = $(V) -endif -ifeq (,$(VERBOSE)) - $(eval override CC = @$(ECHO) " CC " $$@; $(CC)) - $(eval override RAGEL = @$(ECHO) " RGL " $$@; $(RAGEL)) - $(eval override DOT = @$(ECHO) " DOT " $$@; $(DOT)) - $(eval override CONFETTI = @$(ECHO) " CNF " $$@; $(CONFETTI)) - $(eval override CAT = @$(ECHO) " CAT " $$@; $(CAT)) -endif diff --git a/README b/README index 3406cf84d257205124676a34af12da1470982ef0..cd53d4a32cadef24109f33ff06b1ad5ab97055ff 100644 --- a/README +++ b/README @@ -1,29 +1,66 @@ -Taranool/Silverbox +TARANTOOL/SILVERBOX -Taranool: in-memory storage framework -Silverbox: Yet another in-memory key-value database +Tarantool is a framework for in-memory key/value storage and +Silverbox is a yet another in-memory key-value database. -Key features: - * fast +Key features of the pair include: * log streaming replication * hot standby - * simple binary protocol - * memcached protocol emulation - * extensibility + * a simple binary protocol, as well as emulation of memcached + protocol + * extensibility and speed +Caveats: + * currently supported platforms are only Linux/x86 and + FreeBSD/x86 + * gcc is the only supported compiler. -Cons: - * only tested on x86/Linux and x86/FreeBSD - * gcc is required to build +COMPILATION AND INSTALL +Tarantool uses CMake for configuration management. +3 standard CMake build types are supported: + * Debug -- used by project maintainers + * RelWithDebugInfo -- the most common release configuration, + also provides debugging capabilities + * Release -- use only if the highest performance is required -How to run: +Please follow these steps to compile Tarantool: -1) compile (note GNU make is required) - (g)make _release_box/tarantool_silverbox -2) customize config - emacs cfg/tarantool_silverbox_cfg.cfg -3) initialize storage - _release_box/tarantool_silverbox --config cfg/tarantool_silverbox_cfg.cfg --init_storage -4) run - _release_box/tarantool_silverbox --config cfg/tarantool_silverbox_cfg.cfg +tarantool $ cmake . +tarantool $ make + +'make' will create tarantool_silverbox executable in directory core/. + +There is no 'make install' goal, but no installation +is required either. +The simplest way to get started is to use the regression testing +framework (test/test-run.py) to setup and start the server: + +tarantool $ cd test && ./test-run.py --start-and-exit + +This creates a 'var' subdirectory in directory 'test', +populates it with necessary files used by the server, and +starts the server. To connect, you could use +a simplistic command-line client: + +tarantool $ ./test/tarantool + +Alternatively, if a customized server configuration is required, +you could follow these steps: + +tarantool $ emacs cfg/tarantool_silverbox_cfg.cfg # edit the configuration +# Initialize the storage directory, path to this directory +# is specified in the configuration file: +tarantool $ core/tarantool_silverbox --config cfg/tarantool_silverbox_cfg.cfg --init-storage +# +# run +tarantool $ core/tarantool_silverbox --config cfg/tarantool_silverbox_cfg.cfg + +Please report bugs at http://bugs.launchpad.net/tarantool. +We also warmly welcome your feedback in the discussion mailing +list, tarantool-developers@lists.launchpad.net, however, please be +warned: Launchpad silently deletes posts from non-subscribed +members, thus please be sure to have subscribed to the list prior +to posting. + +Thank you for your interest in Tarantool! diff --git a/cfg/Makefile b/cfg/Makefile deleted file mode 100644 index 72e47d0c08d1990ef3e540c0df92ed024557a1ec..0000000000000000000000000000000000000000 --- a/cfg/Makefile +++ /dev/null @@ -1,17 +0,0 @@ -obj += cfg/warning.o -obj += cfg/tarantool_$(module)_cfg.o - -ifeq ($(HAVE_CONFETTI),1) -$(obj): cfg/tarantool_$(module)_cfg.h cfg/tarantool_$(module)_cfg.cfg -cfg/tarantool_$(module)_cfg.cfg_tmpl: cfg/core_cfg.cfg_tmpl $(cfg_tmpl) - @mkdir -p $(dir $@) - @echo '%{ ' > $@ - @echo "#include <third_party/confetti/prscfg.h>" >> $@ - @echo "#include <cfg/tarantool_$(module)_cfg.h>" >> $@ - @echo "void out_warning(ConfettyError r, char *format, ...);" >> $@ - @echo '%}' >> $@ - $(CAT) $^ >> $@ -endif - -CFLAGS += -DTARANTOOL_CONFIG='<cfg/tarantool_$(module)_cfg.h>' -cfg/tarantool_$(module)_cfg.o: CFLAGS += -Wno-unused diff --git a/cfg/core_cfg.cfg_tmpl b/cfg/core_cfg.cfg_tmpl index 3b3e0f6041569c2c4d62e2ac0ad2c6240e5fa620..e316da88633bc02d07bed9e67cba950085a1cfb9 100644 --- a/cfg/core_cfg.cfg_tmpl +++ b/cfg/core_cfg.cfg_tmpl @@ -1,4 +1,3 @@ - # username to switch to username=NULL, ro diff --git a/cfg/tarantool_cfg.h b/cfg/tarantool_cfg.h new file mode 100644 index 0000000000000000000000000000000000000000..09d9155d0d2da7bd6a9092c046c8145b0832b350 --- /dev/null +++ b/cfg/tarantool_cfg.h @@ -0,0 +1,2 @@ +#include <third_party/confetti/prscfg.h> +void out_warning(ConfettyError r, char *format, ...); diff --git a/cfg/tarantool_feeder_cfg.c b/cfg/tarantool_feeder_cfg.c index 42b0c17e308c4cb81325aa74ec5bfdc377e631dc..f4e190704b827eeee3027914930c2f31a81d5515 100644 --- a/cfg/tarantool_feeder_cfg.c +++ b/cfg/tarantool_feeder_cfg.c @@ -10,10 +10,10 @@ * Autogenerated file, do not edit it! */ - + #include <third_party/confetti/prscfg.h> -#include <cfg/tarantool_feeder_cfg.h> void out_warning(ConfettyError r, char *format, ...); +#include "cfg/tarantool_feeder_cfg.h" static int cmpNameAtoms(NameAtom *a, NameAtom *b) { while(a && b) { @@ -126,7 +126,7 @@ static NameAtom _name__custom_proc_title[] = { *y = malloc( sizeof( __typeof__(**(x))) ); \ if (*y == NULL) return CNF_NOMEMORY; \ if ( (ar = acceptDefault##t(*y)) != 0 ) return ar; \ - (*y)->__confetti_flags |= __flags; \ + (*y)->__confetti_flags = __flags; \ y++; \ } \ } \ diff --git a/cfg/tarantool_feeder_cfg.cfg_tmpl b/cfg/tarantool_feeder_cfg.cfg_tmpl deleted file mode 100644 index 2b3c9aa48289d97b108514ac944714bb36323592..0000000000000000000000000000000000000000 --- a/cfg/tarantool_feeder_cfg.cfg_tmpl +++ /dev/null @@ -1,60 +0,0 @@ -%{ -#include <third_party/confetti/prscfg.h> -#include <cfg/tarantool_feeder_cfg.h> -void out_warning(ConfettyError r, char *format, ...); -%} - -# username to switch to -username=NULL, ro - -# save core on abort/assert -coredump=0, ro - -# admin port -# used for admin's connections -admin_port=0, ro - -# Log verbosity, possible values: ERROR=1, CRIT=2, WARN=3, INFO=4(default), DEBUG=5 -log_level=4 - -# Size of slab arena in GiBs -slab_alloc_arena=1.0, ro -# Size of minimal allocation unit -slab_alloc_minimal=64, ro -# Growth factor, each subsecuent unit size is factor * prev unit size -slab_alloc_factor=2.0, ro - -# working directory (daemon will chdir(2) to it) -work_dir=NULL, ro - -# name of pid file -pid_file="tarantool.pid", ro - -# logger command will be executed via /bin/sh -c {} -# example: 'exec cronolog /var/log/taranul/%Y-%m/%Y-%m-%d/tarantool.log' -# example: 'exec extra/logger.pl /var/log/taranul/tarantool.log' -# when logger is not configured all logging going to STDERR -logger=NULL, ro - -# make logging nonblocking, this potentially can loss some logging data -logger_nonblock=1, ro - -# delay between loop iteraions -io_collect_interval=0.0, ro - -# size of listen backlog -backlog=1024, ro - -# network io readahead -readahead=16320 - -# feed WAL to remote replicas -# feeder accepts it's clients on wal_feeder_bind_ipaddr:wal_feeder_bind_port -wal_feeder_bind_ipaddr=NULL, ro, required -wal_feeder_bind_port=0, ro, required - -# Directory with WAL files to serve -wal_feeder_dir=NULL, ro, required - -# custom proc title is appended after normal -custom_proc_title=NULL, ro diff --git a/cfg/tarantool_silverbox_cfg.c b/cfg/tarantool_silverbox_cfg.c index 253f4199e05092a40b2444235a102caf17c1f12b..80d1bf00d329f1e272d2ba492ec72045a79af6aa 100644 --- a/cfg/tarantool_silverbox_cfg.c +++ b/cfg/tarantool_silverbox_cfg.c @@ -10,10 +10,10 @@ * Autogenerated file, do not edit it! */ - + #include <third_party/confetti/prscfg.h> -#include <cfg/tarantool_silverbox_cfg.h> void out_warning(ConfettyError r, char *format, ...); +#include "cfg/tarantool_silverbox_cfg.h" static int cmpNameAtoms(NameAtom *a, NameAtom *b) { while(a && b) { @@ -269,7 +269,7 @@ static NameAtom _name__namespace__index__key_field__type[] = { *y = malloc( sizeof( __typeof__(**(x))) ); \ if (*y == NULL) return CNF_NOMEMORY; \ if ( (ar = acceptDefault##t(*y)) != 0 ) return ar; \ - (*y)->__confetti_flags |= __flags; \ + (*y)->__confetti_flags = __flags; \ y++; \ } \ } \ diff --git a/cfg/tarantool_silverbox_cfg.cfg_tmpl b/cfg/tarantool_silverbox_cfg.cfg_tmpl deleted file mode 100644 index 8ba851471ad2598a99e39015b6ff3e1024dd9768..0000000000000000000000000000000000000000 --- a/cfg/tarantool_silverbox_cfg.cfg_tmpl +++ /dev/null @@ -1,125 +0,0 @@ -%{ -#include <third_party/confetti/prscfg.h> -#include <cfg/tarantool_silverbox_cfg.h> -void out_warning(ConfettyError r, char *format, ...); -%} - -# username to switch to -username=NULL, ro - -# save core on abort/assert -coredump=0, ro - -# admin port -# used for admin's connections -admin_port=0, ro - -# Log verbosity, possible values: ERROR=1, CRIT=2, WARN=3, INFO=4(default), DEBUG=5 -log_level=4 - -# Size of slab arena in GiBs -slab_alloc_arena=1.0, ro -# Size of minimal allocation unit -slab_alloc_minimal=64, ro -# Growth factor, each subsecuent unit size is factor * prev unit size -slab_alloc_factor=2.0, ro - -# working directory (daemon will chdir(2) to it) -work_dir=NULL, ro - -# name of pid file -pid_file="tarantool.pid", ro - -# logger command will be executed via /bin/sh -c {} -# example: 'exec cronolog /var/log/taranul/%Y-%m/%Y-%m-%d/tarantool.log' -# example: 'exec extra/logger.pl /var/log/taranul/tarantool.log' -# when logger is not configured all logging going to STDERR -logger=NULL, ro - -# make logging nonblocking, this potentially can loss some logging data -logger_nonblock=1, ro - -# delay between loop iteraions -io_collect_interval=0.0, ro - -# size of listen backlog -backlog=1024, ro - -# network io readahead -readahead=16320 - -## BOX - -# Snapshot directory (where snapshots get saved/read) -snap_dir=".", ro - -# WAL directory (where WAL get saved/read) -wal_dir=".", ro - -# Primary port (where updates are accepted) -primary_port=0, ro, required - -# Secondary port (where only selects are accepted) -secondary_port=0, ro - -# warn about requests which take longer to process -too_long_threshold=0.5 - -# custom proc title is appended after normal -custom_proc_title=NULL, ro - -# Memcached emulation is enabled if memcached == 1 -memcached=0, ro -# namespace used for memcached emulation -memcached_namespace=23, ro -# maximum rows to consider per expire loop iteration -memcached_expire_per_loop=1024 -# tarantool will try iterate all rows within this time -memcached_expire_full_sweep=3600 - - -# do not write snapshot faster then snap_io_rate_limit MBytes/sec -snap_io_rate_limit=0.0, ro - -# Write no more rows in WAL -rows_per_wal=500000, ro - -# fsync WAL delay, only issue fsync if last fsync was wal_fsync_delay seconds ago -# WARNING: actually, several last requsts may stall for much longer -wal_fsync_delay=0, ro - -# size of WAL writer requests buffer -wal_writer_inbox_size=128, ro - -# Local hot standby (if enabled server will run in locale hot standby mode -# continuously fetching WAL records from shared local directory -local_hot_standby=0, ro -# delay in fractional seconds between successive re-readings of wal_dir -wal_dir_rescan_delay=0.1, ro - - -# panic if where is error reading snap or wal -# be default panic any snapshot reading error and ignore errors then reading wals -panic_on_snap_error=1, ro -panic_on_wal_error=0, ro - -# Remote hot standby (if enabled server will run in hot standby mode -# continuously fetching WAL records from wal_feeder_ipaddr:wal_feeder_port -remote_hot_standby=0, ro -wal_feeder_ipaddr=NULL, ro -wal_feeder_port=0, ro - - -namespace = [ - enabled = 0, ro, required - cardinality = -1, ro - estimated_rows = 0, ro - index = [ - type = "", ro, required - unique = -1, ro, required - key_field = [ - fieldno = -1, ro, required - type = "", ro, required - ], ro, required - ], ro, required -], ro, required diff --git a/cfg/warning.c b/cfg/warning.c index 4b79926d7368cb5e47f4060388e81c22ddd017ae..98c60a6a66437df8003f6ebb3d151dbc7f8cc8c5 100644 --- a/cfg/warning.c +++ b/cfg/warning.c @@ -4,6 +4,11 @@ #include <util.h> #include <third_party/confetti/prscfg.h> +/** This is a callback function used by the generated + * configuration file parser (tarantool_{silverbox, feeder, + * ...}_cfg.c) to complain when something wrong happens. + */ + void out_warning(ConfettyError v, char *format, ...) { diff --git a/core/CMakeLists.txt b/core/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..d86eef277c5b5cb93143e731a2114d1bd655fa73 --- /dev/null +++ b/core/CMakeLists.txt @@ -0,0 +1,173 @@ +# +# libev library +# +add_library(ev tarantool_ev.c) + +set_source_files_properties(tarantool_ev.c + PROPERTIES COMPILE_FLAGS "-Wno-unused-result") + +if (TARGET_OS_LINUX) +# +# Enable Linux-specific event notification API (man inotify) + set_target_properties(ev PROPERTIES COMPILE_FLAGS "-DEV_USE_INOTIFY") +elseif (TARGET_OS_FREEBSD) +# +# On FreeBSD build libev loop on top of + set_target_properties(ev PROPERTIES COMPILE_FLAGS "-DEV_USE_KQUEUE") +endif() +# +# libev uses ceil and floor from the standard math library +# +target_link_libraries(ev m) + +# +# Build admin.c from admin.rl, but only if admin.rl was changed. +# The same applies to memcached.c/memcached.rl. +# We track admin.c and memcached.c in revision control, and thus do not +# require engineers who do not modify .rl files to have Ragel +# installed. +# +add_custom_command(OUTPUT ${CMAKE_SOURCE_DIR}/core/admin.c + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} + COMMAND ${RAGEL} -G2 core/admin.rl -o core/admin.c + DEPENDS ${CMAKE_SOURCE_DIR}/core/admin.rl) + +add_custom_command(OUTPUT ${CMAKE_SOURCE_DIR}/mod/silverbox/memcached.c + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} + COMMAND ${RAGEL} -G2 mod/silverbox/memcached.rl -o mod/silverbox/memcached.c + DEPENDS ${CMAKE_SOURCE_DIR}/mod/silverbox/memcached.rl) +# +# Optionally rebuild the configuration file parsing code from +# templates. +# +macro(generate_config module) +# Gracefully handle out-of-source builds with missing +# 'confetti'. Make sure that generated files are older than +# their sources when configuring the project. +execute_process(COMMAND ${CMAKE_COMMAND} -E touch_nocreate + ${CMAKE_SOURCE_DIR}/cfg/tarantool_${module}_cfg.h + ${CMAKE_SOURCE_DIR}/cfg/tarantool_${module}_cfg.c + ${CMAKE_SOURCE_DIR}/cfg/tarantool_${module}_cfg.cfg) +add_custom_command( + OUTPUT ${CMAKE_SOURCE_DIR}/cfg/tarantool_${module}_cfg.h + ${CMAKE_SOURCE_DIR}/cfg/tarantool_${module}_cfg.c + ${CMAKE_SOURCE_DIR}/cfg/tarantool_${module}_cfg.cfg + COMMAND ${ECHO} '%{' > tmp.cfg + COMMAND ${CAT} ${CMAKE_SOURCE_DIR}/cfg/tarantool_cfg.h >> tmp.cfg + COMMAND ${ECHO} '\#include \"cfg/tarantool_${module}_cfg.h\"' >> tmp.cfg + COMMAND ${ECHO} '%}' >> tmp.cfg + COMMAND ${CAT} ${CMAKE_SOURCE_DIR}/cfg/core_cfg.cfg_tmpl >> tmp.cfg + COMMAND ${CAT} ${CMAKE_SOURCE_DIR}/mod/${module}/${module}_cfg.cfg_tmpl >> + tmp.cfg + COMMAND ${CONFETTI} -i tmp.cfg -n tarantool_cfg + -c ${CMAKE_SOURCE_DIR}/cfg/tarantool_${module}_cfg.c + -h ${CMAKE_SOURCE_DIR}/cfg/tarantool_${module}_cfg.h + -f ${CMAKE_SOURCE_DIR}/cfg/tarantool_${module}_cfg.cfg + COMMAND ${CMAKE_COMMAND} -E remove tmp.cfg + DEPENDS ${CMAKE_SOURCE_DIR}/cfg/core_cfg.cfg_tmpl + ${CMAKE_SOURCE_DIR}/cfg/tarantool_cfg.h + ${CMAKE_SOURCE_DIR}/mod/${module}/${module}_cfg.cfg_tmpl + ) +endmacro() + +generate_config("silverbox") +generate_config("feeder") + +execute_process(COMMAND ${CMAKE_COMMAND} -E touch_nocreate + ${CMAKE_SOURCE_DIR}/third_party/confetti/prscfg.h + ${CMAKE_SOURCE_DIR}/third_party/confetti/prscfg.c) +add_custom_command( + OUTPUT ${CMAKE_SOURCE_DIR}/third_party/confetti/prscfg.h + ${CMAKE_SOURCE_DIR}/third_party/confetti/prscfg.c + COMMAND ${ECHO} '%{' > tmp.cfg + COMMAND ${CAT} ${CMAKE_SOURCE_DIR}/cfg/tarantool_cfg.h >> tmp.cfg + COMMAND ${ECHO} '%}' >> tmp.cfg + COMMAND ${CAT} ${CMAKE_SOURCE_DIR}/cfg/core_cfg.cfg_tmpl >> tmp.cfg + COMMAND ${CONFETTI} -i tmp.cfg -n tarantool_cfg + -H ${CMAKE_SOURCE_DIR}/third_party/confetti/prscfg.h + -p ${CMAKE_SOURCE_DIR}/third_party/confetti/prscfg.c + COMMAND ${CMAKE_COMMAND} -E remove tmp.cfg + DEPENDS ${CMAKE_SOURCE_DIR}/cfg/core_cfg.cfg_tmpl + ${CMAKE_SOURCE_DIR}/cfg/tarantool_cfg.h + ) +# +# Make sure all generated headers are built before they are used. +# +add_custom_target(generate_headers + DEPENDS ${CMAKE_SOURCE_DIR}/third_party/confetti/prscfg.c + ${CMAKE_SOURCE_DIR}/cfg/tarantool_silverbox_cfg.h + ${CMAKE_SOURCE_DIR}/cfg/tarantool_feeder_cfg.h) +# Do not list this helper target among all high-level targets. +set_target_properties(generate_headers PROPERTIES EXCLUDE_FROM_ALL TRUE) + +# +# Do not clean admin.c, memcached.c or other +# generated files in 'make clean' -- they are under +# revision control. +# +set_property(DIRECTORY PROPERTY CLEAN_NO_CUSTOM 1) + +set (recompiled_sources tarantool.c say.c admin.c fiber.c) + +add_library(ltfeeder STATIC ${recompiled_sources}) +set_target_properties(ltfeeder + PROPERTIES COMPILE_FLAGS + "${core_cflags} -DUTILITY -DTARANTOOL_CONFIG='<cfg/tarantool_feeder_cfg.h>'") +add_dependencies(ltfeeder generate_headers) + +add_library(ltbox STATIC ${recompiled_sources}) +set_target_properties(ltbox + PROPERTIES COMPILE_FLAGS + "${core_cflags} -DSTORAGE -DTARANTOOL_CONFIG='<cfg/tarantool_silverbox_cfg.h>'") +add_dependencies(ltbox generate_headers) + +set (common_sources tbuf.c palloc.c util.c + salloc.c pickle.c coro.c stat.c log_io.c + ${CMAKE_SOURCE_DIR}/cfg/warning.c + ${CMAKE_SOURCE_DIR}/third_party/confetti/prscfg.c + ) +add_library(ltcommon STATIC ${common_sources}) + +set (common_libraries ltcommon ev coro gopt misc) + +if (ENABLE_GCOV) + set (common_libraries ${common_libraries} gcov) +endif() + +if (ENABLE_BACKTRACE AND HAVE_BFD) + set (common_libraries ${common_libraries} bfd) +endif() + +set (silverbox_sources + ${CMAKE_SOURCE_DIR}/cfg/tarantool_silverbox_cfg.c + ${CMAKE_SOURCE_DIR}/mod/silverbox/index.c + ${CMAKE_SOURCE_DIR}/mod/silverbox/box.c + ${CMAKE_SOURCE_DIR}/mod/silverbox/memcached.c + log_io_remote.c iproto.c) + +if (ENABLE_TRACE) + set (silverbox_sources ${silverbox_sources} trace.c) +endif() + +set (feeder_sources + ${CMAKE_SOURCE_DIR}/cfg/tarantool_feeder_cfg.c + ${CMAKE_SOURCE_DIR}/mod/feeder/feeder.c) + +set_source_files_properties( + ${CMAKE_SOURCE_DIR}/mod/silverbox/memcached.c + PROPERTIES COMPILE_FLAGS "-Wno-uninitialized") + +set_source_files_properties( + ${CMAKE_SOURCE_DIR}/cfg/tarantool_silverbox_cfg.c + ${CMAKE_SOURCE_DIR}/cfg/tarantool_feeder_cfg.c + ${CMAKE_SOURCE_DIR}/third_party/confetti/prscfg.c + PROPERTIES COMPILE_FLAGS "-Wno-unused") + +add_executable(tarantool_silverbox ${silverbox_sources}) +target_link_libraries(tarantool_silverbox ltbox ${common_libraries}) + +add_executable(tarantool_feeder ${feeder_sources}) +target_link_libraries(tarantool_feeder ltfeeder ${common_libraries}) + +set_target_properties(tarantool_silverbox tarantool_feeder ltcommon + PROPERTIES COMPILE_FLAGS "${core_cflags}") diff --git a/core/Makefile b/core/Makefile deleted file mode 100644 index 3241278655c3463bb6841d573953881f74e25272..0000000000000000000000000000000000000000 --- a/core/Makefile +++ /dev/null @@ -1,33 +0,0 @@ -obj += core/coro.o -obj += core/fiber.o -obj += core/iproto.o -obj += core/log_io.o -obj += core/log_io_remote.o -obj += core/palloc.o -obj += core/pickle.o -obj += core/salloc.o -obj += core/say.o -obj += core/stat.o -obj += core/tarantool_ev.o -obj += core/tbuf.o -obj += core/util.o -obj += core/tarantool.o - -core/tarantool.o: tarantool_version.h - -core/tarantool_ev.o: CFLAGS += -U_FORTIFY_SOURCE \ - -Wno-comment \ - -Wno-extra \ - -Wno-parentheses \ - -Wno-unused - -ifeq (1,$(RESOLVE_SYMBOLS)) - LDFLAGS += -rdynamic -lbfd - CFLAGS += -DRESOLVE_SYMBOLS -endif - -ifneq (,$(TRACE)) - obj += core/trace.o - $(TRACE): CFLAGS += -finstrument-functions - LDFLAGS += -Wl,-Map=tarantool.map -endif diff --git a/core/admin.c b/core/admin.c index ce4176cc47058ee94ece8c5cc22b889f2994289c..000cd857641b9224f5e74e722cb1db1785cf6c3c 100644 --- a/core/admin.c +++ b/core/admin.c @@ -38,6 +38,7 @@ #include <say.h> #include <stat.h> #include <tarantool.h> +#include TARANTOOL_CONFIG #include <tbuf.h> #include <util.h> @@ -60,7 +61,7 @@ static const char *help = static const char unknown_command[] = "unknown command. try typing help." CRLF; -#line 64 "core/admin.c" +#line 65 "core/admin.c" static const int admin_start = 1; static const int admin_first_final = 108; static const int admin_error = 0; @@ -68,7 +69,7 @@ static const int admin_error = 0; static const int admin_en_main = 1; -#line 63 "core/admin.rl" +#line 64 "core/admin.rl" @@ -118,12 +119,12 @@ admin_dispatch(void) p = fiber->rbuf->data; -#line 122 "core/admin.c" +#line 123 "core/admin.c" { cs = admin_start; } -#line 127 "core/admin.c" +#line 128 "core/admin.c" { if ( p == pe ) goto _test_eof; @@ -185,17 +186,17 @@ case 6: } goto st0; tr12: -#line 179 "core/admin.rl" +#line 180 "core/admin.rl" {slab_validate(); ok(out);} goto st108; tr19: -#line 169 "core/admin.rl" +#line 170 "core/admin.rl" {return 0;} goto st108; tr28: -#line 165 "core/admin.rl" +#line 166 "core/admin.rl" {strend = p;} -#line 136 "core/admin.rl" +#line 137 "core/admin.rl" { start(out); mod_exec(strstart, strend - strstart, out); @@ -203,7 +204,7 @@ case 6: } goto st108; tr32: -#line 130 "core/admin.rl" +#line 131 "core/admin.rl" { start(out); tbuf_append(out, help, strlen(help)); @@ -211,7 +212,7 @@ case 6: } goto st108; tr43: -#line 142 "core/admin.rl" +#line 143 "core/admin.rl" { if (reload_cfg(err)) fail(out, err); @@ -220,15 +221,15 @@ case 6: } goto st108; tr66: -#line 176 "core/admin.rl" +#line 177 "core/admin.rl" {coredump(60); ok(out);} goto st108; tr75: -#line 177 "core/admin.rl" +#line 178 "core/admin.rl" {snapshot(NULL, 0); ok(out);} goto st108; tr92: -#line 112 "core/admin.rl" +#line 113 "core/admin.rl" { tarantool_cfg_iterator_t *i; char *key, *value; @@ -248,43 +249,43 @@ case 6: } goto st108; tr106: -#line 171 "core/admin.rl" +#line 172 "core/admin.rl" {start(out); fiber_info(out); end(out);} goto st108; tr112: -#line 170 "core/admin.rl" +#line 171 "core/admin.rl" {start(out); mod_info(out); end(out);} goto st108; tr117: -#line 174 "core/admin.rl" +#line 175 "core/admin.rl" {start(out); palloc_stat(out); end(out);} goto st108; tr125: -#line 173 "core/admin.rl" +#line 174 "core/admin.rl" {start(out); slab_stat(out); end(out);} goto st108; tr129: -#line 175 "core/admin.rl" +#line 176 "core/admin.rl" {start(out); stat_print(out);end(out);} goto st108; st108: if ( ++p == pe ) goto _test_eof108; case 108: -#line 275 "core/admin.c" +#line 276 "core/admin.c" goto st0; tr13: -#line 179 "core/admin.rl" +#line 180 "core/admin.rl" {slab_validate(); ok(out);} goto st7; tr20: -#line 169 "core/admin.rl" +#line 170 "core/admin.rl" {return 0;} goto st7; tr29: -#line 165 "core/admin.rl" +#line 166 "core/admin.rl" {strend = p;} -#line 136 "core/admin.rl" +#line 137 "core/admin.rl" { start(out); mod_exec(strstart, strend - strstart, out); @@ -292,7 +293,7 @@ case 108: } goto st7; tr33: -#line 130 "core/admin.rl" +#line 131 "core/admin.rl" { start(out); tbuf_append(out, help, strlen(help)); @@ -300,7 +301,7 @@ case 108: } goto st7; tr44: -#line 142 "core/admin.rl" +#line 143 "core/admin.rl" { if (reload_cfg(err)) fail(out, err); @@ -309,15 +310,15 @@ case 108: } goto st7; tr67: -#line 176 "core/admin.rl" +#line 177 "core/admin.rl" {coredump(60); ok(out);} goto st7; tr76: -#line 177 "core/admin.rl" +#line 178 "core/admin.rl" {snapshot(NULL, 0); ok(out);} goto st7; tr93: -#line 112 "core/admin.rl" +#line 113 "core/admin.rl" { tarantool_cfg_iterator_t *i; char *key, *value; @@ -337,30 +338,30 @@ case 108: } goto st7; tr107: -#line 171 "core/admin.rl" +#line 172 "core/admin.rl" {start(out); fiber_info(out); end(out);} goto st7; tr113: -#line 170 "core/admin.rl" +#line 171 "core/admin.rl" {start(out); mod_info(out); end(out);} goto st7; tr118: -#line 174 "core/admin.rl" +#line 175 "core/admin.rl" {start(out); palloc_stat(out); end(out);} goto st7; tr126: -#line 173 "core/admin.rl" +#line 174 "core/admin.rl" {start(out); slab_stat(out); end(out);} goto st7; tr130: -#line 175 "core/admin.rl" +#line 176 "core/admin.rl" {start(out); stat_print(out);end(out);} goto st7; st7: if ( ++p == pe ) goto _test_eof7; case 7: -#line 364 "core/admin.c" +#line 365 "core/admin.c" if ( (*p) == 10 ) goto st108; goto st0; @@ -441,28 +442,28 @@ case 15: } goto tr25; tr25: -#line 165 "core/admin.rl" +#line 166 "core/admin.rl" {strstart = p;} goto st16; st16: if ( ++p == pe ) goto _test_eof16; case 16: -#line 452 "core/admin.c" +#line 453 "core/admin.c" switch( (*p) ) { case 10: goto tr28; case 13: goto tr29; } goto st16; tr26: -#line 165 "core/admin.rl" +#line 166 "core/admin.rl" {strstart = p;} goto st17; st17: if ( ++p == pe ) goto _test_eof17; case 17: -#line 466 "core/admin.c" +#line 467 "core/admin.c" switch( (*p) ) { case 10: goto tr28; case 13: goto tr29; @@ -1426,7 +1427,7 @@ case 107: _out: {} } -#line 185 "core/admin.rl" +#line 186 "core/admin.rl" fiber->rbuf->len -= (void *)pe - (void *)fiber->rbuf->data; @@ -1468,4 +1469,5 @@ admin_init(void) * Local Variables: * mode: c * End: + * vim: syntax=c */ diff --git a/core/admin.rl b/core/admin.rl index 766239c9fa19086433b9d6c60b8961156f763ebe..896f203272e76750995755e5ee0c4ca8c061f834 100644 --- a/core/admin.rl +++ b/core/admin.rl @@ -36,6 +36,7 @@ #include <say.h> #include <stat.h> #include <tarantool.h> +#include TARANTOOL_CONFIG #include <tbuf.h> #include <util.h> @@ -223,4 +224,5 @@ admin_init(void) * Local Variables: * mode: c * End: + * vim: syntax=c */ diff --git a/core/coro.c b/core/coro.c index 13d2b6f58bac90e17c2fa0608620cc0a2c63c96e..13f0045f43ae625e4077156d5055a18535b0a649 100644 --- a/core/coro.c +++ b/core/coro.c @@ -28,9 +28,8 @@ #include <string.h> #include <sys/mman.h> -#include <third_party/coro/coro.h> +#include "third_party/valgrind/memcheck.h" -#include <debug.h> #include <coro.h> #include <palloc.h> diff --git a/core/fiber.c b/core/fiber.c index 9d6c71312238e4df0ab8e29dbd97052e9a4eac73..ec51d727b3923fe45dcabb05d500a5a5a014aab3 100644 --- a/core/fiber.c +++ b/core/fiber.c @@ -42,12 +42,12 @@ #include <third_party/queue.h> #include <third_party/khash.h> -#include <debug.h> #include <fiber.h> #include <palloc.h> #include <salloc.h> #include <say.h> #include <tarantool.h> +#include TARANTOOL_CONFIG #include <tarantool_ev.h> #include <tbuf.h> #include <util.h> @@ -92,11 +92,11 @@ static khash_t(fid2fiber) *fibers_registry; static void update_last_stack_frame(struct fiber *fiber) { -#ifdef BACKTRACE +#ifdef ENABLE_BACKTRACE fiber->last_stack_frame = frame_addess(); #else (void)fiber; -#endif +#endif /* ENABLE_BACKTRACE */ } void @@ -1068,11 +1068,11 @@ fiber_info(struct tbuf *out) tbuf_printf(out, " stack: %p\n", stack_top); tbuf_printf(out, " exc: %p\n", ((void **)fiber->exc)[3]); tbuf_printf(out, " exc_frame: %p, \n", ((void **)fiber->exc)[3] + 2 * sizeof(void *)); -#ifdef BACKTRACE +#ifdef ENABLE_BACKTRACE tbuf_printf(out, " backtrace:\n%s", backtrace(fiber->last_stack_frame, fiber->coro.stack, fiber->coro.stack_size)); -#endif +#endif /* ENABLE_BACKTRACE */ } } diff --git a/core/log_io.c b/core/log_io.c index 4b557d80119b805917a2dba4e7c9078cec8a1e07..c84c45e0d30e054f77c838976dd76aea12015b29 100644 --- a/core/log_io.c +++ b/core/log_io.c @@ -24,6 +24,7 @@ * SUCH DAMAGE. */ +#include "config.h" #include <dirent.h> #include <errno.h> #include <fcntl.h> @@ -574,7 +575,7 @@ flush_log(struct log_io *l) if (fflush(l->f) < 0) return -1; -#ifdef Linux +#ifdef TARGET_OS_LINUX if (fdatasync(fileno(l->f)) < 0) { say_syserror("fdatasync"); return -1; diff --git a/core/palloc.c b/core/palloc.c index d47e14eb75328964ee94253fdc2814b17d4cce88..b0209cbbd387ad4b4104b7da9e512da3bc1e5cdd 100644 --- a/core/palloc.c +++ b/core/palloc.c @@ -24,6 +24,7 @@ * SUCH DAMAGE. */ +#include "config.h" #include <stdint.h> #include <stddef.h> #include <stdbool.h> @@ -31,7 +32,7 @@ #include <string.h> #include <stdio.h> -#include <debug.h> +#include "third_party/valgrind/memcheck.h" #include <palloc.h> #include <util.h> #include <say.h> diff --git a/core/salloc.c b/core/salloc.c index 7a7843026680627a287df8386d51b6acb46fec88..675076e147a09a43eb316804fa73a23e0f93be38 100644 --- a/core/salloc.c +++ b/core/salloc.c @@ -31,7 +31,7 @@ #include <string.h> #include <sys/mman.h> -#include <debug.h> +#include "third_party/valgrind/memcheck.h" #include <third_party/queue.h> #include <salloc.h> #include <util.h> diff --git a/core/say.c b/core/say.c index 7477774c4ada65e496381597aa1f47f05787a9ac..c608a3c7b0f4be91397d258058ed9e9a25682de6 100644 --- a/core/say.c +++ b/core/say.c @@ -36,6 +36,7 @@ #include <fiber.h> #include <say.h> +#include TARANTOOL_CONFIG int sayfd = STDERR_FILENO; @@ -154,6 +155,8 @@ vsay(int level, const char *filename, int line, const char *error, const char *f void _say(int level, const char *filename, int line, const char *error, const char *format, ...) { + if (cfg.log_level < level) + return; va_list ap; va_start(ap, format); vsay(level, filename, line, error, format, ap); diff --git a/core/tarantool.c b/core/tarantool.c index 6128c729302bb37e76f15198ab6f57b9500fc448..9d5b6ddb0486312634427397dcf637947d45279b 100644 --- a/core/tarantool.c +++ b/core/tarantool.c @@ -24,6 +24,7 @@ * SUCH DAMAGE. */ +#include "config.h" #include <stdio.h> #include <stdlib.h> #include <string.h> @@ -37,7 +38,7 @@ #include <getopt.h> #include <libgen.h> #include <sysexits.h> -#ifdef Linux +#ifdef TARGET_OS_LINUX # include <sys/prctl.h> #endif #include <admin.h> @@ -49,9 +50,10 @@ #include <say.h> #include <stat.h> #include <tarantool.h> +#include TARANTOOL_CONFIG #include <util.h> #include <third_party/gopt/gopt.h> -#include <tarantool_version.h> + static pid_t master_pid; #define DEFAULT_CFG_FILENAME "tarantool.cfg" @@ -152,7 +154,7 @@ reload_cfg(struct tbuf *out) const char * tarantool_version(void) { - return tarantool_version_string; + return TARANTOOL_VERSION; } static double start_time; @@ -179,7 +181,7 @@ snapshot(void *ev __unused__, int events __unused__) set_proc_title("dumper (%" PRIu32 ")", getppid()); close_all_xcpt(1, sayfd); snapshot_save(recovery_state, mod_snapshot); -#ifdef COVERAGE +#ifdef ENABLE_GCOV __gcov_flush(); #endif _exit(EXIT_SUCCESS); @@ -206,7 +208,7 @@ sig_int(int signal) usleep(1000); } } -#ifdef COVERAGE +#ifdef ENABLE_GCOV __gcov_flush(); #endif @@ -475,7 +477,7 @@ main(int argc, char **argv) say_syserror("setrlimit"); exit(EX_OSERR); } -#ifdef Linux +#ifdef TARGET_OS_LINUX if (prctl(PR_SET_DUMPABLE, 1, 0, 0, 0) < 0) { say_syserror("prctl"); exit(EX_OSERR); diff --git a/core/tarantool_ev.c b/core/tarantool_ev.c index 763c39c821319cd8262324ea51113529354d78cb..ec67ce4a45a4c6aca8ff2658852a58387fdbf31f 100644 --- a/core/tarantool_ev.c +++ b/core/tarantool_ev.c @@ -24,5 +24,5 @@ * SUCH DAMAGE. */ -#include <tarantool_ev.h> -#include <third_party/libev/ev.c> +#include "tarantool_ev.h" +#include "third_party/libev/ev.c" diff --git a/core/util.c b/core/util.c index 968fd561b0a63d0d33bdf84faeda2edb94d890ce..4bc8772f6b2c0c0a9bd662561abb56ee8c09109a 100644 --- a/core/util.c +++ b/core/util.c @@ -24,6 +24,7 @@ * SUCH DAMAGE. */ +#include "config.h" #include <stdarg.h> #include <stdbool.h> #include <stdio.h> @@ -34,9 +35,9 @@ #include <time.h> #include <unistd.h> -#ifdef RESOLVE_SYMBOLS +#ifdef HAVE_BFD #include <bfd.h> -#endif +#endif /* HAVE_BFD */ #include <util.h> #include <fiber.h> @@ -83,7 +84,7 @@ coredump(int dump_interval) if (fork() == 0) { close_all_xcpt(0); -#ifdef COVERAGE +#ifdef ENABLE_GCOV __gcov_flush(); #endif abort(); @@ -99,7 +100,7 @@ xrealloc(void *ptr, size_t size) return ret; } -#ifdef BACKTRACE +#ifdef ENABLE_BACKTRACE /* * we use global static buffer because it is too late to do @@ -135,24 +136,24 @@ backtrace(void *frame_, void *stack, size_t stack_size) p += r; len -= r; -#ifdef RESOLVE_SYMBOLS +#ifdef HAVE_BFD struct symbol *s = addr2symbol(frame->ret); if (s != NULL) { - r = snprintf(p, len, " <%s+%i> ", s->name, frame->ret - s->addr); + r = snprintf(p, len, " <%s+%ld> ", s->name, frame->ret - s->addr); if (r >= len) goto out; p += r; len -= r; } -#endif +#endif /* HAVE_BFD */ r = snprintf(p, len, " }\r\n"); if (r >= len) goto out; p += r; len -= r; -#ifdef RESOLVE_SYMBOLS +#ifdef HAVE_BFD if (s != NULL && strcmp(s->name, "main") == 0) break; @@ -165,15 +166,15 @@ backtrace(void *frame_, void *stack, size_t stack_size) *p = 0; return backtrace_buf; } -#endif +#endif /* ENABLE_BACKTRACE */ void __attribute__ ((noreturn)) assert_fail(const char *assertion, const char *file, unsigned int line, const char *function) { fprintf(stderr, "%s:%i: %s: assertion %s failed.\n", file, line, function, assertion); -#ifdef BACKTRACE - void *frame = frame_addess(); +#ifdef ENABLE_BACKTRACE + void *frame = __builtin_frame_address(0); void *stack_top; size_t stack_size; @@ -186,12 +187,12 @@ assert_fail(const char *assertion, const char *file, unsigned int line, const ch } fprintf(stderr, "%s", backtrace(frame, stack_top, stack_size)); -#endif +#endif /* ENABLE_BACKTRACE */ close_all_xcpt(0); abort(); } -#ifdef RESOLVE_SYMBOLS +#ifdef HAVE_BFD static struct symbol *symbols; static size_t symbol_count; @@ -313,4 +314,4 @@ addr2symbol(void *addr) return NULL; } -#endif +#endif /* HAVE_BFD */ diff --git a/include/config.h.cmake b/include/config.h.cmake new file mode 100644 index 0000000000000000000000000000000000000000..3bd80eb234c8635e716c4e9341743e21fdaca49a --- /dev/null +++ b/include/config.h.cmake @@ -0,0 +1,37 @@ +#ifndef TARANTOOL_CONFIG_H_INCLUDED +#define TARANTOOL_CONFIG_H_INCLUDED +/* + * This file is generated by CMake. The original file is called + * config.h.cmake. Please do not modify. + */ +/* + A string with major-minor-patch-commit-id identifier of the + * release. + */ +#define TARANTOOL_VERSION "@TARANTOOL_VERSION@" +/* Defined if building for Linux */ +#cmakedefine TARGET_OS_LINUX 1 +/* Defined if building for FreeBSD */ +#cmakedefine TARGET_OS_FREEBSD 1 +/* + * Defined if gcov instrumentation should be enabled. + */ +#cmakedefine ENABLE_GCOV 1 +/* + * Defined if configured with ENABLE_TRACE (debug trace into + * a file specified by TRANTOOL_TRACE environment variable. + */ +#cmakedefine ENABLE_TRACE 1 +/* + * Defined if configured with ENABLE_BACKTRACE ('show fiber' + * showing fiber call stack. + */ +#cmakedefine ENABLE_BACKTRACE 1 +/* + * Set if the system has bfd.h header and GNU bfd library. + */ +#cmakedefine HAVE_BFD 1 +/* + * vim: syntax=c + */ +#endif /* TARANTOOL_CONFIG_H_INCLUDED */ diff --git a/include/debug.h b/include/debug.h deleted file mode 100644 index 14d0f29ce24704c65b75cba4bda0aad7f053536a..0000000000000000000000000000000000000000 --- a/include/debug.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (C) 2010 Mail.RU - * Copyright (C) 2010 Yuriy Vostrikov - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef TARANTOOL_DEBUG_H -#define TARANTOOL_DEBUG_H - -#ifdef HAVE_VALGRIND -# include <third_party/valgrind/valgrind.h> -# include <third_party/valgrind/memcheck.h> -#else -# define VALGRIND_CREATE_MEMPOOL(a,b,c) -# define VALGRIND_DESTROY_MEMPOOL(a) -# define VALGRIND_MEMPOOL_TRIM(a,b,c) -# define VALGRIND_MEMPOOL_ALLOC(a,b,c) -# define VALGRIND_STACK_REGISTER(a,b) -# define VALGRIND_MAKE_MEM_DEFINED(a,b) -# define VALGRIND_MALLOCLIKE_BLOCK(a,b,c,d) -# define VALGRIND_FREELIKE_BLOCK(a,b) -# define VALGRIND_MAKE_MEM_UNDEFINED(a,b) -#endif -#endif diff --git a/include/say.h b/include/say.h index ff5da1402ae4ef5829f17ff6c6458125c5efe285..a0cce235304cf7003db36c8b24a26d5ac17773c6 100644 --- a/include/say.h +++ b/include/say.h @@ -52,7 +52,7 @@ void _say(int level, const char *filename, int line, const char *error, const char *format, ...) __attribute__ ((format(FORMAT_PRINTF, 5, 6))); -#define say(level, ...) ({ if(cfg.log_level >= level) _say(level, __FILE__, __LINE__, __VA_ARGS__); }) +#define say(level, ...) ({ _say(level, __FILE__, __LINE__, __VA_ARGS__); }) #define panic(...) ({ say(S_FATAL, NULL, __VA_ARGS__); exit(EXIT_FAILURE); }) #define panic_syserror(...) ({ say(S_FATAL, strerror(errno), __VA_ARGS__); exit(EXIT_FAILURE); }) diff --git a/include/tarantool.h b/include/tarantool.h index f5eeafb70c2d2fb00769ae5142915791cfcfe892..47f16641823ea968218ee10c2ffc4744ed55094f 100644 --- a/include/tarantool.h +++ b/include/tarantool.h @@ -24,16 +24,16 @@ * SUCH DAMAGE. */ -#ifndef TARANUL_H -#define TARANUL_H +#ifndef TARANTOOL_H +#define TARANTOOL_H #include <tbuf.h> #include <util.h> #include <log_io.h> -#include TARANTOOL_CONFIG struct recovery_state *recovery_state; void mod_init(void); +struct tarantool_cfg; i32 mod_check_config(struct tarantool_cfg *conf); void mod_reload_config(struct tarantool_cfg *old_conf, struct tarantool_cfg *new_conf); int mod_cat(const char *filename); @@ -56,4 +56,4 @@ double tarantool_uptime(void); char **init_set_proc_title(int argc, char **argv); void set_proc_title(const char *format, ...); -#endif +#endif /* TARANTOOL_H */ diff --git a/include/util.h b/include/util.h index ddbff310dbca5efc02503c3d45cb1c824c208561..dc3ccbd9ca516c983d4d8e242a8c1cb093b6e4df 100644 --- a/include/util.h +++ b/include/util.h @@ -117,13 +117,11 @@ void __gcov_flush(); extern void *__libc_stack_end; -#if __GNUC__ && (defined(__x86) || defined (__amd64) || defined(__i386)) -#define BACKTRACE -#define frame_addess() __builtin_frame_address(0) +#ifdef ENABLE_BACKTRACE char *backtrace(void *frame, void *stack, size_t stack_size); -#endif +#endif /* ENABLE_BACKTRACE */ -#ifdef RESOLVE_SYMBOLS +#ifdef HAVE_BFD struct symbol { void *addr; const char *name; @@ -131,7 +129,7 @@ struct symbol { }; struct symbol *addr2symbol(void *addr); void load_symbols(const char *name); -#endif +#endif /* HAVE_BFD */ #ifdef NDEBUG # define assert(pred) (void)(0) diff --git a/mod/feeder/Makefile b/mod/feeder/Makefile deleted file mode 100644 index 106ee0f7262ff9404d86d49bbec1d88d780899db..0000000000000000000000000000000000000000 --- a/mod/feeder/Makefile +++ /dev/null @@ -1,5 +0,0 @@ -core/tarantool.o: CFLAGS += -DUTILITY - -obj += mod/feeder/feeder.o -cfg_tmpl += mod/feeder/feeder_cfg.cfg_tmpl - diff --git a/mod/feeder/feeder.c b/mod/feeder/feeder.c index b6629b778d4b12881e2bf570a928078375537ad5..d9454a39d6b91df8131b04eb982e5c88f26bcb43 100644 --- a/mod/feeder/feeder.c +++ b/mod/feeder/feeder.c @@ -30,6 +30,7 @@ #include <fiber.h> #include <util.h> +#include "cfg/tarantool_feeder_cfg.h" static char *custom_proc_title; diff --git a/mod/silverbox/Makefile b/mod/silverbox/Makefile deleted file mode 100644 index b11c787c5ec40156a482752ed7db7f9978bda75d..0000000000000000000000000000000000000000 --- a/mod/silverbox/Makefile +++ /dev/null @@ -1,9 +0,0 @@ -core/tarantool.o: CFLAGS += -DSTORAGE - -obj += core/admin.o -obj += mod/silverbox/box.o -obj += mod/silverbox/index.o -obj += mod/silverbox/memcached.o -obj += third_party/qsort_arg.o - -cfg_tmpl += mod/silverbox/box_cfg.cfg_tmpl diff --git a/mod/silverbox/box.c b/mod/silverbox/box.c index d4653b5581cfbb95fe2f326eafda9d82ced71fd6..1b2cb587469668f8822df56c46bd09de3209f939 100644 --- a/mod/silverbox/box.c +++ b/mod/silverbox/box.c @@ -40,6 +40,7 @@ #include <tbuf.h> #include <util.h> +#include <cfg/tarantool_silverbox_cfg.h> #include <mod/silverbox/box.h> #include <mod/silverbox/index.h> diff --git a/mod/silverbox/box.h b/mod/silverbox/box.h index a8cd2bf1467abf82335c39742a3dd8a8e360db8d..2f77fcb75a87c377111f2833877af8418bf44422 100644 --- a/mod/silverbox/box.h +++ b/mod/silverbox/box.h @@ -107,7 +107,7 @@ enum box_mode { _(UPDATE_FIELDS_OLD, 16) _(JUBOX_ALIVE, 11) - DO NOT use those ids! + DO NOT use these ids! */ #define MESSAGES(_) \ _(INSERT, 13) \ diff --git a/mod/silverbox/memcached.c b/mod/silverbox/memcached.c index 126e548df578bd3612922ffb01616d898438eece..c6100fdc388ae1847118b6a4f4d8ca23801ed4a1 100644 --- a/mod/silverbox/memcached.c +++ b/mod/silverbox/memcached.c @@ -39,6 +39,7 @@ #include <pickle.h> #include <tarantool.h> +#include <cfg/tarantool_silverbox_cfg.h> #include <mod/silverbox/box.h> #include <stat.h> @@ -65,7 +66,7 @@ struct meta { } __packed__; -#line 69 "mod/silverbox/memcached.c" +#line 70 "mod/silverbox/memcached.c" static const int memcached_start = 1; static const int memcached_first_final = 197; static const int memcached_error = 0; @@ -73,7 +74,7 @@ static const int memcached_error = 0; static const int memcached_en_main = 1; -#line 68 "mod/silverbox/memcached.rl" +#line 69 "mod/silverbox/memcached.rl" @@ -262,12 +263,12 @@ memcached_dispatch(struct box_txn *txn) }) -#line 266 "mod/silverbox/memcached.c" +#line 267 "mod/silverbox/memcached.c" { cs = memcached_start; } -#line 271 "mod/silverbox/memcached.c" +#line 272 "mod/silverbox/memcached.c" { if ( p == pe ) goto _test_eof; @@ -325,7 +326,7 @@ case 5: goto st0; goto tr15; tr15: -#line 477 "mod/silverbox/memcached.rl" +#line 478 "mod/silverbox/memcached.rl" { fstart = p; for (; p < pe && *p != ' ' && *p != '\r' && *p != '\n'; p++); @@ -342,7 +343,7 @@ case 5: if ( ++p == pe ) goto _test_eof6; case 6: -#line 346 "mod/silverbox/memcached.c" +#line 347 "mod/silverbox/memcached.c" if ( (*p) == 32 ) goto st7; goto st0; @@ -356,49 +357,49 @@ case 7: goto tr17; goto st0; tr17: -#line 476 "mod/silverbox/memcached.rl" +#line 477 "mod/silverbox/memcached.rl" { fstart = p; } goto st8; st8: if ( ++p == pe ) goto _test_eof8; case 8: -#line 367 "mod/silverbox/memcached.c" +#line 368 "mod/silverbox/memcached.c" if ( (*p) == 32 ) goto tr18; if ( 48 <= (*p) && (*p) <= 57 ) goto st8; goto st0; tr18: -#line 500 "mod/silverbox/memcached.rl" +#line 501 "mod/silverbox/memcached.rl" {flags = natoq(fstart, p);} goto st9; st9: if ( ++p == pe ) goto _test_eof9; case 9: -#line 381 "mod/silverbox/memcached.c" +#line 382 "mod/silverbox/memcached.c" if ( (*p) == 32 ) goto st9; if ( 48 <= (*p) && (*p) <= 57 ) goto tr21; goto st0; tr21: -#line 476 "mod/silverbox/memcached.rl" +#line 477 "mod/silverbox/memcached.rl" { fstart = p; } goto st10; st10: if ( ++p == pe ) goto _test_eof10; case 10: -#line 395 "mod/silverbox/memcached.c" +#line 396 "mod/silverbox/memcached.c" if ( (*p) == 32 ) goto tr22; if ( 48 <= (*p) && (*p) <= 57 ) goto st10; goto st0; tr22: -#line 493 "mod/silverbox/memcached.rl" +#line 494 "mod/silverbox/memcached.rl" { exptime = natoq(fstart, p); if (exptime > 0 && exptime <= 60*60*24*30) @@ -409,21 +410,21 @@ case 10: if ( ++p == pe ) goto _test_eof11; case 11: -#line 413 "mod/silverbox/memcached.c" +#line 414 "mod/silverbox/memcached.c" if ( (*p) == 32 ) goto st11; if ( 48 <= (*p) && (*p) <= 57 ) goto tr25; goto st0; tr25: -#line 476 "mod/silverbox/memcached.rl" +#line 477 "mod/silverbox/memcached.rl" { fstart = p; } goto st12; st12: if ( ++p == pe ) goto _test_eof12; case 12: -#line 427 "mod/silverbox/memcached.c" +#line 428 "mod/silverbox/memcached.c" switch( (*p) ) { case 10: goto tr26; case 13: goto tr27; @@ -433,11 +434,11 @@ case 12: goto st12; goto st0; tr26: -#line 501 "mod/silverbox/memcached.rl" +#line 502 "mod/silverbox/memcached.rl" {bytes = natoq(fstart, p);} -#line 533 "mod/silverbox/memcached.rl" +#line 534 "mod/silverbox/memcached.rl" { p++; } -#line 506 "mod/silverbox/memcached.rl" +#line 507 "mod/silverbox/memcached.rl" { size_t parsed = p - (u8 *)fiber->rbuf->data; while (fiber->rbuf->len - parsed < bytes + 2) { @@ -458,13 +459,13 @@ case 12: goto exit; } } -#line 527 "mod/silverbox/memcached.rl" +#line 528 "mod/silverbox/memcached.rl" { done = true; stats.bytes_read += p - (u8 *)fiber->rbuf->data; tbuf_peek(fiber->rbuf, p - (u8 *)fiber->rbuf->data); } -#line 261 "mod/silverbox/memcached.rl" +#line 262 "mod/silverbox/memcached.rl" { key = read_field(keys); struct box_tuple *tuple = find(key); @@ -475,9 +476,9 @@ case 12: } goto st197; tr30: -#line 533 "mod/silverbox/memcached.rl" +#line 534 "mod/silverbox/memcached.rl" { p++; } -#line 506 "mod/silverbox/memcached.rl" +#line 507 "mod/silverbox/memcached.rl" { size_t parsed = p - (u8 *)fiber->rbuf->data; while (fiber->rbuf->len - parsed < bytes + 2) { @@ -498,13 +499,13 @@ case 12: goto exit; } } -#line 527 "mod/silverbox/memcached.rl" +#line 528 "mod/silverbox/memcached.rl" { done = true; stats.bytes_read += p - (u8 *)fiber->rbuf->data; tbuf_peek(fiber->rbuf, p - (u8 *)fiber->rbuf->data); } -#line 261 "mod/silverbox/memcached.rl" +#line 262 "mod/silverbox/memcached.rl" { key = read_field(keys); struct box_tuple *tuple = find(key); @@ -515,11 +516,11 @@ case 12: } goto st197; tr39: -#line 535 "mod/silverbox/memcached.rl" +#line 536 "mod/silverbox/memcached.rl" { noreply = true; } -#line 533 "mod/silverbox/memcached.rl" +#line 534 "mod/silverbox/memcached.rl" { p++; } -#line 506 "mod/silverbox/memcached.rl" +#line 507 "mod/silverbox/memcached.rl" { size_t parsed = p - (u8 *)fiber->rbuf->data; while (fiber->rbuf->len - parsed < bytes + 2) { @@ -540,13 +541,13 @@ case 12: goto exit; } } -#line 527 "mod/silverbox/memcached.rl" +#line 528 "mod/silverbox/memcached.rl" { done = true; stats.bytes_read += p - (u8 *)fiber->rbuf->data; tbuf_peek(fiber->rbuf, p - (u8 *)fiber->rbuf->data); } -#line 261 "mod/silverbox/memcached.rl" +#line 262 "mod/silverbox/memcached.rl" { key = read_field(keys); struct box_tuple *tuple = find(key); @@ -557,11 +558,11 @@ case 12: } goto st197; tr58: -#line 501 "mod/silverbox/memcached.rl" +#line 502 "mod/silverbox/memcached.rl" {bytes = natoq(fstart, p);} -#line 533 "mod/silverbox/memcached.rl" +#line 534 "mod/silverbox/memcached.rl" { p++; } -#line 506 "mod/silverbox/memcached.rl" +#line 507 "mod/silverbox/memcached.rl" { size_t parsed = p - (u8 *)fiber->rbuf->data; while (fiber->rbuf->len - parsed < bytes + 2) { @@ -582,13 +583,13 @@ case 12: goto exit; } } -#line 527 "mod/silverbox/memcached.rl" +#line 528 "mod/silverbox/memcached.rl" { done = true; stats.bytes_read += p - (u8 *)fiber->rbuf->data; tbuf_peek(fiber->rbuf, p - (u8 *)fiber->rbuf->data); } -#line 290 "mod/silverbox/memcached.rl" +#line 291 "mod/silverbox/memcached.rl" { struct tbuf *b; void *value; @@ -617,9 +618,9 @@ case 12: } goto st197; tr62: -#line 533 "mod/silverbox/memcached.rl" +#line 534 "mod/silverbox/memcached.rl" { p++; } -#line 506 "mod/silverbox/memcached.rl" +#line 507 "mod/silverbox/memcached.rl" { size_t parsed = p - (u8 *)fiber->rbuf->data; while (fiber->rbuf->len - parsed < bytes + 2) { @@ -640,13 +641,13 @@ case 12: goto exit; } } -#line 527 "mod/silverbox/memcached.rl" +#line 528 "mod/silverbox/memcached.rl" { done = true; stats.bytes_read += p - (u8 *)fiber->rbuf->data; tbuf_peek(fiber->rbuf, p - (u8 *)fiber->rbuf->data); } -#line 290 "mod/silverbox/memcached.rl" +#line 291 "mod/silverbox/memcached.rl" { struct tbuf *b; void *value; @@ -675,11 +676,11 @@ case 12: } goto st197; tr71: -#line 535 "mod/silverbox/memcached.rl" +#line 536 "mod/silverbox/memcached.rl" { noreply = true; } -#line 533 "mod/silverbox/memcached.rl" +#line 534 "mod/silverbox/memcached.rl" { p++; } -#line 506 "mod/silverbox/memcached.rl" +#line 507 "mod/silverbox/memcached.rl" { size_t parsed = p - (u8 *)fiber->rbuf->data; while (fiber->rbuf->len - parsed < bytes + 2) { @@ -700,13 +701,13 @@ case 12: goto exit; } } -#line 527 "mod/silverbox/memcached.rl" +#line 528 "mod/silverbox/memcached.rl" { done = true; stats.bytes_read += p - (u8 *)fiber->rbuf->data; tbuf_peek(fiber->rbuf, p - (u8 *)fiber->rbuf->data); } -#line 290 "mod/silverbox/memcached.rl" +#line 291 "mod/silverbox/memcached.rl" { struct tbuf *b; void *value; @@ -735,11 +736,11 @@ case 12: } goto st197; tr91: -#line 502 "mod/silverbox/memcached.rl" +#line 503 "mod/silverbox/memcached.rl" {cas = natoq(fstart, p);} -#line 533 "mod/silverbox/memcached.rl" +#line 534 "mod/silverbox/memcached.rl" { p++; } -#line 506 "mod/silverbox/memcached.rl" +#line 507 "mod/silverbox/memcached.rl" { size_t parsed = p - (u8 *)fiber->rbuf->data; while (fiber->rbuf->len - parsed < bytes + 2) { @@ -760,13 +761,13 @@ case 12: goto exit; } } -#line 527 "mod/silverbox/memcached.rl" +#line 528 "mod/silverbox/memcached.rl" { done = true; stats.bytes_read += p - (u8 *)fiber->rbuf->data; tbuf_peek(fiber->rbuf, p - (u8 *)fiber->rbuf->data); } -#line 279 "mod/silverbox/memcached.rl" +#line 280 "mod/silverbox/memcached.rl" { key = read_field(keys); struct box_tuple *tuple = find(key); @@ -779,9 +780,9 @@ case 12: } goto st197; tr95: -#line 533 "mod/silverbox/memcached.rl" +#line 534 "mod/silverbox/memcached.rl" { p++; } -#line 506 "mod/silverbox/memcached.rl" +#line 507 "mod/silverbox/memcached.rl" { size_t parsed = p - (u8 *)fiber->rbuf->data; while (fiber->rbuf->len - parsed < bytes + 2) { @@ -802,13 +803,13 @@ case 12: goto exit; } } -#line 527 "mod/silverbox/memcached.rl" +#line 528 "mod/silverbox/memcached.rl" { done = true; stats.bytes_read += p - (u8 *)fiber->rbuf->data; tbuf_peek(fiber->rbuf, p - (u8 *)fiber->rbuf->data); } -#line 279 "mod/silverbox/memcached.rl" +#line 280 "mod/silverbox/memcached.rl" { key = read_field(keys); struct box_tuple *tuple = find(key); @@ -821,11 +822,11 @@ case 12: } goto st197; tr105: -#line 535 "mod/silverbox/memcached.rl" +#line 536 "mod/silverbox/memcached.rl" { noreply = true; } -#line 533 "mod/silverbox/memcached.rl" +#line 534 "mod/silverbox/memcached.rl" { p++; } -#line 506 "mod/silverbox/memcached.rl" +#line 507 "mod/silverbox/memcached.rl" { size_t parsed = p - (u8 *)fiber->rbuf->data; while (fiber->rbuf->len - parsed < bytes + 2) { @@ -846,13 +847,13 @@ case 12: goto exit; } } -#line 527 "mod/silverbox/memcached.rl" +#line 528 "mod/silverbox/memcached.rl" { done = true; stats.bytes_read += p - (u8 *)fiber->rbuf->data; tbuf_peek(fiber->rbuf, p - (u8 *)fiber->rbuf->data); } -#line 279 "mod/silverbox/memcached.rl" +#line 280 "mod/silverbox/memcached.rl" { key = read_field(keys); struct box_tuple *tuple = find(key); @@ -865,17 +866,17 @@ case 12: } goto st197; tr118: -#line 503 "mod/silverbox/memcached.rl" +#line 504 "mod/silverbox/memcached.rl" {incr = natoq(fstart, p);} -#line 533 "mod/silverbox/memcached.rl" +#line 534 "mod/silverbox/memcached.rl" { p++; } -#line 527 "mod/silverbox/memcached.rl" +#line 528 "mod/silverbox/memcached.rl" { done = true; stats.bytes_read += p - (u8 *)fiber->rbuf->data; tbuf_peek(fiber->rbuf, p - (u8 *)fiber->rbuf->data); } -#line 317 "mod/silverbox/memcached.rl" +#line 318 "mod/silverbox/memcached.rl" { struct meta *m; struct tbuf *b; @@ -928,15 +929,15 @@ case 12: } goto st197; tr122: -#line 533 "mod/silverbox/memcached.rl" +#line 534 "mod/silverbox/memcached.rl" { p++; } -#line 527 "mod/silverbox/memcached.rl" +#line 528 "mod/silverbox/memcached.rl" { done = true; stats.bytes_read += p - (u8 *)fiber->rbuf->data; tbuf_peek(fiber->rbuf, p - (u8 *)fiber->rbuf->data); } -#line 317 "mod/silverbox/memcached.rl" +#line 318 "mod/silverbox/memcached.rl" { struct meta *m; struct tbuf *b; @@ -989,17 +990,17 @@ case 12: } goto st197; tr132: -#line 535 "mod/silverbox/memcached.rl" +#line 536 "mod/silverbox/memcached.rl" { noreply = true; } -#line 533 "mod/silverbox/memcached.rl" +#line 534 "mod/silverbox/memcached.rl" { p++; } -#line 527 "mod/silverbox/memcached.rl" +#line 528 "mod/silverbox/memcached.rl" { done = true; stats.bytes_read += p - (u8 *)fiber->rbuf->data; tbuf_peek(fiber->rbuf, p - (u8 *)fiber->rbuf->data); } -#line 317 "mod/silverbox/memcached.rl" +#line 318 "mod/silverbox/memcached.rl" { struct meta *m; struct tbuf *b; @@ -1052,15 +1053,15 @@ case 12: } goto st197; tr141: -#line 533 "mod/silverbox/memcached.rl" +#line 534 "mod/silverbox/memcached.rl" { p++; } -#line 527 "mod/silverbox/memcached.rl" +#line 528 "mod/silverbox/memcached.rl" { done = true; stats.bytes_read += p - (u8 *)fiber->rbuf->data; tbuf_peek(fiber->rbuf, p - (u8 *)fiber->rbuf->data); } -#line 368 "mod/silverbox/memcached.rl" +#line 369 "mod/silverbox/memcached.rl" { key = read_field(keys); struct box_tuple *tuple = find(key); @@ -1075,21 +1076,21 @@ case 12: } goto st197; tr146: -#line 493 "mod/silverbox/memcached.rl" +#line 494 "mod/silverbox/memcached.rl" { exptime = natoq(fstart, p); if (exptime > 0 && exptime <= 60*60*24*30) exptime = exptime + ev_now(); } -#line 533 "mod/silverbox/memcached.rl" +#line 534 "mod/silverbox/memcached.rl" { p++; } -#line 527 "mod/silverbox/memcached.rl" +#line 528 "mod/silverbox/memcached.rl" { done = true; stats.bytes_read += p - (u8 *)fiber->rbuf->data; tbuf_peek(fiber->rbuf, p - (u8 *)fiber->rbuf->data); } -#line 368 "mod/silverbox/memcached.rl" +#line 369 "mod/silverbox/memcached.rl" { key = read_field(keys); struct box_tuple *tuple = find(key); @@ -1104,17 +1105,17 @@ case 12: } goto st197; tr157: -#line 535 "mod/silverbox/memcached.rl" +#line 536 "mod/silverbox/memcached.rl" { noreply = true; } -#line 533 "mod/silverbox/memcached.rl" +#line 534 "mod/silverbox/memcached.rl" { p++; } -#line 527 "mod/silverbox/memcached.rl" +#line 528 "mod/silverbox/memcached.rl" { done = true; stats.bytes_read += p - (u8 *)fiber->rbuf->data; tbuf_peek(fiber->rbuf, p - (u8 *)fiber->rbuf->data); } -#line 368 "mod/silverbox/memcached.rl" +#line 369 "mod/silverbox/memcached.rl" { key = read_field(keys); struct box_tuple *tuple = find(key); @@ -1129,15 +1130,15 @@ case 12: } goto st197; tr169: -#line 533 "mod/silverbox/memcached.rl" +#line 534 "mod/silverbox/memcached.rl" { p++; } -#line 527 "mod/silverbox/memcached.rl" +#line 528 "mod/silverbox/memcached.rl" { done = true; stats.bytes_read += p - (u8 *)fiber->rbuf->data; tbuf_peek(fiber->rbuf, p - (u8 *)fiber->rbuf->data); } -#line 458 "mod/silverbox/memcached.rl" +#line 459 "mod/silverbox/memcached.rl" { if (flush_delay > 0) { struct fiber *f = fiber_create("flush_all", -1, -1, flush_all, (void *)flush_delay); @@ -1149,17 +1150,17 @@ case 12: } goto st197; tr174: -#line 504 "mod/silverbox/memcached.rl" +#line 505 "mod/silverbox/memcached.rl" {flush_delay = natoq(fstart, p);} -#line 533 "mod/silverbox/memcached.rl" +#line 534 "mod/silverbox/memcached.rl" { p++; } -#line 527 "mod/silverbox/memcached.rl" +#line 528 "mod/silverbox/memcached.rl" { done = true; stats.bytes_read += p - (u8 *)fiber->rbuf->data; tbuf_peek(fiber->rbuf, p - (u8 *)fiber->rbuf->data); } -#line 458 "mod/silverbox/memcached.rl" +#line 459 "mod/silverbox/memcached.rl" { if (flush_delay > 0) { struct fiber *f = fiber_create("flush_all", -1, -1, flush_all, (void *)flush_delay); @@ -1171,17 +1172,17 @@ case 12: } goto st197; tr185: -#line 535 "mod/silverbox/memcached.rl" +#line 536 "mod/silverbox/memcached.rl" { noreply = true; } -#line 533 "mod/silverbox/memcached.rl" +#line 534 "mod/silverbox/memcached.rl" { p++; } -#line 527 "mod/silverbox/memcached.rl" +#line 528 "mod/silverbox/memcached.rl" { done = true; stats.bytes_read += p - (u8 *)fiber->rbuf->data; tbuf_peek(fiber->rbuf, p - (u8 *)fiber->rbuf->data); } -#line 458 "mod/silverbox/memcached.rl" +#line 459 "mod/silverbox/memcached.rl" { if (flush_delay > 0) { struct fiber *f = fiber_create("flush_all", -1, -1, flush_all, (void *)flush_delay); @@ -1193,15 +1194,15 @@ case 12: } goto st197; tr195: -#line 533 "mod/silverbox/memcached.rl" +#line 534 "mod/silverbox/memcached.rl" { p++; } -#line 527 "mod/silverbox/memcached.rl" +#line 528 "mod/silverbox/memcached.rl" { done = true; stats.bytes_read += p - (u8 *)fiber->rbuf->data; tbuf_peek(fiber->rbuf, p - (u8 *)fiber->rbuf->data); } -#line 381 "mod/silverbox/memcached.rl" +#line 382 "mod/silverbox/memcached.rl" { txn->op = SELECT; fiber_register_cleanup((void *)txn_cleanup, txn); @@ -1280,25 +1281,25 @@ case 12: } goto st197; tr213: -#line 533 "mod/silverbox/memcached.rl" +#line 534 "mod/silverbox/memcached.rl" { p++; } -#line 527 "mod/silverbox/memcached.rl" +#line 528 "mod/silverbox/memcached.rl" { done = true; stats.bytes_read += p - (u8 *)fiber->rbuf->data; tbuf_peek(fiber->rbuf, p - (u8 *)fiber->rbuf->data); } -#line 472 "mod/silverbox/memcached.rl" +#line 473 "mod/silverbox/memcached.rl" { return 0; } goto st197; tr233: -#line 501 "mod/silverbox/memcached.rl" +#line 502 "mod/silverbox/memcached.rl" {bytes = natoq(fstart, p);} -#line 533 "mod/silverbox/memcached.rl" +#line 534 "mod/silverbox/memcached.rl" { p++; } -#line 506 "mod/silverbox/memcached.rl" +#line 507 "mod/silverbox/memcached.rl" { size_t parsed = p - (u8 *)fiber->rbuf->data; while (fiber->rbuf->len - parsed < bytes + 2) { @@ -1319,13 +1320,13 @@ case 12: goto exit; } } -#line 527 "mod/silverbox/memcached.rl" +#line 528 "mod/silverbox/memcached.rl" { done = true; stats.bytes_read += p - (u8 *)fiber->rbuf->data; tbuf_peek(fiber->rbuf, p - (u8 *)fiber->rbuf->data); } -#line 270 "mod/silverbox/memcached.rl" +#line 271 "mod/silverbox/memcached.rl" { key = read_field(keys); struct box_tuple *tuple = find(key); @@ -1336,9 +1337,9 @@ case 12: } goto st197; tr237: -#line 533 "mod/silverbox/memcached.rl" +#line 534 "mod/silverbox/memcached.rl" { p++; } -#line 506 "mod/silverbox/memcached.rl" +#line 507 "mod/silverbox/memcached.rl" { size_t parsed = p - (u8 *)fiber->rbuf->data; while (fiber->rbuf->len - parsed < bytes + 2) { @@ -1359,13 +1360,13 @@ case 12: goto exit; } } -#line 527 "mod/silverbox/memcached.rl" +#line 528 "mod/silverbox/memcached.rl" { done = true; stats.bytes_read += p - (u8 *)fiber->rbuf->data; tbuf_peek(fiber->rbuf, p - (u8 *)fiber->rbuf->data); } -#line 270 "mod/silverbox/memcached.rl" +#line 271 "mod/silverbox/memcached.rl" { key = read_field(keys); struct box_tuple *tuple = find(key); @@ -1376,11 +1377,11 @@ case 12: } goto st197; tr246: -#line 535 "mod/silverbox/memcached.rl" +#line 536 "mod/silverbox/memcached.rl" { noreply = true; } -#line 533 "mod/silverbox/memcached.rl" +#line 534 "mod/silverbox/memcached.rl" { p++; } -#line 506 "mod/silverbox/memcached.rl" +#line 507 "mod/silverbox/memcached.rl" { size_t parsed = p - (u8 *)fiber->rbuf->data; while (fiber->rbuf->len - parsed < bytes + 2) { @@ -1401,13 +1402,13 @@ case 12: goto exit; } } -#line 527 "mod/silverbox/memcached.rl" +#line 528 "mod/silverbox/memcached.rl" { done = true; stats.bytes_read += p - (u8 *)fiber->rbuf->data; tbuf_peek(fiber->rbuf, p - (u8 *)fiber->rbuf->data); } -#line 270 "mod/silverbox/memcached.rl" +#line 271 "mod/silverbox/memcached.rl" { key = read_field(keys); struct box_tuple *tuple = find(key); @@ -1418,11 +1419,11 @@ case 12: } goto st197; tr263: -#line 501 "mod/silverbox/memcached.rl" +#line 502 "mod/silverbox/memcached.rl" {bytes = natoq(fstart, p);} -#line 533 "mod/silverbox/memcached.rl" +#line 534 "mod/silverbox/memcached.rl" { p++; } -#line 506 "mod/silverbox/memcached.rl" +#line 507 "mod/silverbox/memcached.rl" { size_t parsed = p - (u8 *)fiber->rbuf->data; while (fiber->rbuf->len - parsed < bytes + 2) { @@ -1443,22 +1444,22 @@ case 12: goto exit; } } -#line 527 "mod/silverbox/memcached.rl" +#line 528 "mod/silverbox/memcached.rl" { done = true; stats.bytes_read += p - (u8 *)fiber->rbuf->data; tbuf_peek(fiber->rbuf, p - (u8 *)fiber->rbuf->data); } -#line 256 "mod/silverbox/memcached.rl" +#line 257 "mod/silverbox/memcached.rl" { key = read_field(keys); STORE; } goto st197; tr267: -#line 533 "mod/silverbox/memcached.rl" +#line 534 "mod/silverbox/memcached.rl" { p++; } -#line 506 "mod/silverbox/memcached.rl" +#line 507 "mod/silverbox/memcached.rl" { size_t parsed = p - (u8 *)fiber->rbuf->data; while (fiber->rbuf->len - parsed < bytes + 2) { @@ -1479,24 +1480,24 @@ case 12: goto exit; } } -#line 527 "mod/silverbox/memcached.rl" +#line 528 "mod/silverbox/memcached.rl" { done = true; stats.bytes_read += p - (u8 *)fiber->rbuf->data; tbuf_peek(fiber->rbuf, p - (u8 *)fiber->rbuf->data); } -#line 256 "mod/silverbox/memcached.rl" +#line 257 "mod/silverbox/memcached.rl" { key = read_field(keys); STORE; } goto st197; tr276: -#line 535 "mod/silverbox/memcached.rl" +#line 536 "mod/silverbox/memcached.rl" { noreply = true; } -#line 533 "mod/silverbox/memcached.rl" +#line 534 "mod/silverbox/memcached.rl" { p++; } -#line 506 "mod/silverbox/memcached.rl" +#line 507 "mod/silverbox/memcached.rl" { size_t parsed = p - (u8 *)fiber->rbuf->data; while (fiber->rbuf->len - parsed < bytes + 2) { @@ -1517,28 +1518,28 @@ case 12: goto exit; } } -#line 527 "mod/silverbox/memcached.rl" +#line 528 "mod/silverbox/memcached.rl" { done = true; stats.bytes_read += p - (u8 *)fiber->rbuf->data; tbuf_peek(fiber->rbuf, p - (u8 *)fiber->rbuf->data); } -#line 256 "mod/silverbox/memcached.rl" +#line 257 "mod/silverbox/memcached.rl" { key = read_field(keys); STORE; } goto st197; tr281: -#line 533 "mod/silverbox/memcached.rl" +#line 534 "mod/silverbox/memcached.rl" { p++; } -#line 527 "mod/silverbox/memcached.rl" +#line 528 "mod/silverbox/memcached.rl" { done = true; stats.bytes_read += p - (u8 *)fiber->rbuf->data; tbuf_peek(fiber->rbuf, p - (u8 *)fiber->rbuf->data); } -#line 468 "mod/silverbox/memcached.rl" +#line 469 "mod/silverbox/memcached.rl" { print_stats(); } @@ -1547,33 +1548,33 @@ case 12: if ( ++p == pe ) goto _test_eof197; case 197: -#line 1551 "mod/silverbox/memcached.c" +#line 1552 "mod/silverbox/memcached.c" goto st0; tr27: -#line 501 "mod/silverbox/memcached.rl" +#line 502 "mod/silverbox/memcached.rl" {bytes = natoq(fstart, p);} goto st13; tr40: -#line 535 "mod/silverbox/memcached.rl" +#line 536 "mod/silverbox/memcached.rl" { noreply = true; } goto st13; st13: if ( ++p == pe ) goto _test_eof13; case 13: -#line 1565 "mod/silverbox/memcached.c" +#line 1566 "mod/silverbox/memcached.c" if ( (*p) == 10 ) goto tr30; goto st0; tr28: -#line 501 "mod/silverbox/memcached.rl" +#line 502 "mod/silverbox/memcached.rl" {bytes = natoq(fstart, p);} goto st14; st14: if ( ++p == pe ) goto _test_eof14; case 14: -#line 1577 "mod/silverbox/memcached.c" +#line 1578 "mod/silverbox/memcached.c" switch( (*p) ) { case 32: goto st14; case 110: goto st15; @@ -1666,18 +1667,18 @@ case 26: goto tr45; goto st0; tr45: -#line 541 "mod/silverbox/memcached.rl" +#line 542 "mod/silverbox/memcached.rl" {append = true; } goto st27; tr209: -#line 542 "mod/silverbox/memcached.rl" +#line 543 "mod/silverbox/memcached.rl" {append = false;} goto st27; st27: if ( ++p == pe ) goto _test_eof27; case 27: -#line 1681 "mod/silverbox/memcached.c" +#line 1682 "mod/silverbox/memcached.c" switch( (*p) ) { case 13: goto st0; case 32: goto st27; @@ -1686,7 +1687,7 @@ case 27: goto st0; goto tr46; tr46: -#line 477 "mod/silverbox/memcached.rl" +#line 478 "mod/silverbox/memcached.rl" { fstart = p; for (; p < pe && *p != ' ' && *p != '\r' && *p != '\n'; p++); @@ -1703,7 +1704,7 @@ case 27: if ( ++p == pe ) goto _test_eof28; case 28: -#line 1707 "mod/silverbox/memcached.c" +#line 1708 "mod/silverbox/memcached.c" if ( (*p) == 32 ) goto st29; goto st0; @@ -1717,49 +1718,49 @@ case 29: goto tr49; goto st0; tr49: -#line 476 "mod/silverbox/memcached.rl" +#line 477 "mod/silverbox/memcached.rl" { fstart = p; } goto st30; st30: if ( ++p == pe ) goto _test_eof30; case 30: -#line 1728 "mod/silverbox/memcached.c" +#line 1729 "mod/silverbox/memcached.c" if ( (*p) == 32 ) goto tr50; if ( 48 <= (*p) && (*p) <= 57 ) goto st30; goto st0; tr50: -#line 500 "mod/silverbox/memcached.rl" +#line 501 "mod/silverbox/memcached.rl" {flags = natoq(fstart, p);} goto st31; st31: if ( ++p == pe ) goto _test_eof31; case 31: -#line 1742 "mod/silverbox/memcached.c" +#line 1743 "mod/silverbox/memcached.c" if ( (*p) == 32 ) goto st31; if ( 48 <= (*p) && (*p) <= 57 ) goto tr53; goto st0; tr53: -#line 476 "mod/silverbox/memcached.rl" +#line 477 "mod/silverbox/memcached.rl" { fstart = p; } goto st32; st32: if ( ++p == pe ) goto _test_eof32; case 32: -#line 1756 "mod/silverbox/memcached.c" +#line 1757 "mod/silverbox/memcached.c" if ( (*p) == 32 ) goto tr54; if ( 48 <= (*p) && (*p) <= 57 ) goto st32; goto st0; tr54: -#line 493 "mod/silverbox/memcached.rl" +#line 494 "mod/silverbox/memcached.rl" { exptime = natoq(fstart, p); if (exptime > 0 && exptime <= 60*60*24*30) @@ -1770,21 +1771,21 @@ case 32: if ( ++p == pe ) goto _test_eof33; case 33: -#line 1774 "mod/silverbox/memcached.c" +#line 1775 "mod/silverbox/memcached.c" if ( (*p) == 32 ) goto st33; if ( 48 <= (*p) && (*p) <= 57 ) goto tr57; goto st0; tr57: -#line 476 "mod/silverbox/memcached.rl" +#line 477 "mod/silverbox/memcached.rl" { fstart = p; } goto st34; st34: if ( ++p == pe ) goto _test_eof34; case 34: -#line 1788 "mod/silverbox/memcached.c" +#line 1789 "mod/silverbox/memcached.c" switch( (*p) ) { case 10: goto tr58; case 13: goto tr59; @@ -1794,30 +1795,30 @@ case 34: goto st34; goto st0; tr59: -#line 501 "mod/silverbox/memcached.rl" +#line 502 "mod/silverbox/memcached.rl" {bytes = natoq(fstart, p);} goto st35; tr72: -#line 535 "mod/silverbox/memcached.rl" +#line 536 "mod/silverbox/memcached.rl" { noreply = true; } goto st35; st35: if ( ++p == pe ) goto _test_eof35; case 35: -#line 1809 "mod/silverbox/memcached.c" +#line 1810 "mod/silverbox/memcached.c" if ( (*p) == 10 ) goto tr62; goto st0; tr60: -#line 501 "mod/silverbox/memcached.rl" +#line 502 "mod/silverbox/memcached.rl" {bytes = natoq(fstart, p);} goto st36; st36: if ( ++p == pe ) goto _test_eof36; case 36: -#line 1821 "mod/silverbox/memcached.c" +#line 1822 "mod/silverbox/memcached.c" switch( (*p) ) { case 32: goto st36; case 110: goto st37; @@ -1907,7 +1908,7 @@ case 47: goto st0; goto tr76; tr76: -#line 477 "mod/silverbox/memcached.rl" +#line 478 "mod/silverbox/memcached.rl" { fstart = p; for (; p < pe && *p != ' ' && *p != '\r' && *p != '\n'; p++); @@ -1924,7 +1925,7 @@ case 47: if ( ++p == pe ) goto _test_eof48; case 48: -#line 1928 "mod/silverbox/memcached.c" +#line 1929 "mod/silverbox/memcached.c" if ( (*p) == 32 ) goto st49; goto st0; @@ -1938,49 +1939,49 @@ case 49: goto tr78; goto st0; tr78: -#line 476 "mod/silverbox/memcached.rl" +#line 477 "mod/silverbox/memcached.rl" { fstart = p; } goto st50; st50: if ( ++p == pe ) goto _test_eof50; case 50: -#line 1949 "mod/silverbox/memcached.c" +#line 1950 "mod/silverbox/memcached.c" if ( (*p) == 32 ) goto tr79; if ( 48 <= (*p) && (*p) <= 57 ) goto st50; goto st0; tr79: -#line 500 "mod/silverbox/memcached.rl" +#line 501 "mod/silverbox/memcached.rl" {flags = natoq(fstart, p);} goto st51; st51: if ( ++p == pe ) goto _test_eof51; case 51: -#line 1963 "mod/silverbox/memcached.c" +#line 1964 "mod/silverbox/memcached.c" if ( (*p) == 32 ) goto st51; if ( 48 <= (*p) && (*p) <= 57 ) goto tr82; goto st0; tr82: -#line 476 "mod/silverbox/memcached.rl" +#line 477 "mod/silverbox/memcached.rl" { fstart = p; } goto st52; st52: if ( ++p == pe ) goto _test_eof52; case 52: -#line 1977 "mod/silverbox/memcached.c" +#line 1978 "mod/silverbox/memcached.c" if ( (*p) == 32 ) goto tr83; if ( 48 <= (*p) && (*p) <= 57 ) goto st52; goto st0; tr83: -#line 493 "mod/silverbox/memcached.rl" +#line 494 "mod/silverbox/memcached.rl" { exptime = natoq(fstart, p); if (exptime > 0 && exptime <= 60*60*24*30) @@ -1991,49 +1992,49 @@ case 52: if ( ++p == pe ) goto _test_eof53; case 53: -#line 1995 "mod/silverbox/memcached.c" +#line 1996 "mod/silverbox/memcached.c" if ( (*p) == 32 ) goto st53; if ( 48 <= (*p) && (*p) <= 57 ) goto tr86; goto st0; tr86: -#line 476 "mod/silverbox/memcached.rl" +#line 477 "mod/silverbox/memcached.rl" { fstart = p; } goto st54; st54: if ( ++p == pe ) goto _test_eof54; case 54: -#line 2009 "mod/silverbox/memcached.c" +#line 2010 "mod/silverbox/memcached.c" if ( (*p) == 32 ) goto tr87; if ( 48 <= (*p) && (*p) <= 57 ) goto st54; goto st0; tr87: -#line 501 "mod/silverbox/memcached.rl" +#line 502 "mod/silverbox/memcached.rl" {bytes = natoq(fstart, p);} goto st55; st55: if ( ++p == pe ) goto _test_eof55; case 55: -#line 2023 "mod/silverbox/memcached.c" +#line 2024 "mod/silverbox/memcached.c" if ( (*p) == 32 ) goto st55; if ( 48 <= (*p) && (*p) <= 57 ) goto tr90; goto st0; tr90: -#line 476 "mod/silverbox/memcached.rl" +#line 477 "mod/silverbox/memcached.rl" { fstart = p; } goto st56; st56: if ( ++p == pe ) goto _test_eof56; case 56: -#line 2037 "mod/silverbox/memcached.c" +#line 2038 "mod/silverbox/memcached.c" switch( (*p) ) { case 10: goto tr91; case 13: goto tr92; @@ -2043,30 +2044,30 @@ case 56: goto st56; goto st0; tr106: -#line 535 "mod/silverbox/memcached.rl" +#line 536 "mod/silverbox/memcached.rl" { noreply = true; } goto st57; tr92: -#line 502 "mod/silverbox/memcached.rl" +#line 503 "mod/silverbox/memcached.rl" {cas = natoq(fstart, p);} goto st57; st57: if ( ++p == pe ) goto _test_eof57; case 57: -#line 2058 "mod/silverbox/memcached.c" +#line 2059 "mod/silverbox/memcached.c" if ( (*p) == 10 ) goto tr95; goto st0; tr93: -#line 502 "mod/silverbox/memcached.rl" +#line 503 "mod/silverbox/memcached.rl" {cas = natoq(fstart, p);} goto st58; st58: if ( ++p == pe ) goto _test_eof58; case 58: -#line 2070 "mod/silverbox/memcached.c" +#line 2071 "mod/silverbox/memcached.c" switch( (*p) ) { case 10: goto tr95; case 13: goto st57; @@ -2127,14 +2128,14 @@ case 65: } goto st0; tr107: -#line 535 "mod/silverbox/memcached.rl" +#line 536 "mod/silverbox/memcached.rl" { noreply = true; } goto st66; st66: if ( ++p == pe ) goto _test_eof66; case 66: -#line 2138 "mod/silverbox/memcached.c" +#line 2139 "mod/silverbox/memcached.c" switch( (*p) ) { case 10: goto tr95; case 13: goto st57; @@ -2172,18 +2173,18 @@ case 70: goto tr113; goto st0; tr113: -#line 550 "mod/silverbox/memcached.rl" +#line 551 "mod/silverbox/memcached.rl" {incr_sign = -1;} goto st71; tr202: -#line 549 "mod/silverbox/memcached.rl" +#line 550 "mod/silverbox/memcached.rl" {incr_sign = 1; } goto st71; st71: if ( ++p == pe ) goto _test_eof71; case 71: -#line 2187 "mod/silverbox/memcached.c" +#line 2188 "mod/silverbox/memcached.c" switch( (*p) ) { case 13: goto st0; case 32: goto st71; @@ -2192,7 +2193,7 @@ case 71: goto st0; goto tr114; tr114: -#line 477 "mod/silverbox/memcached.rl" +#line 478 "mod/silverbox/memcached.rl" { fstart = p; for (; p < pe && *p != ' ' && *p != '\r' && *p != '\n'; p++); @@ -2209,7 +2210,7 @@ case 71: if ( ++p == pe ) goto _test_eof72; case 72: -#line 2213 "mod/silverbox/memcached.c" +#line 2214 "mod/silverbox/memcached.c" if ( (*p) == 32 ) goto st73; goto st0; @@ -2223,14 +2224,14 @@ case 73: goto tr117; goto st0; tr117: -#line 476 "mod/silverbox/memcached.rl" +#line 477 "mod/silverbox/memcached.rl" { fstart = p; } goto st74; st74: if ( ++p == pe ) goto _test_eof74; case 74: -#line 2234 "mod/silverbox/memcached.c" +#line 2235 "mod/silverbox/memcached.c" switch( (*p) ) { case 10: goto tr118; case 13: goto tr119; @@ -2240,30 +2241,30 @@ case 74: goto st74; goto st0; tr133: -#line 535 "mod/silverbox/memcached.rl" +#line 536 "mod/silverbox/memcached.rl" { noreply = true; } goto st75; tr119: -#line 503 "mod/silverbox/memcached.rl" +#line 504 "mod/silverbox/memcached.rl" {incr = natoq(fstart, p);} goto st75; st75: if ( ++p == pe ) goto _test_eof75; case 75: -#line 2255 "mod/silverbox/memcached.c" +#line 2256 "mod/silverbox/memcached.c" if ( (*p) == 10 ) goto tr122; goto st0; tr120: -#line 503 "mod/silverbox/memcached.rl" +#line 504 "mod/silverbox/memcached.rl" {incr = natoq(fstart, p);} goto st76; st76: if ( ++p == pe ) goto _test_eof76; case 76: -#line 2267 "mod/silverbox/memcached.c" +#line 2268 "mod/silverbox/memcached.c" switch( (*p) ) { case 10: goto tr122; case 13: goto st75; @@ -2324,14 +2325,14 @@ case 83: } goto st0; tr134: -#line 535 "mod/silverbox/memcached.rl" +#line 536 "mod/silverbox/memcached.rl" { noreply = true; } goto st84; st84: if ( ++p == pe ) goto _test_eof84; case 84: -#line 2335 "mod/silverbox/memcached.c" +#line 2336 "mod/silverbox/memcached.c" switch( (*p) ) { case 10: goto tr122; case 13: goto st75; @@ -2378,7 +2379,7 @@ case 89: goto st0; goto tr140; tr140: -#line 477 "mod/silverbox/memcached.rl" +#line 478 "mod/silverbox/memcached.rl" { fstart = p; for (; p < pe && *p != ' ' && *p != '\r' && *p != '\n'; p++); @@ -2395,7 +2396,7 @@ case 89: if ( ++p == pe ) goto _test_eof90; case 90: -#line 2399 "mod/silverbox/memcached.c" +#line 2400 "mod/silverbox/memcached.c" switch( (*p) ) { case 10: goto tr141; case 13: goto st91; @@ -2403,7 +2404,7 @@ case 90: } goto st0; tr147: -#line 493 "mod/silverbox/memcached.rl" +#line 494 "mod/silverbox/memcached.rl" { exptime = natoq(fstart, p); if (exptime > 0 && exptime <= 60*60*24*30) @@ -2411,14 +2412,14 @@ case 90: } goto st91; tr158: -#line 535 "mod/silverbox/memcached.rl" +#line 536 "mod/silverbox/memcached.rl" { noreply = true; } goto st91; st91: if ( ++p == pe ) goto _test_eof91; case 91: -#line 2422 "mod/silverbox/memcached.c" +#line 2423 "mod/silverbox/memcached.c" if ( (*p) == 10 ) goto tr141; goto st0; @@ -2436,14 +2437,14 @@ case 92: goto tr144; goto st0; tr144: -#line 476 "mod/silverbox/memcached.rl" +#line 477 "mod/silverbox/memcached.rl" { fstart = p; } goto st93; st93: if ( ++p == pe ) goto _test_eof93; case 93: -#line 2447 "mod/silverbox/memcached.c" +#line 2448 "mod/silverbox/memcached.c" switch( (*p) ) { case 10: goto tr146; case 13: goto tr147; @@ -2453,7 +2454,7 @@ case 93: goto st93; goto st0; tr148: -#line 493 "mod/silverbox/memcached.rl" +#line 494 "mod/silverbox/memcached.rl" { exptime = natoq(fstart, p); if (exptime > 0 && exptime <= 60*60*24*30) @@ -2464,7 +2465,7 @@ case 93: if ( ++p == pe ) goto _test_eof94; case 94: -#line 2468 "mod/silverbox/memcached.c" +#line 2469 "mod/silverbox/memcached.c" switch( (*p) ) { case 10: goto tr141; case 13: goto st91; @@ -2525,14 +2526,14 @@ case 101: } goto st0; tr159: -#line 535 "mod/silverbox/memcached.rl" +#line 536 "mod/silverbox/memcached.rl" { noreply = true; } goto st102; st102: if ( ++p == pe ) goto _test_eof102; case 102: -#line 2536 "mod/silverbox/memcached.c" +#line 2537 "mod/silverbox/memcached.c" switch( (*p) ) { case 10: goto tr141; case 13: goto st91; @@ -2606,18 +2607,18 @@ case 111: } goto st0; tr186: -#line 535 "mod/silverbox/memcached.rl" +#line 536 "mod/silverbox/memcached.rl" { noreply = true; } goto st112; tr175: -#line 504 "mod/silverbox/memcached.rl" +#line 505 "mod/silverbox/memcached.rl" {flush_delay = natoq(fstart, p);} goto st112; st112: if ( ++p == pe ) goto _test_eof112; case 112: -#line 2621 "mod/silverbox/memcached.c" +#line 2622 "mod/silverbox/memcached.c" if ( (*p) == 10 ) goto tr169; goto st0; @@ -2635,14 +2636,14 @@ case 113: goto tr172; goto st0; tr172: -#line 476 "mod/silverbox/memcached.rl" +#line 477 "mod/silverbox/memcached.rl" { fstart = p; } goto st114; st114: if ( ++p == pe ) goto _test_eof114; case 114: -#line 2646 "mod/silverbox/memcached.c" +#line 2647 "mod/silverbox/memcached.c" switch( (*p) ) { case 10: goto tr174; case 13: goto tr175; @@ -2652,14 +2653,14 @@ case 114: goto st114; goto st0; tr176: -#line 504 "mod/silverbox/memcached.rl" +#line 505 "mod/silverbox/memcached.rl" {flush_delay = natoq(fstart, p);} goto st115; st115: if ( ++p == pe ) goto _test_eof115; case 115: -#line 2663 "mod/silverbox/memcached.c" +#line 2664 "mod/silverbox/memcached.c" switch( (*p) ) { case 10: goto tr169; case 13: goto st112; @@ -2720,14 +2721,14 @@ case 122: } goto st0; tr187: -#line 535 "mod/silverbox/memcached.rl" +#line 536 "mod/silverbox/memcached.rl" { noreply = true; } goto st123; st123: if ( ++p == pe ) goto _test_eof123; case 123: -#line 2731 "mod/silverbox/memcached.c" +#line 2732 "mod/silverbox/memcached.c" switch( (*p) ) { case 10: goto tr169; case 13: goto st112; @@ -2758,18 +2759,18 @@ case 126: } goto st0; tr191: -#line 546 "mod/silverbox/memcached.rl" +#line 547 "mod/silverbox/memcached.rl" {show_cas = false;} goto st127; tr198: -#line 547 "mod/silverbox/memcached.rl" +#line 548 "mod/silverbox/memcached.rl" {show_cas = true;} goto st127; st127: if ( ++p == pe ) goto _test_eof127; case 127: -#line 2773 "mod/silverbox/memcached.c" +#line 2774 "mod/silverbox/memcached.c" switch( (*p) ) { case 13: goto st0; case 32: goto st127; @@ -2778,7 +2779,7 @@ case 127: goto st0; goto tr193; tr193: -#line 477 "mod/silverbox/memcached.rl" +#line 478 "mod/silverbox/memcached.rl" { fstart = p; for (; p < pe && *p != ' ' && *p != '\r' && *p != '\n'; p++); @@ -2795,7 +2796,7 @@ case 127: if ( ++p == pe ) goto _test_eof128; case 128: -#line 2799 "mod/silverbox/memcached.c" +#line 2800 "mod/silverbox/memcached.c" switch( (*p) ) { case 10: goto tr195; case 13: goto st129; @@ -3002,7 +3003,7 @@ case 155: goto st0; goto tr222; tr222: -#line 477 "mod/silverbox/memcached.rl" +#line 478 "mod/silverbox/memcached.rl" { fstart = p; for (; p < pe && *p != ' ' && *p != '\r' && *p != '\n'; p++); @@ -3019,7 +3020,7 @@ case 155: if ( ++p == pe ) goto _test_eof156; case 156: -#line 3023 "mod/silverbox/memcached.c" +#line 3024 "mod/silverbox/memcached.c" if ( (*p) == 32 ) goto st157; goto st0; @@ -3033,49 +3034,49 @@ case 157: goto tr224; goto st0; tr224: -#line 476 "mod/silverbox/memcached.rl" +#line 477 "mod/silverbox/memcached.rl" { fstart = p; } goto st158; st158: if ( ++p == pe ) goto _test_eof158; case 158: -#line 3044 "mod/silverbox/memcached.c" +#line 3045 "mod/silverbox/memcached.c" if ( (*p) == 32 ) goto tr225; if ( 48 <= (*p) && (*p) <= 57 ) goto st158; goto st0; tr225: -#line 500 "mod/silverbox/memcached.rl" +#line 501 "mod/silverbox/memcached.rl" {flags = natoq(fstart, p);} goto st159; st159: if ( ++p == pe ) goto _test_eof159; case 159: -#line 3058 "mod/silverbox/memcached.c" +#line 3059 "mod/silverbox/memcached.c" if ( (*p) == 32 ) goto st159; if ( 48 <= (*p) && (*p) <= 57 ) goto tr228; goto st0; tr228: -#line 476 "mod/silverbox/memcached.rl" +#line 477 "mod/silverbox/memcached.rl" { fstart = p; } goto st160; st160: if ( ++p == pe ) goto _test_eof160; case 160: -#line 3072 "mod/silverbox/memcached.c" +#line 3073 "mod/silverbox/memcached.c" if ( (*p) == 32 ) goto tr229; if ( 48 <= (*p) && (*p) <= 57 ) goto st160; goto st0; tr229: -#line 493 "mod/silverbox/memcached.rl" +#line 494 "mod/silverbox/memcached.rl" { exptime = natoq(fstart, p); if (exptime > 0 && exptime <= 60*60*24*30) @@ -3086,21 +3087,21 @@ case 160: if ( ++p == pe ) goto _test_eof161; case 161: -#line 3090 "mod/silverbox/memcached.c" +#line 3091 "mod/silverbox/memcached.c" if ( (*p) == 32 ) goto st161; if ( 48 <= (*p) && (*p) <= 57 ) goto tr232; goto st0; tr232: -#line 476 "mod/silverbox/memcached.rl" +#line 477 "mod/silverbox/memcached.rl" { fstart = p; } goto st162; st162: if ( ++p == pe ) goto _test_eof162; case 162: -#line 3104 "mod/silverbox/memcached.c" +#line 3105 "mod/silverbox/memcached.c" switch( (*p) ) { case 10: goto tr233; case 13: goto tr234; @@ -3110,30 +3111,30 @@ case 162: goto st162; goto st0; tr234: -#line 501 "mod/silverbox/memcached.rl" +#line 502 "mod/silverbox/memcached.rl" {bytes = natoq(fstart, p);} goto st163; tr247: -#line 535 "mod/silverbox/memcached.rl" +#line 536 "mod/silverbox/memcached.rl" { noreply = true; } goto st163; st163: if ( ++p == pe ) goto _test_eof163; case 163: -#line 3125 "mod/silverbox/memcached.c" +#line 3126 "mod/silverbox/memcached.c" if ( (*p) == 10 ) goto tr237; goto st0; tr235: -#line 501 "mod/silverbox/memcached.rl" +#line 502 "mod/silverbox/memcached.rl" {bytes = natoq(fstart, p);} goto st164; st164: if ( ++p == pe ) goto _test_eof164; case 164: -#line 3137 "mod/silverbox/memcached.c" +#line 3138 "mod/silverbox/memcached.c" switch( (*p) ) { case 32: goto st164; case 110: goto st165; @@ -3225,7 +3226,7 @@ case 175: goto st0; goto tr252; tr252: -#line 477 "mod/silverbox/memcached.rl" +#line 478 "mod/silverbox/memcached.rl" { fstart = p; for (; p < pe && *p != ' ' && *p != '\r' && *p != '\n'; p++); @@ -3242,7 +3243,7 @@ case 175: if ( ++p == pe ) goto _test_eof176; case 176: -#line 3246 "mod/silverbox/memcached.c" +#line 3247 "mod/silverbox/memcached.c" if ( (*p) == 32 ) goto st177; goto st0; @@ -3256,49 +3257,49 @@ case 177: goto tr254; goto st0; tr254: -#line 476 "mod/silverbox/memcached.rl" +#line 477 "mod/silverbox/memcached.rl" { fstart = p; } goto st178; st178: if ( ++p == pe ) goto _test_eof178; case 178: -#line 3267 "mod/silverbox/memcached.c" +#line 3268 "mod/silverbox/memcached.c" if ( (*p) == 32 ) goto tr255; if ( 48 <= (*p) && (*p) <= 57 ) goto st178; goto st0; tr255: -#line 500 "mod/silverbox/memcached.rl" +#line 501 "mod/silverbox/memcached.rl" {flags = natoq(fstart, p);} goto st179; st179: if ( ++p == pe ) goto _test_eof179; case 179: -#line 3281 "mod/silverbox/memcached.c" +#line 3282 "mod/silverbox/memcached.c" if ( (*p) == 32 ) goto st179; if ( 48 <= (*p) && (*p) <= 57 ) goto tr258; goto st0; tr258: -#line 476 "mod/silverbox/memcached.rl" +#line 477 "mod/silverbox/memcached.rl" { fstart = p; } goto st180; st180: if ( ++p == pe ) goto _test_eof180; case 180: -#line 3295 "mod/silverbox/memcached.c" +#line 3296 "mod/silverbox/memcached.c" if ( (*p) == 32 ) goto tr259; if ( 48 <= (*p) && (*p) <= 57 ) goto st180; goto st0; tr259: -#line 493 "mod/silverbox/memcached.rl" +#line 494 "mod/silverbox/memcached.rl" { exptime = natoq(fstart, p); if (exptime > 0 && exptime <= 60*60*24*30) @@ -3309,21 +3310,21 @@ case 180: if ( ++p == pe ) goto _test_eof181; case 181: -#line 3313 "mod/silverbox/memcached.c" +#line 3314 "mod/silverbox/memcached.c" if ( (*p) == 32 ) goto st181; if ( 48 <= (*p) && (*p) <= 57 ) goto tr262; goto st0; tr262: -#line 476 "mod/silverbox/memcached.rl" +#line 477 "mod/silverbox/memcached.rl" { fstart = p; } goto st182; st182: if ( ++p == pe ) goto _test_eof182; case 182: -#line 3327 "mod/silverbox/memcached.c" +#line 3328 "mod/silverbox/memcached.c" switch( (*p) ) { case 10: goto tr263; case 13: goto tr264; @@ -3333,30 +3334,30 @@ case 182: goto st182; goto st0; tr264: -#line 501 "mod/silverbox/memcached.rl" +#line 502 "mod/silverbox/memcached.rl" {bytes = natoq(fstart, p);} goto st183; tr277: -#line 535 "mod/silverbox/memcached.rl" +#line 536 "mod/silverbox/memcached.rl" { noreply = true; } goto st183; st183: if ( ++p == pe ) goto _test_eof183; case 183: -#line 3348 "mod/silverbox/memcached.c" +#line 3349 "mod/silverbox/memcached.c" if ( (*p) == 10 ) goto tr267; goto st0; tr265: -#line 501 "mod/silverbox/memcached.rl" +#line 502 "mod/silverbox/memcached.rl" {bytes = natoq(fstart, p);} goto st184; st184: if ( ++p == pe ) goto _test_eof184; case 184: -#line 3360 "mod/silverbox/memcached.c" +#line 3361 "mod/silverbox/memcached.c" switch( (*p) ) { case 32: goto st184; case 110: goto st185; @@ -3652,7 +3653,7 @@ case 196: _out: {} } -#line 560 "mod/silverbox/memcached.rl" +#line 561 "mod/silverbox/memcached.rl" if (!done) { @@ -3794,4 +3795,5 @@ memcached_expire(void *data __unused__) * Local Variables: * mode: c * End: + * vim: syntax=c */ diff --git a/mod/silverbox/memcached.rl b/mod/silverbox/memcached.rl index b07ac1ef561aacc2eba2caf440ac2448899144da..e5dc30d5fc6096db78e3577e0dca2f209bf15570 100644 --- a/mod/silverbox/memcached.rl +++ b/mod/silverbox/memcached.rl @@ -37,6 +37,7 @@ #include <pickle.h> #include <tarantool.h> +#include <cfg/tarantool_silverbox_cfg.h> #include <mod/silverbox/box.h> #include <stat.h> @@ -698,4 +699,5 @@ memcached_expire(void *data __unused__) * Local Variables: * mode: c * End: + * vim: syntax=c */ diff --git a/mod/silverbox/box_cfg.cfg_tmpl b/mod/silverbox/silverbox_cfg.cfg_tmpl similarity index 100% rename from mod/silverbox/box_cfg.cfg_tmpl rename to mod/silverbox/silverbox_cfg.cfg_tmpl diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..d8c64bd8eeeed354e7e71447b3ec5fca9c7bedee --- /dev/null +++ b/test/CMakeLists.txt @@ -0,0 +1,3 @@ +add_custom_target(test + COMMAND ${PROJECT_SOURCE_DIR}/test/test-run.py --bindir=${PROJECT_BINARY_DIR}/core --vardir=${PROJECT_BINARY_DIR}/test/var + ) diff --git a/test/Makefile b/test/Makefile deleted file mode 100644 index d3c699e728d01be31efa8f68bf87ac0e667159b1..0000000000000000000000000000000000000000 --- a/test/Makefile +++ /dev/null @@ -1,3 +0,0 @@ -test: - ./test-run.py - diff --git a/test/box/reconfigure.test b/test/box/reconfigure.test index d129bd4f202ac041f6344081627c78ce7473333f..6a292b142802cf32f8222eae4d60292faf905540 100644 --- a/test/box/reconfigure.test +++ b/test/box/reconfigure.test @@ -2,46 +2,48 @@ # # backup default from os.path import abspath -os.rename("var/tarantool.cfg", "var/tarantool.cfg.old") +cfg = os.path.join(vardir, "tarantool.cfg") +oldcfg = os.path.join(vardir, "tarantool.cfg.old") +os.rename(cfg, oldcfg) # bad1 -os.symlink(abspath("box/tarantool_bad1.cfg"), "var/tarantool.cfg") +os.symlink(abspath("box/tarantool_bad1.cfg"), cfg) exec admin "reload configuration" # bad2 -os.unlink("var/tarantool.cfg") -os.symlink(abspath("box/tarantool_bad2.cfg"), "var/tarantool.cfg") +os.unlink(cfg) +os.symlink(abspath("box/tarantool_bad2.cfg"), cfg) exec admin "reload configuration" # bad3 -os.unlink("var/tarantool.cfg") -os.symlink(abspath("box/tarantool_bad3.cfg"), "var/tarantool.cfg") +os.unlink(cfg) +os.symlink(abspath("box/tarantool_bad3.cfg"), cfg) exec admin "reload configuration" # bad4 -os.unlink("var/tarantool.cfg") -os.symlink(abspath("box/tarantool_bad4.cfg"), "var/tarantool.cfg") +os.unlink(cfg) +os.symlink(abspath("box/tarantool_bad4.cfg"), cfg) exec admin "reload configuration" # bad5 -os.unlink("var/tarantool.cfg") -os.symlink(abspath("box/tarantool_bad5.cfg"), "var/tarantool.cfg") +os.unlink(cfg) +os.symlink(abspath("box/tarantool_bad5.cfg"), cfg) exec admin "reload configuration" # good -os.unlink("var/tarantool.cfg") -os.symlink(abspath("box/tarantool_good.cfg"), "var/tarantool.cfg") +os.unlink(cfg) +os.symlink(abspath("box/tarantool_good.cfg"), cfg) exec admin "reload configuration" # empty -os.unlink("var/tarantool.cfg") -os.symlink(abspath("box/tarantool_empty.cfg"), "var/tarantool.cfg") +os.unlink(cfg) +os.symlink(abspath("box/tarantool_empty.cfg"), cfg) exec admin "reload configuration" # no config -os.unlink("var/tarantool.cfg") +os.unlink(cfg) exec admin "reload configuration" # restore default -os.rename("var/tarantool.cfg.old", "var/tarantool.cfg") +os.rename(oldcfg, cfg) # vim: syntax=python diff --git a/test/lib/tarantool_silverbox_server.py b/test/lib/tarantool_silverbox_server.py index d8b169390cdc5bf26219a30ed64736e41c41a504..c3d68ac7e9e74fa1a05013cd06bd1333eee777bd 100644 --- a/test/lib/tarantool_silverbox_server.py +++ b/test/lib/tarantool_silverbox_server.py @@ -7,6 +7,7 @@ import sys import signal import time import socket +import glob def wait_until_connected(host, port): """Wait until the server is started and accepting connections""" @@ -86,17 +87,18 @@ class TarantoolSilverboxServer: if not silent: print " Found old vardir, deleting..." self.kill_old_server() - if os.path.islink(vardir): - shutil.rmtree(os.readlink(vardir), ignore_errors = True) - os.remove(vardir) - else: - shutil.rmtree(vardir, ignore_errors = True) - - if (self.args.mem == True and check_tmpfs_exists() and - os.path.basename(vardir) == vardir): - create_tmpfs_vardir(vardir) + for filename in (glob.glob(os.path.join(vardir, "*.snap")) + + glob.glob(os.path.join(vardir, "*.inprogress")) + + glob.glob(os.path.join(vardir, "*.xlog")) + + glob.glob(os.path.join(vardir, "*.cfg")) + + glob.glob(os.path.join(vardir, "core"))): + os.remove(filename) else: - os.mkdir(vardir) + if (self.args.mem == True and check_tmpfs_exists() and + os.path.basename(vardir) == vardir): + create_tmpfs_vardir(vardir) + else: + os.mkdir(vardir) shutil.copy(self.suite_ini["config"], self.args.vardir) diff --git a/test/lib/test_suite.py b/test/lib/test_suite.py index a41cc088e4445de6f7aba13d0c27b9c9f8fd1c44..a521aee71f2ed226cc8076fcdbedd9a67bdb4617 100644 --- a/test/lib/test_suite.py +++ b/test/lib/test_suite.py @@ -54,13 +54,15 @@ class FilteredStream: class Test: - """An individual test file. A test can run itself, and remembers - its completion state.""" + """An individual test file. A test object can run itself + and remembers completion state of the run.""" def __init__(self, name, suite_ini): """Initialize test properties: path to test file, path to temporary result file, path to the client program, test status.""" self.name = name self.result = name.replace(".test", ".result") + self.tmp_result = os.path.join(suite_ini["vardir"], + os.path.basename(self.result)) self.reject = name.replace(".test", ".reject") self.suite_ini = suite_ini self.is_executed = False @@ -93,8 +95,9 @@ class Test: try: admin.connect() sql.connect() - sys.stdout = FilteredStream(self.reject) + sys.stdout = FilteredStream(self.tmp_result) server = self.suite_ini["server"] + vardir = self.suite_ini["vardir"] execfile(self.name, globals(), locals()) self.is_executed_ok = True except Exception as e: @@ -110,16 +113,17 @@ class Test: self.is_executed = True if self.is_executed_ok and os.path.isfile(self.result): - self.is_equal_result = filecmp.cmp(self.result, self.reject) + self.is_equal_result = filecmp.cmp(self.result, self.tmp_result) if self.is_executed_ok and self.is_equal_result: print "[ pass ]" - os.remove(self.reject) + os.remove(self.tmp_result) elif (self.is_executed_ok and not self.is_equal_result and not os.path.isfile(self.result)): - os.rename(self.reject, self.result) + os.rename(self.tmp_result, self.result) print "[ NEW ]" else: + os.rename(self.tmp_result, self.reject) print "[ fail ]" where = "" if not self.is_executed_ok: @@ -197,6 +201,7 @@ class TestSuite: self.ini["suite_path"] = suite_path self.ini["host"] = "localhost" self.ini["is_force"] = self.args.is_force + self.ini["vardir"] = args.vardir if os.access(suite_path, os.F_OK) == False: raise TestRunException("Suite \"" + suite_path +\ diff --git a/test/test-run.py b/test/test-run.py index 4321b2e3be520e8b1ed0bcf80ff4392f8d4c1f8e..6c821719438acb5dbe78527fc18b508d8d58c41e 100755 --- a/test/test-run.py +++ b/test/test-run.py @@ -39,14 +39,10 @@ from lib.test_suite import TestSuite, TestRunException class Options: """Handle options of test-runner""" def __init__(self): - """Add all program options, with their defaults. We assume - that the program is started from the directory where it is - located""" + """Add all program options, with their defaults.""" parser = argparse.ArgumentParser( - description = "Tarantool regression test suite front-end. \ - This program must be started from its working directory (" + - os.path.abspath(os.path.dirname(sys.argv[0])) + ").") + description = "Tarantool regression test suite front-end.") parser.epilog = "For a complete description, use 'pydoc ./" +\ os.path.basename(sys.argv[0]) + "'" @@ -68,8 +64,7 @@ class Options: metavar = "suite", nargs="*", default = ["box"], - help = """List of tests suites to look for tests in. Default: "box" - and "cmd".""") + help = """List of tests suites to look for tests in. Default: "box".""") parser.add_argument( "--force", @@ -98,9 +93,9 @@ class Options: parser.add_argument( "--bindir", dest = "bindir", - default = "../_debug_box", + default = "../core", help = "Path to server binary." - " Default: " + "../_debug_box.") + " Default: " + "../core.") parser.add_argument( "--vardir", @@ -118,28 +113,18 @@ class Options: vardir is sym-linked to /dev/shm/<vardir>. Linux only. Default: false""") - self.check(parser) self.args = parser.parse_args() - def check(self, parser): - """Check that the program is started from the directory where - it is located. This is necessary to minimize potential confusion - with absolute paths, since all default paths are relative to the - starting directory.""" - - if not os.path.exists(os.path.basename(sys.argv[0])): -# print first 6 lines of help - short_help = "\n".join(parser.format_help().split("\n")[0:6]) - print short_help - exit(-1) - - ####################################################################### # Program body ####################################################################### def main(): options = Options() + oldcwd = os.getcwd() + # Change the current working directory to where all test + # collections are supposed to reside. + os.chdir(os.path.dirname(sys.argv[0])) try: print "Started", " ".join(sys.argv) @@ -152,6 +137,8 @@ def main(): except RuntimeError as e: print "\nFatal error: {0}. Execution aborted.".format(e) return (-1) + finally: + os.chdir(oldcwd) return 0 diff --git a/third_party/CMakeLists.txt b/third_party/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..4db4ec376afc40946cbf908fc8c38b8c2e042678 --- /dev/null +++ b/third_party/CMakeLists.txt @@ -0,0 +1,9 @@ +add_library (misc STATIC crc32.c daemon.c proctitle.c qsort_arg.c) + +if (TARGET_OS_FREEBSD) + set_source_files_properties(proctitle.c PROPERTIES + COMPILE_FLAGS "-DHAVE_SETPROCTITLE") +endif() + +add_subdirectory(coro) +add_subdirectory(gopt) diff --git a/third_party/Makefile b/third_party/Makefile deleted file mode 100644 index a2de6b5a95732e4ca3ee103e6e9d0b0b605b1d49..0000000000000000000000000000000000000000 --- a/third_party/Makefile +++ /dev/null @@ -1,11 +0,0 @@ -obj += third_party/crc32.o -obj += third_party/daemon.o -obj += third_party/coro/coro.o -obj += third_party/proctitle.o -obj += third_party/confetti/prscfg.o -obj += third_party/gopt/gopt.o - -third_party/coro/coro.o third_party/confetti/prscfg.o: CFLAGS += -Wno-unused -third_party/gopt/gopt.o: CFLAGS += -Wno-all - -CFLAGS += -DCORO_$(CORO_IMPL) diff --git a/third_party/confetti/prscfg.c b/third_party/confetti/prscfg.c index 65653532140994507f48532012a9eed0ac51dcda..fa30e44ae72d41b1d1a6fee026a25f093d98b636 100644 --- a/third_party/confetti/prscfg.c +++ b/third_party/confetti/prscfg.c @@ -1,8 +1,6 @@ #include <third_party/confetti/prscfg.h> - void out_warning(ConfettyError r, char *format, ...); - #include <stdio.h> typedef struct prscfg_yy_extra_type { diff --git a/third_party/coro/CMakeLists.txt b/third_party/coro/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..cfa89654d2d7be6b99a9b115d031811aa1700b33 --- /dev/null +++ b/third_party/coro/CMakeLists.txt @@ -0,0 +1 @@ +add_library(coro STATIC coro.c) diff --git a/third_party/coro/coro.h b/third_party/coro/coro.h index e931718a14c7206ed9fb4f7ff64285b7a9797c09..9e1737eccc0d03a3d2013bd77089b470389d3957 100644 --- a/third_party/coro/coro.h +++ b/third_party/coro/coro.h @@ -199,17 +199,7 @@ void coro_destroy (coro_context *ctx); && !defined(CORO_SJLJ) && !defined(CORO_LINUX) \ && !defined(CORO_IRIX) && !defined(CORO_ASM) \ && !defined(CORO_PTHREAD) -# if defined(WINDOWS) -# define CORO_LOSER 1 /* you don't win with windoze */ -# elif defined(__linux) && (defined(__x86) || defined (__amd64)) -# define CORO_ASM 1 -# elif defined(HAVE_UCONTEXT_H) -# define CORO_UCONTEXT 1 -# elif defined(HAVE_SETJMP_H) && defined(HAVE_SIGALTSTACK) -# define CORO_SJLJ 1 -# else -error unknown or unsupported architecture -# endif +#error unknown or unsupported architecture #endif /*****************************************************************************/ diff --git a/third_party/gopt/CMakeLists.txt b/third_party/gopt/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..cba2b2b0be7d6a9363cb73d5d616afe06bb07df2 --- /dev/null +++ b/third_party/gopt/CMakeLists.txt @@ -0,0 +1,2 @@ +add_library(gopt STATIC gopt.c) +set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${core_cflags}") diff --git a/third_party/gopt/gopt.c b/third_party/gopt/gopt.c index 084f1ad807139bc9c368ce5dff85d9c0a55c3dba..a4aec5c2e50cc1b48f7946b17850959736bd5481 100644 --- a/third_party/gopt/gopt.c +++ b/third_party/gopt/gopt.c @@ -52,6 +52,7 @@ void *gopt_sort( int *argc, const char **argv, const void *opt_specs ){ size_t opt_count= 1; for( ; *arg_p; ++arg_p ) if( '-' == (*arg_p)[0] && (*arg_p)[1] ) + { if( '-' == (*arg_p)[1] ) if( (*arg_p)[2] ) ++opt_count; @@ -65,6 +66,7 @@ void *gopt_sort( int *argc, const char **argv, const void *opt_specs ){ break; } } + } opts= malloc( opt_count * sizeof(opt_t) ); }}} { @@ -132,7 +134,7 @@ void *gopt_sort( int *argc, const char **argv, const void *opt_specs ){ next_option-> arg= strchr( (*arg_p) + 2, '=' ) + 1; if( (char*)0 + 1 == next_option-> arg ){ ++arg_p; - if( !*arg_p || '-' == (*arg_p)[0] && (*arg_p)[1] ){ + if( !*arg_p || ('-' == (*arg_p)[0] && (*arg_p)[1] )){ fprintf( stderr, "%s: --%s: option requires an option argument\n", argv[0], (*(arg_p-1)) + 2 ); free( opts ); exit( EX_USAGE ); @@ -180,7 +182,7 @@ void *gopt_sort( int *argc, const char **argv, const void *opt_specs ){ else { ++arg_p; - if( !*arg_p || '-' == (*arg_p)[0] && (*arg_p)[1] ){ + if( !*arg_p || ('-' == (*arg_p)[0] && (*arg_p)[1])){ fprintf( stderr, "%s: -%c: option requires an option argument\n", argv[0], *short_opt ); free( opts ); exit( EX_USAGE ); @@ -197,9 +199,9 @@ void *gopt_sort( int *argc, const char **argv, const void *opt_specs ){ fprintf( stderr, "%s: -%c: unknown option\n", argv[0], *short_opt ); free( opts ); exit( EX_USAGE ); - continue_2: 0; + continue_2: ; } - break_2: 0; + break_2: ; }}} else *next_operand++= *arg_p; @@ -280,7 +282,7 @@ void gopt_help(const void *opt_def){ const int long_opt_width = 18; /* not counting leading "--" */ const int help_width = 54; - const char *help_padding = " "; + const char help_padding[] = " "; while (opt->key) { const char *shorts = opt->shorts; @@ -299,7 +301,7 @@ void gopt_help(const void *opt_def){ else printf(" "); if (opt->help_arg) - printf("--%s%-*s", *longs, long_opt_width - strlen(*longs), + printf("--%s%-*s", *longs, long_opt_width - (int) strlen(*longs), opt->help_arg); else printf("--%-*s", long_opt_width, *longs); @@ -312,10 +314,10 @@ void gopt_help(const void *opt_def){ p--; if (p == help) p = help + help_width; - printf("%.*s\n", p - help, help); + printf("%.*s\n", (int) (p - help), help); help = p; if (strlen(help)) - printf(help_padding); + printf("%s", help_padding); } puts(help); } else