Skip to content
Browse files

sync with tokyotyrant-1.1.17.tar.gz

  • Loading branch information...
1 parent 045a7c3 commit 264d1c6ce065031ca27a0b1176b0507dd1a185e3 @etrepum etrepum committed Mar 12, 2009
Showing with 221 additions and 98 deletions.
  1. +12 −0 ChangeLog
  2. +24 −19 configure
  3. +13 −9 configure.in
  4. +7 −5 doc/index.html
  5. +1 −1 example/tcrdbtblex.c
  6. +50 −16 man/hoge
  7. +6 −3 man/tcrdb.3
  8. +3 −1 man/ttserver.1
  9. +5 −3 tcrdb.c
  10. +6 −3 tcrdb.h
  11. +2 −2 tcrtest.c
  12. +52 −21 ttserver.c
  13. +30 −10 ttutil.c
  14. +10 −5 ttutil.h
View
12 ChangeLog
@@ -1,3 +1,15 @@
+2009-02-19 Mikio Hirabayashi <mikio@users.sourceforge.net>
+
+ * ttutil.c (tthttpfetch): timeout mechanism was added.
+
+ * ttserver.c (do_mc_delete): mismatch of the error message was resolved.
+
+ * ttserver.c (do_mc_incr, do_mc_decr): behavior became as with the original memcached.
+
+ * tcrdb.c (tcrdbqrysetlimit): new function instead of "tcrdbqrysetmax".
+
+ - Release: 1.1.17
+
2009-02-16 Mikio Hirabayashi <mikio@users.sourceforge.net>
* tcrdb.h: the macro "RDBITOPT" was added.
View
43 configure
@@ -1,6 +1,6 @@
#! /bin/sh
# Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.61 for tokyotyrant 1.1.16.
+# Generated by GNU Autoconf 2.61 for tokyotyrant 1.1.17.
#
# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001,
# 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
@@ -572,8 +572,8 @@ SHELL=${CONFIG_SHELL-/bin/sh}
# Identity of this package.
PACKAGE_NAME='tokyotyrant'
PACKAGE_TARNAME='tokyotyrant'
-PACKAGE_VERSION='1.1.16'
-PACKAGE_STRING='tokyotyrant 1.1.16'
+PACKAGE_VERSION='1.1.17'
+PACKAGE_STRING='tokyotyrant 1.1.17'
PACKAGE_BUGREPORT=''
# Factoring default headers for most tests.
@@ -1194,7 +1194,7 @@ if test "$ac_init_help" = "long"; then
# Omit some internal or obsolete options to make the list less imposing.
# This message is too long to be a string in the A/UX 3.1 sh.
cat <<_ACEOF
-\`configure' configures tokyotyrant 1.1.16 to adapt to many kinds of systems.
+\`configure' configures tokyotyrant 1.1.17 to adapt to many kinds of systems.
Usage: $0 [OPTION]... [VAR=VALUE]...
@@ -1255,7 +1255,7 @@ fi
if test -n "$ac_init_help"; then
case $ac_init_help in
- short | recursive ) echo "Configuration of tokyotyrant 1.1.16:";;
+ short | recursive ) echo "Configuration of tokyotyrant 1.1.17:";;
esac
cat <<\_ACEOF
@@ -1349,7 +1349,7 @@ fi
test -n "$ac_init_help" && exit $ac_status
if $ac_init_version; then
cat <<\_ACEOF
-tokyotyrant configure 1.1.16
+tokyotyrant configure 1.1.17
generated by GNU Autoconf 2.61
Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001,
@@ -1363,7 +1363,7 @@ cat >config.log <<_ACEOF
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
-It was created by tokyotyrant $as_me 1.1.16, which was
+It was created by tokyotyrant $as_me 1.1.17, which was
generated by GNU Autoconf 2.61. Invocation command line was
$ $0 $@
@@ -1718,8 +1718,8 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu
# Package information
-MYLIBVER=2
-MYLIBREV=7
+MYLIBVER=3
+MYLIBREV=1
MYPROTVER="0.9"
# Targets
@@ -1746,9 +1746,8 @@ MYLDLIBPATHENV="LD_LIBRARY_PATH"
MYPOSTCMD="true"
# Building paths
-pathtmp="$PATH"
-PATH="$HOME/bin:/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/bin:/sbin"
-PATH="$PATH:/usr/ccs/bin:/usr/ucb:/usr/xpg4/bin:/usr/xpg6/bin:$pathtmp"
+PATH="$PATH:$HOME/bin:/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/bin:/sbin"
+PATH="$PATH:/opt/SUNWspro/bin:/usr/ccs/bin:/usr/xpg4/bin:/usr/xpg6/bin:/usr/ucb"
CPATH="$HOME/include:/usr/local/include:$CPATH"
LIBRARY_PATH="$HOME/lib:/usr/local/lib:$LIBRARY_PATH"
LD_LIBRARY_PATH="$HOME/lib:/usr/local/lib:$LD_LIBRARY_PATH"
@@ -1915,11 +1914,6 @@ printf '#================================================================\n'
# Checking Commands and Libraries
#================================================================
-# Reset variables
-test -n "$CFLAGS" && MYCFLAGS="$CFLAGS $MYCFLAGS"
-test -n "$CPPFLAGS" && MYCPPFLAGS="$CPPFLAGS $MYCPPFLAGS"
-test -n "$LDFLAGS" && MYLDFLAGS="$LDFLAGS $MYLDFLAGS"
-
# C compiler
ac_ext=c
ac_cpp='$CPP $CPPFLAGS'
@@ -2841,6 +2835,17 @@ ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $
ac_compiler_gnu=$ac_cv_c_compiler_gnu
+# Reset variables
+if test "$GCC" != "yes"
+then
+ { echo "$as_me:$LINENO: WARNING: another compiler except for GCC was detected" >&5
+echo "$as_me: WARNING: another compiler except for GCC was detected" >&2;}
+ MYCFLAGS=""
+fi
+test -n "$CFLAGS" && MYCFLAGS="$CFLAGS $MYCFLAGS"
+test -n "$CPPFLAGS" && MYCPPFLAGS="$CPPFLAGS $MYCPPFLAGS"
+test -n "$LDFLAGS" && MYLDFLAGS="$LDFLAGS $MYLDFLAGS"
+
# Byte order
ac_ext=c
@@ -5907,7 +5912,7 @@ exec 6>&1
# report actual input values of CONFIG_FILES etc. instead of their
# values after options handling.
ac_log="
-This file was extended by tokyotyrant $as_me 1.1.16, which was
+This file was extended by tokyotyrant $as_me 1.1.17, which was
generated by GNU Autoconf 2.61. Invocation command line was
CONFIG_FILES = $CONFIG_FILES
@@ -5950,7 +5955,7 @@ Report bugs to <bug-autoconf@gnu.org>."
_ACEOF
cat >>$CONFIG_STATUS <<_ACEOF
ac_cs_version="\\
-tokyotyrant config.status 1.1.16
+tokyotyrant config.status 1.1.17
configured by $0, generated by GNU Autoconf 2.61,
with options \\"`echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`\\"
View
22 configure.in
@@ -7,11 +7,11 @@
#================================================================
# Package name
-AC_INIT(tokyotyrant, 1.1.16)
+AC_INIT(tokyotyrant, 1.1.17)
# Package information
-MYLIBVER=2
-MYLIBREV=7
+MYLIBVER=3
+MYLIBREV=1
MYPROTVER="0.9"
# Targets
@@ -38,9 +38,8 @@ MYLDLIBPATHENV="LD_LIBRARY_PATH"
MYPOSTCMD="true"
# Building paths
-pathtmp="$PATH"
-PATH="$HOME/bin:/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/bin:/sbin"
-PATH="$PATH:/usr/ccs/bin:/usr/ucb:/usr/xpg4/bin:/usr/xpg6/bin:$pathtmp"
+PATH="$PATH:$HOME/bin:/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/bin:/sbin"
+PATH="$PATH:/opt/SUNWspro/bin:/usr/ccs/bin:/usr/xpg4/bin:/usr/xpg6/bin:/usr/ucb"
CPATH="$HOME/include:/usr/local/include:$CPATH"
LIBRARY_PATH="$HOME/lib:/usr/local/lib:$LIBRARY_PATH"
LD_LIBRARY_PATH="$HOME/lib:/usr/local/lib:$LD_LIBRARY_PATH"
@@ -177,14 +176,19 @@ printf '#================================================================\n'
# Checking Commands and Libraries
#================================================================
+# C compiler
+AC_PROG_CC
+
# Reset variables
+if test "$GCC" != "yes"
+then
+ AC_MSG_WARN([another compiler except for GCC was detected])
+ MYCFLAGS=""
+fi
test -n "$CFLAGS" && MYCFLAGS="$CFLAGS $MYCFLAGS"
test -n "$CPPFLAGS" && MYCPPFLAGS="$CPPFLAGS $MYCPPFLAGS"
test -n "$LDFLAGS" && MYLDFLAGS="$LDFLAGS $MYLDFLAGS"
-# C compiler
-AC_PROG_CC
-
# Byte order
AC_C_BIGENDIAN(MYCPPFLAGS="$MYCPPFLAGS -D_MYBIGEND")
View
12 doc/index.html
@@ -262,7 +262,7 @@ <h3 id="serverprog_ttserver">ttserver</h3>
<p>The command `<code>ttserver</code>' runs the server managing a database instance. Because the database is treated by the abstract API of Tokyo Cabinet, you can choose the scheme on start-up of the server. Supported schema are on-memory hash database, on-memory tree database, hash database, and B+ tree database. This command is used in the following format. `<var>dbname</var>' specifies the database name. If it is omitted, on-memory hash database is specified.</p>
<dl class="api">
-<dt><code>ttserver [-host <var>name</var>] [-port <var>num</var>] [-th<var>num</var> <var>num</var>] [-tout <var>num</var>] [-dmn] [-pid <var>path</var>] [-log <var>path</var>] [-ld|-le] [-ulog <var>path</var>] [-ulim <var>num</var>] [-uas] [-sid <var>num</var>] [-mhost <var>name</var>] [-mport <var>num</var>] [-rts <var>path</var>] [-ext <var>path</var>] [-extpc <var>name</var> <var>period</var>] [-mask <var>expr</var>] [<var>dbname</var>]</code></dt>
+<dt><code>ttserver [-host <var>name</var>] [-port <var>num</var>] [-th<var>num</var> <var>num</var>] [-tout <var>num</var>] [-dmn] [-pid <var>path</var>] [-kl] [-log <var>path</var>] [-ld|-le] [-ulog <var>path</var>] [-ulim <var>num</var>] [-uas] [-sid <var>num</var>] [-mhost <var>name</var>] [-mport <var>num</var>] [-rts <var>path</var>] [-ext <var>path</var>] [-extpc <var>name</var> <var>period</var>] [-mask <var>expr</var>] [<var>dbname</var>]</code></dt>
</dl>
<p>Options feature the following.</p>
@@ -274,6 +274,7 @@ <h3 id="serverprog_ttserver">ttserver</h3>
<li><code>-tout <var>num</var></code> : specify the timeout of each session in seconds. By default, no timeout is specified.</li>
<li><code>-dmn</code> : work as a daemon process.</li>
<li><code>-pid <var>path</var></code> : output the process ID into the file.</li>
+<li><code>-kl</code> : kill the existing process if the process ID file is detected.</li>
<li><code>-log <var>path</var></code> : output log messages into the file.</li>
<li><code>-ld</code> : log debug messages also.</li>
<li><code>-le</code> : log error messages only.</li>
@@ -1035,12 +1036,13 @@ <h3 id="tcrdbapi_apitbl">API of the Table Extension</h3>
<dd>`<var>type</var>' specifies the order type: `RDBQOSTRASC' for string ascending, `RDBQOSTRDESC' for string descending, `RDBQONUMASC' for number ascending, `RDBQONUMDESC' for number descending.</dd>
</dl>
-<p>The function `tcrdbqrysetmax' is used in order to set the maximum number of records of the result of a query object.</p>
+<p>The function `tcrdbqrysetlimit' is used in order to set the limit number of records of the result of a query object.</p>
<dl class="api">
-<dt><code>void tcrdbqrysetmax(RDBQRY *<var>qry</var>, int <var>max</var>);</code></dt>
+<dt><code>void tcrdbqrysetlimit(RDBQRY *<var>qry</var>, int <var>max</var>, int <var>skip</var>);</code></dt>
<dd>`<var>qry</var>' specifies the query object.</dd>
-<dd>`<var>max</var>' specifies the maximum number of records of the result.</dd>
+<dd>`<var>max</var>' specifies the maximum number of records of the result. If it is negative, no limit is specified.</dd>
+<dd>`<var>skip</var>' specifies the number of skipped records of the result. If it is not more than 0, no record is skipped.</dd>
</dl>
<p>The function `tcrdbqrysearch' is used in order to execute the search of a query object.</p>
@@ -1186,7 +1188,7 @@ <h3 id="tcrdbapi_example">Example Code</h3>
tcrdbqryaddcond(qry, "age", RDBQCNUMGE, "20");
tcrdbqryaddcond(qry, "lang", RDBQCSTROR, "ja,en");
tcrdbqrysetorder(qry, "name", RDBQOSTRASC);
- tcrdbqrysetmax(qry, 10);
+ tcrdbqrysetlimit(qry, 10, 0);
res = tcrdbqrysearch(qry);
for(i = 0; i &lt; tclistnum(res); i++){
rbuf = tclistval(res, i, &amp;rsiz);
View
2 example/tcrdbtblex.c
@@ -48,7 +48,7 @@ int main(int argc, char **argv){
tcrdbqryaddcond(qry, "age", RDBQCNUMGE, "20");
tcrdbqryaddcond(qry, "lang", RDBQCSTROR, "ja,en");
tcrdbqrysetorder(qry, "name", RDBQOSTRASC);
- tcrdbqrysetmax(qry, 10);
+ tcrdbqrysetlimit(qry, 10, 0);
res = tcrdbqrysearch(qry);
for(i = 0; i < tclistnum(res); i++){
rbuf = tclistval(res, i, &rsiz);
View
66 man/hoge
@@ -1,4 +1,4 @@
-.TH "INTRO" 3 "2009-02-04" "Man Page" "Tokyo Cabinet"
+.TH "INTRO" 3 "2009-03-09" "Man Page" "Tokyo Cabinet"
.SH TOKYO TYRANT: NETWORK INTERFACE OF TOKYO CABINET
@@ -25,11 +25,13 @@ License
.SH INTRODUCTION
.PP
-Tokyo Tyrant is a package of network interface to the DBM called Tokyo Cabinet. Though the DBM has high performance, you might bother in case that multiple processes share the same database, or remote processes access the database. Thus, Tokyo Tyrant is provided for concurrent and remote connections to Tokyo Cabinet. It is composed of the server process managing a database and its access library for client applications. The server can embed Lua, a lightweight script language so that you can define arbitrary operations of the database.
+Tokyo Tyrant is a package of network interface to the DBM called Tokyo Cabinet. Though the DBM has high performance, you might bother in case that multiple processes share the same database, or remote processes access the database. Thus, Tokyo Tyrant is provided for concurrent and remote connections to Tokyo Cabinet. It is composed of the server process managing a database and its access library for client applications.
.PP
-The server features high concurrency due to thread\-pool modeled implementation and the epoll/kqueue mechanism of the modern Linux/*BSD kernel. The server and its clients communicate with each other by simple binary protocol on TCP/IP. Protocols compatible with memcached and HTTP/1.1 are also supported so that almost all principal platforms and programming languages can use Tokyo Tyrant. High availability and high integrity are also featured due to such mechanisms as hot backup, update logging, and replication.
+The server features high concurrency due to thread\-pool modeled implementation and the epoll/kqueue mechanism of the modern Linux/*BSD kernel. The server and its clients communicate with each other by simple binary protocol on TCP/IP. Protocols compatible with memcached and HTTP/1.1 are also supported so that almost all principal platforms and programming languages can use Tokyo Tyrant. High availability and high integrity are also featured due to such mechanisms as hot backup, update logging, and replication. The server can embed Lua, a lightweight script language so that you can define arbitrary operations of the database.
.PP
-As for now, the server works on Linux, FreeBSD, Mac OS X only.
+Because the server uses the abstract API of Tokyo Cabinet, all of the six APIs: the on\-memory hash database API, the on\-memory tree database API, the hash API, the B+ tree database API, the fixed\-length database API, and the table database API, are available from the client with the common interface. Moreover, the table extension is provided to use specifidc features of the table database.
+.PP
+As for now, the server works on Linux, FreeBSD, Mac OS X, Solaris only.
.SH INSTALLATION
.PP
@@ -57,7 +59,7 @@ The command `\fBttserver\fR' runs the server managing a database instance. Beca
.PP
.RS
.br
-\fBttserver \fR[\fB\-host \fIname\fB\fR]\fB \fR[\fB\-port \fInum\fB\fR]\fB \fR[\fB\-th\fInum\fB \fInum\fB\fR]\fB \fR[\fB\-tout \fInum\fB\fR]\fB \fR[\fB\-dmn\fR]\fB \fR[\fB\-pid \fIpath\fB\fR]\fB \fR[\fB\-log \fIpath\fB\fR]\fB \fR[\fB\-ld\fR|\fB\-le\fR]\fB \fR[\fB\-ulog \fIpath\fB\fR]\fB \fR[\fB\-ulim \fInum\fB\fR]\fB \fR[\fB\-uas\fR]\fB \fR[\fB\-sid \fInum\fB\fR]\fB \fR[\fB\-mhost \fIname\fB\fR]\fB \fR[\fB\-mport \fInum\fB\fR]\fB \fR[\fB\-rts \fIpath\fB\fR]\fB \fR[\fB\-ext \fIpath\fB\fR]\fB \fR[\fB\-mask \fIexpr\fB\fR]\fB \fR[\fB\fIdbname\fB\fR]\fB\fR
+\fBttserver \fR[\fB\-host \fIname\fB\fR]\fB \fR[\fB\-port \fInum\fB\fR]\fB \fR[\fB\-th\fInum\fB \fInum\fB\fR]\fB \fR[\fB\-tout \fInum\fB\fR]\fB \fR[\fB\-dmn\fR]\fB \fR[\fB\-pid \fIpath\fB\fR]\fB \fR[\fB\-kl\fR]\fB \fR[\fB\-log \fIpath\fB\fR]\fB \fR[\fB\-ld\fR|\fB\-le\fR]\fB \fR[\fB\-ulog \fIpath\fB\fR]\fB \fR[\fB\-ulim \fInum\fB\fR]\fB \fR[\fB\-uas\fR]\fB \fR[\fB\-sid \fInum\fB\fR]\fB \fR[\fB\-mhost \fIname\fB\fR]\fB \fR[\fB\-mport \fInum\fB\fR]\fB \fR[\fB\-rts \fIpath\fB\fR]\fB \fR[\fB\-ext \fIpath\fB\fR]\fB \fR[\fB\-extpc \fIname\fB \fIperiod\fB\fR]\fB \fR[\fB\-mask \fIexpr\fB\fR]\fB \fR[\fB\fIdbname\fB\fR]\fB\fR
.RE
.PP
Options feature the following.
@@ -75,6 +77,8 @@ Options feature the following.
.br
\fB\-pid \fIpath\fR\fR : output the process ID into the file.
.br
+\fB\-kl\fR : kill the existing process if the process ID file is detected.
+.br
\fB\-log \fIpath\fR\fR : output log messages into the file.
.br
\fB\-ld\fR : log debug messages also.
@@ -97,6 +101,8 @@ Options feature the following.
.br
\fB\-ext \fIpath\fR\fR : specify the script language extension file.
.br
+\fB\-extpc \fIname\fR \fIperiod\fR\fR : specify the function name and the calling period of a periodic command.
+.br
\fB\-mask \fIexpr\fR\fR : specify the names of forbidden commands.
.br
\fB\-unmask \fIexpr\fR\fR : specify the names of allowed commands.
@@ -1075,7 +1081,7 @@ The function `tcrdbext' is used in order to call a function of the script langua
`\fIname\fR' specifies the function name.
.RE
.RS
-`\fIopts\fR' specifies options by bitwise or: `RDBXOLCKREC' for record locking, `RDBXOLCKGLB' for global locking.
+`\fIopts\fR' specifies options by bitwise\-or: `RDBXOLCKREC' for record locking, `RDBXOLCKGLB' for global locking.
.RE
.RS
`\fIkbuf\fR' specifies the pointer to the region of the key.
@@ -1112,7 +1118,7 @@ The function `tcrdbext2' is used in order to call a function of the script langu
`\fIname\fR' specifies the function name.
.RE
.RS
-`\fIopts\fR' specifies options by bitwise or: `RDBXOLCKREC' for record locking, `RDBXOLCKGLB' for global locking.
+`\fIopts\fR' specifies options by bitwise\-or: `RDBXOLCKREC' for record locking, `RDBXOLCKGLB' for global locking.
.RE
.RS
`\fIkstr\fR' specifies the string of the key.
@@ -1265,7 +1271,7 @@ The function `tcrdbmisc' is used in order to call a versatile function for misce
`\fIname\fR' specifies the name of the function. All databases support "put", "out", "get", "putlist", "outlist", and "getlist". "put" is to store a record. It receives a key and a value, and returns an empty list. "out" is to remove a record. It receives a key, and returns an empty list. "get" is to retrieve a record. It receives a key, and returns a list of the values. "putlist" is to store records. It receives keys and values one after the other, and returns an empty list. "outlist" is to remove records. It receives keys, and returns an empty list. "getlist" is to retrieve records. It receives keys, and returns keys and values of corresponding records one after the other.
.RE
.RS
-`\fIopts\fR' specifies options by bitwise or: `RDBMONOULOG' for omission of the update log.
+`\fIopts\fR' specifies options by bitwise\-or: `RDBMONOULOG' for omission of the update log.
.RE
.RS
`\fIargs\fR' specifies a list object containing arguments.
@@ -1408,7 +1414,7 @@ The function `tcrdbtblsetindex' is used in order to set a column index to a remo
`\fIname\fR' specifies the name of a column. If the name of an existing index is specified, the index is rebuilt. An empty string means the primary key.
.RE
.RS
-`\fItype\fR' specifies the index type: `RDBITLEXICAL' for lexical string, `RDBITDECIMAL' for decimal string. If it is `RDBITVOID', the index is removed. If `RDBITKEEP' is added by bitwise or and the index exists, this function merely returns failure.
+`\fItype\fR' specifies the index type: `RDBITLEXICAL' for lexical string, `RDBITDECIMAL' for decimal string. If it is `RDBITOPT', the index is optimized. If it is `RDBITVOID', the index is removed. If `RDBITKEEP' is added by bitwise\-or and the index exists, this function merely returns failure.
.RE
.RS
If successful, the return value is true, else, it is false.
@@ -1466,7 +1472,7 @@ The function `tcrdbqryaddcond' is used in order to add a narrowing condition to
`\fIname\fR' specifies the name of a column. An empty string means the primary key.
.RE
.RS
-`\fIop\fR' specifies an operation type: `RDBQCSTREQ' for string which is equal to the expression, `RDBQCSTRINC' for string which is included in the expression, `RDBQCSTRBW' for string which begins with the expression, `RDBQCSTREW' for string which ends with the expression, `RDBQCSTRAND' for string which includes all tokens in the expression, `RDBQCSTROR' for string which includes at least one token in the expression, `RDBQCSTROREQ' for string which is equal to at least one token in the expression, `RDBQCSTRRX' for string which matches regular expressions of the expression, `RDBQCNUMEQ' for number which is equal to the expression, `RDBQCNUMGT' for number which is greater than the expression, `RDBQCNUMGE' for number which is greater than or equal to the expression, `RDBQCNUMLT' for number which is less than the expression, `RDBQCNUMLE' for number which is less than or equal to the expression, `RDBQCNUMBT' for number which is between two tokens of the expression, `RDBQCNUMOREQ' for number which is equal to at least one token in the expression. All operations can be flagged by bitwise or: `RDBQCNEGATE' for negation, `RDBQCNOIDX' for using no index.
+`\fIop\fR' specifies an operation type: `RDBQCSTREQ' for string which is equal to the expression, `RDBQCSTRINC' for string which is included in the expression, `RDBQCSTRBW' for string which begins with the expression, `RDBQCSTREW' for string which ends with the expression, `RDBQCSTRAND' for string which includes all tokens in the expression, `RDBQCSTROR' for string which includes at least one token in the expression, `RDBQCSTROREQ' for string which is equal to at least one token in the expression, `RDBQCSTRRX' for string which matches regular expressions of the expression, `RDBQCNUMEQ' for number which is equal to the expression, `RDBQCNUMGT' for number which is greater than the expression, `RDBQCNUMGE' for number which is greater than or equal to the expression, `RDBQCNUMLT' for number which is less than the expression, `RDBQCNUMLE' for number which is less than or equal to the expression, `RDBQCNUMBT' for number which is between two tokens of the expression, `RDBQCNUMOREQ' for number which is equal to at least one token in the expression. All operations can be flagged by bitwise\-or: `RDBQCNEGATE' for negation, `RDBQCNOIDX' for using no index.
.RE
.RS
`\fIexpr\fR' specifies an operand exression.
@@ -1489,16 +1495,19 @@ The function `tcrdbqrysetorder' is used in order to set the order of a query obj
.RE
.RE
.PP
-The function `tcrdbqrysetmax' is used in order to set the maximum number of records of the result of a query object.
+The function `tcrdbqrysetlimit' is used in order to set the limit number of records of the result of a query object.
.PP
.RS
.br
-\fBvoid tcrdbqrysetmax(RDBQRY *\fIqry\fB, int \fImax\fB);\fR
+\fBvoid tcrdbqrysetlimit(RDBQRY *\fIqry\fB, int \fImax\fB, int \fIskip\fB);\fR
.RS
`\fIqry\fR' specifies the query object.
.RE
.RS
-`\fImax\fR' specifies the maximum number of records of the result.
+`\fImax\fR' specifies the maximum number of records of the result. If it is negative, no limit is specified.
+.RE
+.RS
+`\fIskip\fR' specifies the number of skipped records of the result. If it is not more than 0, no record is skipped.
.RE
.RE
.PP
@@ -1569,6 +1578,8 @@ Because the object of the return value is created with the function `tcmapnew',
.SH EXAMPLE CODE
.PP
The following code is an example to use a remote database.
+.PP
+The following code is an example to use a remote database with the table extension.
.SH HOW TO USE THE LIBRARY
.PP
@@ -2688,9 +2699,9 @@ iteration: Arbitrary data of the element
.PP
To finish the session, the client can shutdown and close the socket at any time. If not closed, the connection can be reused for the next session. If protocol violation or some fatal error occurs, the server immediately breaks the session and closes the connection.
.PP
-As for the memcached compatible protocol, the server implements the following commands; "set", "add", "replace", "get", "delete", "incr", "decr", "stats", "flush_all", "version", and "quit". "noreply" options of update commands are also supported. However, "flags", "exptime", and "cas unique" parameters are ignored. The limitation size of each query is 8192 bytes except for the entity of the value.
+As for the memcached compatible protocol, the server implements the following commands; "set", "add", "replace", "get", "delete", "incr", "decr", "stats", "flush_all", "version", and "quit". "noreply" options of update commands are also supported. However, "flags", "exptime", and "cas unique" parameters are ignored.
.PP
-As for the HTTP/1.1 compatible protocol, the server implements the following commands; "GET" (relevant to `tcrdbget'), "HEAD" (relevant to `tcrdbvsiz'), "PUT" (relevant to `tcrdbput'), "POST" (relevant to `tcrdbext'), and "DELETE" (relevant to `tcrdbout'). The URI of each request is treated as the key encoded by the URL encoding. And the entity body is treated as the value. However, headers except for "Connection" and "Content\-Length" are ignored. The limitation size of each query is 8192 bytes. "PUT" can have the header "X\-TT\-PDMODE" whose value is either of 1 (relevant to `tcrdbputkeep'), 2 (relevant to `tcrdbputcat'), or else (relevant to `tcrdbput'). "POST" should have the header "X\-TT\-XNAME" whose value stands for the function name to be called. "POST" can have the header "X\-TT\-XOPTS" whose value stands for bitwise\-or options of 1 (record locking) and 2 (global locking).
+As for the HTTP/1.1 compatible protocol, the server implements the following commands; "GET" (relevant to `tcrdbget'), "HEAD" (relevant to `tcrdbvsiz'), "PUT" (relevant to `tcrdbput'), "POST" (relevant to `tcrdbext'), and "DELETE" (relevant to `tcrdbout'). The URI of each request is treated as the key encoded by the URL encoding. And the entity body is treated as the value. However, headers except for "Connection" and "Content\-Length" are ignored. "PUT" can have the header "X\-TT\-PDMODE" whose value is either of 1 (relevant to `tcrdbputkeep'), 2 (relevant to `tcrdbputcat'), or else (relevant to `tcrdbput'). "POST" should have the header "X\-TT\-XNAME" whose value stands for the function name to be called. "POST" can have the header "X\-TT\-XOPTS" whose value stands for bitwise\-or options of 1 (record locking) and 2 (global locking).
.SH TUTORIAL
@@ -2841,7 +2852,7 @@ Fibonacci numbers can be generated by another algorithm, which is naive and stat
.PP
Then, restart the server and test the new algorithm.
.PP
-As you see, the called function receives two string parameters of the key and the value. The return value is sent back to the client. You can use such built\-in functions for database operations as "_put", "_out", "_get", and so on. There is a sample file `\fB/usr/local/share/tokyotyrant/senatus.lua\fR'.
+As you see, the called function receives two string parameters of the key and the value. The return value is sent back to the client. You can use such built\-in functions for database operations as "_put", "_out", "_get", and so on. There is a sample file `\fBext/senatus.lua\fR'.
.SH USING MEMCACHED CLIENT
.PP
@@ -2851,6 +2862,29 @@ This section describes how to use a memcached client library of Perl (Cache::Mem
.PP
This section describes how to use an HTTP client library of Perl (LWP::UserAgent) with Tokyo Tyrant. Run the server of Tokyo Tyrant as usual. And, the following script is a typical example.
+.SH PERSISTENT BUT EXPIRABLE CACHE
+.PP
+If you want to cache data like session information for your Web application but want to avoid data loss because of the server crash, using Tokyo Tyrant can be the solution, that is to say, "persistent" expirable cache. It requires the following preconditions.
+.PP
+.RS
+The server must open a table database.
+.br
+Clients should store each record with an expiration date column.
+.br
+The database should have an index for the expiration date column.
+.br
+The server must periodically call the user defined function provided through the Lua extension.
+.br
+.RE
+.PP
+First, prepare the following script for expiration and save it as "ttexpire.lua". It will expire records where the value of the "x" column exceeds the current date.
+.PP
+Start the server by opening a table database which has the index for the "x" column, and by scheduling it to call the expiration function per second.
+.PP
+Store test records from another terminal.
+.PP
+You can confirm that the records are being removed by expiration.
+
.SH LICENSE
.PP
Tokyo Tyrant is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License or any later version.
View
9 man/tcrdb.3
@@ -1068,16 +1068,19 @@ The function `tcrdbqrysetorder' is used in order to set the order of a query obj
.RE
.RE
.PP
-The function `tcrdbqrysetmax' is used in order to set the maximum number of records of the result of a query object.
+The function `tcrdbqrysetlimit' is used in order to set the limit number of records of the result of a query object.
.PP
.RS
.br
-\fBvoid tcrdbqrysetmax(RDBQRY *\fIqry\fB, int \fImax\fB);\fR
+\fBvoid tcrdbqrysetlimit(RDBQRY *\fIqry\fB, int \fImax\fB, int \fIskip\fB);\fR
.RS
`\fIqry\fR' specifies the query object.
.RE
.RS
-`\fImax\fR' specifies the maximum number of records of the result.
+`\fImax\fR' specifies the maximum number of records of the result. If it is negative, no limit is specified.
+.RE
+.RS
+`\fIskip\fR' specifies the number of skipped records of the result. If it is not more than 0, no record is skipped.
.RE
.RE
.PP
View
4 man/ttserver.1
@@ -9,7 +9,7 @@ The command `\fBttserver\fR' runs the server managing a database instance. Beca
.PP
.RS
.br
-\fBttserver \fR[\fB\-host \fIname\fB\fR]\fB \fR[\fB\-port \fInum\fB\fR]\fB \fR[\fB\-th\fInum\fB \fInum\fB\fR]\fB \fR[\fB\-tout \fInum\fB\fR]\fB \fR[\fB\-dmn\fR]\fB \fR[\fB\-pid \fIpath\fB\fR]\fB \fR[\fB\-log \fIpath\fB\fR]\fB \fR[\fB\-ld\fR|\fB\-le\fR]\fB \fR[\fB\-ulog \fIpath\fB\fR]\fB \fR[\fB\-ulim \fInum\fB\fR]\fB \fR[\fB\-uas\fR]\fB \fR[\fB\-sid \fInum\fB\fR]\fB \fR[\fB\-mhost \fIname\fB\fR]\fB \fR[\fB\-mport \fInum\fB\fR]\fB \fR[\fB\-rts \fIpath\fB\fR]\fB \fR[\fB\-ext \fIpath\fB\fR]\fB \fR[\fB\-extpc \fIname\fB \fIperiod\fB\fR]\fB \fR[\fB\-mask \fIexpr\fB\fR]\fB \fR[\fB\fIdbname\fB\fR]\fB\fR
+\fBttserver \fR[\fB\-host \fIname\fB\fR]\fB \fR[\fB\-port \fInum\fB\fR]\fB \fR[\fB\-th\fInum\fB \fInum\fB\fR]\fB \fR[\fB\-tout \fInum\fB\fR]\fB \fR[\fB\-dmn\fR]\fB \fR[\fB\-pid \fIpath\fB\fR]\fB \fR[\fB\-kl\fR]\fB \fR[\fB\-log \fIpath\fB\fR]\fB \fR[\fB\-ld\fR|\fB\-le\fR]\fB \fR[\fB\-ulog \fIpath\fB\fR]\fB \fR[\fB\-ulim \fInum\fB\fR]\fB \fR[\fB\-uas\fR]\fB \fR[\fB\-sid \fInum\fB\fR]\fB \fR[\fB\-mhost \fIname\fB\fR]\fB \fR[\fB\-mport \fInum\fB\fR]\fB \fR[\fB\-rts \fIpath\fB\fR]\fB \fR[\fB\-ext \fIpath\fB\fR]\fB \fR[\fB\-extpc \fIname\fB \fIperiod\fB\fR]\fB \fR[\fB\-mask \fIexpr\fB\fR]\fB \fR[\fB\fIdbname\fB\fR]\fB\fR
.RE
.PP
Options feature the following.
@@ -27,6 +27,8 @@ Options feature the following.
.br
\fB\-pid \fIpath\fR\fR : output the process ID into the file.
.br
+\fB\-kl\fR : kill the existing process if the process ID file is detected.
+.br
\fB\-log \fIpath\fR\fR : output log messages into the file.
.br
\fB\-ld\fR : log debug messages also.
View
8 tcrdb.c
@@ -1391,12 +1391,14 @@ void tcrdbqrysetorder(RDBQRY *qry, const char *name, int type){
}
-/* Set the maximum number of records of the result of a query object. */
-void tcrdbqrysetmax(RDBQRY *qry, int max){
+/* Set the limit number of records of the result of a query object. */
+void tcrdbqrysetlimit(RDBQRY *qry, int max, int skip){
TCXSTR *xstr = tcxstrnew();
- tcxstrcat2(xstr, "setmax");
+ tcxstrcat2(xstr, "setlimit");
tcxstrcat(xstr, "\0", 1);
tcxstrprintf(xstr, "%d", max);
+ tcxstrcat(xstr, "\0", 1);
+ tcxstrprintf(xstr, "%d", skip);
tclistpush(qry->args, tcxstrptr(xstr), tcxstrsize(xstr));
tcxstrdel(xstr);
}
View
9 tcrdb.h
@@ -629,10 +629,13 @@ void tcrdbqryaddcond(RDBQRY *qry, const char *name, int op, const char *expr);
void tcrdbqrysetorder(RDBQRY *qry, const char *name, int type);
-/* Set the maximum number of records of the result of a query object.
+/* Set the limit number of records of the result of a query object.
`qry' specifies the query object.
- `max' specifies the maximum number of records of the result. */
-void tcrdbqrysetmax(RDBQRY *qry, int max);
+ `max' specifies the maximum number of records of the result. If it is negative, no limit is
+ specified.
+ `skip' specifies the number of skipped records of the result. If it is not more than 0, no
+ record is skipped. */
+void tcrdbqrysetlimit(RDBQRY *qry, int max, int skip);
/* Execute the search of a query object.
View
4 tcrtest.c
@@ -1317,7 +1317,7 @@ static int proctable(const char *host, int port, int cnum, int rnum){
int type = types[myrand(sizeof(types) / sizeof(*types))];
tcrdbqrysetorder(qry, name, type);
}
- tcrdbqrysetmax(qry, myrand(10));
+ tcrdbqrysetlimit(qry, myrand(10), myrand(5) * 10);
TCLIST *res = tcrdbqrysearch(qry);
tclistdel(res);
tcrdbqrydel(qry);
@@ -1330,7 +1330,7 @@ static int proctable(const char *host, int port, int cnum, int rnum){
RDBQRY *qry = tcrdbqrynew(rdb);
tcrdbqryaddcond(qry, "", RDBQCSTRBW, "1");
tcrdbqrysetorder(qry, "str", RDBQOSTRASC);
- tcrdbqrysetmax(qry, 10);
+ tcrdbqrysetlimit(qry, 10, 0);
TCLIST *res = tcrdbqrysearchget(qry);
for(int i = 0; i < tclistnum(res); i++){
TCMAP *cols = tcrdbqryrescols(res, i);
View
73 ttserver.c
@@ -114,7 +114,7 @@ static uint64_t getcmdmask(const char *expr);
static void sigtermhandler(int signum);
static void sigchldhandler(int signum);
static int proc(const char *dbname, const char *host, int port, int thnum, int tout,
- bool dmn, const char *pidpath, const char *logpath,
+ bool dmn, const char *pidpath, bool kl, const char *logpath,
const char *ulogpath, uint64_t ulim, bool uas, uint32_t sid,
const char *mhost, int mport, const char *rtspath, const char *extpath,
const TCLIST *extpcs, uint64_t mask);
@@ -184,6 +184,7 @@ int main(int argc, char **argv){
int thnum = DEFTHNUM;
int tout = 0;
bool dmn = false;
+ bool kl = false;
uint64_t ulim = 0;
bool uas = false;
uint32_t sid = 0;
@@ -208,6 +209,8 @@ int main(int argc, char **argv){
} else if(!strcmp(argv[i], "-pid")){
if(++i >= argc) usage();
pidpath = argv[i];
+ } else if(!strcmp(argv[i], "-kl")){
+ kl = true;
} else if(!strcmp(argv[i], "-log")){
if(++i >= argc) usage();
logpath = argv[i];
@@ -279,7 +282,7 @@ int main(int argc, char **argv){
}
if(!rtspath) rtspath = DEFRTSPATH;
g_serv = ttservnew();
- int rv = proc(dbname, host, port, thnum, tout, dmn, pidpath, logpath,
+ int rv = proc(dbname, host, port, thnum, tout, dmn, pidpath, kl, logpath,
ulogpath, ulim, uas, sid, mhost, mport, rtspath, extpath, extpcs, mask);
ttservdel(g_serv);
if(extpcs) tclistdel(extpcs);
@@ -293,8 +296,8 @@ static void usage(void){
fprintf(stderr, "\n");
fprintf(stderr, "usage:\n");
fprintf(stderr, " %s [-host name] [-port num] [-thnum num] [-tout num]"
- " [-dmn] [-pid path] [-log path] [-ld|-le] [-ulog path] [-ulim num] [-uas] [-sid num]"
- " [-mhost name] [-mport num] [-rts path] [-ext path] [-extpc name period]"
+ " [-dmn] [-pid path] [-kl] [-log path] [-ld|-le] [-ulog path] [-ulim num] [-uas]"
+ " [-sid num] [-mhost name] [-mport num] [-rts path] [-ext path] [-extpc name period]"
" [-mask expr] [-unmask expr] [dbname]\n", g_progname);
fprintf(stderr, "\n");
exit(1);
@@ -397,7 +400,7 @@ static void sigchldhandler(int signum){
/* perform the command */
static int proc(const char *dbname, const char *host, int port, int thnum, int tout,
- bool dmn, const char *pidpath, const char *logpath,
+ bool dmn, const char *pidpath, bool kl, const char *logpath,
const char *ulogpath, uint64_t ulim, bool uas, uint32_t sid,
const char *mhost, int mport, const char *rtspath, const char *extpath,
const TCLIST *extpcs, uint64_t mask){
@@ -433,10 +436,34 @@ static int proc(const char *dbname, const char *host, int port, int thnum, int t
ttservlog(g_serv, TTLOGINFO, "warning: ulog(%s) is not a directory", ulogpath);
if(pidpath){
char *numstr = tcreadfile(pidpath, -1, NULL);
+ if(numstr && kl){
+ int64_t pid = tcatoi(numstr);
+ tcfree(numstr);
+ ttservlog(g_serv, TTLOGINFO,
+ "warning: killing the process %lld with SIGTERM", (long long)pid);
+ if(kill(pid, SIGTERM) != 0) ttservlog(g_serv, TTLOGERROR, "kill failed");
+ int cnt = 0;
+ while(true){
+ usleep(1000 * 100);
+ if((numstr = tcreadfile(pidpath, -1, NULL)) != NULL){
+ tcfree(numstr);
+ } else {
+ break;
+ }
+ if(++cnt >= 100){
+ ttservlog(g_serv, TTLOGINFO,
+ "warning: killing the process %lld with SIGKILL", (long long)pid);
+ if(kill(pid, SIGKILL) != 0) ttservlog(g_serv, TTLOGERROR, "kill failed");
+ unlink(pidpath);
+ break;
+ }
+ }
+ numstr = tcreadfile(pidpath, -1, NULL);
+ }
if(numstr){
int64_t pid = tcatoi(numstr);
tcfree(numstr);
- ttservlog(g_serv, TTLOGERROR, "process %lld may be already running", (long long)pid);
+ ttservlog(g_serv, TTLOGERROR, "the process %lld may be already running", (long long)pid);
return 1;
}
}
@@ -2221,7 +2248,7 @@ static void do_mc_delete(TTSOCK *sock, TASKARG *arg, TTREQ *req, char **tokens,
} else if(tculogadbout(ulog, sid, adb, kbuf, ksiz)){
len = sprintf(stack, "DELETED\r\n");
} else {
- len = sprintf(stack, "NOT_STORED\r\n");
+ len = sprintf(stack, "NOT_FOUND\r\n");
}
if(nr || ttsocksend(sock, stack, len)){
req->keep = true;
@@ -2263,15 +2290,17 @@ static void do_mc_incr(TTSOCK *sock, TASKARG *arg, TTREQ *req, char **tokens, in
char *vbuf = tcadbget(adb, kbuf, ksiz, &vsiz);
if(vbuf){
num += strtoll(vbuf, NULL, 10);
+ if(num < 0) num = 0;
+ len = sprintf(stack, "%lld", (long long)num);
+ if(tculogadbput(ulog, sid, adb, kbuf, ksiz, stack, len)){
+ len = sprintf(stack, "%lld\r\n", (long long)num);
+ } else {
+ len = sprintf(stack, "SERVER_ERROR unexpected\r\n");
+ ttservlog(g_serv, TTLOGERROR, "do_mc_incr: operation failed");
+ }
tcfree(vbuf);
- }
- if(num < 0) num = 0;
- len = sprintf(stack, "%lld", (long long)num);
- if(tculogadbput(ulog, sid, adb, kbuf, ksiz, stack, len)){
- len = sprintf(stack, "%lld\r\n", (long long)num);
} else {
- len = sprintf(stack, "SERVER_ERROR unexpected\r\n");
- ttservlog(g_serv, TTLOGERROR, "do_mc_incr: operation failed");
+ len = sprintf(stack, "NOT_FOUND\r\n");
}
if(pthread_mutex_unlock(rmtxs + mtxidx) != 0)
ttservlog(g_serv, TTLOGERROR, "do_mc_incr: pthread_mutex_unlock failed");
@@ -2316,15 +2345,17 @@ static void do_mc_decr(TTSOCK *sock, TASKARG *arg, TTREQ *req, char **tokens, in
char *vbuf = tcadbget(adb, kbuf, ksiz, &vsiz);
if(vbuf){
num += strtoll(vbuf, NULL, 10);
+ if(num < 0) num = 0;
+ len = sprintf(stack, "%lld", (long long)num);
+ if(tculogadbput(ulog, sid, adb, kbuf, ksiz, stack, len)){
+ len = sprintf(stack, "%lld\r\n", (long long)num);
+ } else {
+ len = sprintf(stack, "SERVER_ERROR unexpected\r\n");
+ ttservlog(g_serv, TTLOGERROR, "do_mc_decr: operation failed");
+ }
tcfree(vbuf);
- }
- if(num < 0) num = 0;
- len = sprintf(stack, "%lld", (long long)num);
- if(tculogadbput(ulog, sid, adb, kbuf, ksiz, stack, len)){
- len = sprintf(stack, "%lld\r\n", (long long)num);
} else {
- len = sprintf(stack, "SERVER_ERROR unexpected\r\n");
- ttservlog(g_serv, TTLOGERROR, "do_mc_decr: operation failed");
+ len = sprintf(stack, "NOT_FOUND\r\n");
}
if(pthread_mutex_unlock(rmtxs + mtxidx) != 0)
ttservlog(g_serv, TTLOGERROR, "do_mc_decr: pthread_mutex_unlock failed");
View
40 ttutil.c
@@ -98,6 +98,13 @@ int ttopensock(const char *addr, int port){
close(fd);
return -1;
}
+ struct timeval opttv;
+ opttv.tv_sec = (int)SOCKRCVTIMEO;
+ opttv.tv_usec = (SOCKRCVTIMEO - (int)SOCKRCVTIMEO) * 1000000;
+ setsockopt(fd, SOL_SOCKET, SO_RCVTIMEO, (char *)&opttv, sizeof(opttv));
+ opttv.tv_sec = (int)SOCKSNDTIMEO;
+ opttv.tv_usec = (SOCKSNDTIMEO - (int)SOCKSNDTIMEO) * 1000000;
+ setsockopt(fd, SOL_SOCKET, SO_SNDTIMEO, (char *)&opttv, sizeof(opttv));
return fd;
}
@@ -115,6 +122,13 @@ int ttopensockunix(const char *path){
close(fd);
return -1;
}
+ struct timeval opttv;
+ opttv.tv_sec = (int)SOCKRCVTIMEO;
+ opttv.tv_usec = (SOCKRCVTIMEO - (int)SOCKRCVTIMEO) * 1000000;
+ setsockopt(fd, SOL_SOCKET, SO_RCVTIMEO, (char *)&opttv, sizeof(opttv));
+ opttv.tv_sec = (int)SOCKSNDTIMEO;
+ opttv.tv_usec = (SOCKSNDTIMEO - (int)SOCKSNDTIMEO) * 1000000;
+ setsockopt(fd, SOL_SOCKET, SO_SNDTIMEO, (char *)&opttv, sizeof(opttv));
return fd;
}
@@ -566,25 +580,31 @@ int tthttpfetch(const char *url, TCMAP *reqheads, TCMAP *resheads, TCXSTR *resbo
tcxstrprintf(obuf, "Authorization: Basic %s\r\n", enc);
tcfree(enc);
}
+ double tout = -1;
if(reqheads){
tcmapiterinit(reqheads);
const char *name;
while((name = tcmapiternext2(reqheads)) != NULL){
if(strchr(name, ':') || !tcstricmp(name, "connection")) continue;
- char *cap = tcstrdup(name);
- tcstrtolower(cap);
- char *wp = cap;
- bool head = true;
- while(*wp != '\0'){
- if(head && *wp >= 'a' && *wp <= 'z') *wp -= 'a' - 'A';
- head = *wp == '-' || *wp == ' ';
- wp++;
+ if(!tcstricmp(name, "x-tt-timeout")){
+ tout = tcatof(tcmapget2(reqheads, name));
+ } else {
+ char *cap = tcstrdup(name);
+ tcstrtolower(cap);
+ char *wp = cap;
+ bool head = true;
+ while(*wp != '\0'){
+ if(head && *wp >= 'a' && *wp <= 'z') *wp -= 'a' - 'A';
+ head = *wp == '-' || *wp == ' ';
+ wp++;
+ }
+ tcxstrprintf(obuf, "%s: %s\r\n", cap, tcmapget2(reqheads, name));
+ tcfree(cap);
}
- tcxstrprintf(obuf, "%s: %s\r\n", cap, tcmapget2(reqheads, name));
- tcfree(cap);
}
}
tcxstrprintf(obuf, "\r\n", host);
+ if(tout > 0) ttsocksetlife(sock, tout);
if(ttsocksend(sock, tcxstrptr(obuf), tcxstrsize(obuf))){
char line[SOCKLINEBUFSIZ];
if(ttsockgets(sock, line, SOCKLINEBUFSIZ) && tcstrfwm(line, "HTTP/")){
View
15 ttutil.h
@@ -225,13 +225,13 @@ int ttsockcheckpfsiz(TTSOCK *sock);
/* Fetch the resource of a URL by HTTP.
`url' specifies the URL.
- `reqheads' specifies a map object contains request header names and their values. If it is
- NULL, it is not used.
+ `reqheads' specifies a map object contains request header names and their values. The header
+ "X-TT-Timeout" specifies the timeout in seconds. If it is `NULL', it is not used.
`resheads' specifies a map object to store response headers their values. If it is NULL, it
is not used. Each key of the map is an uncapitalized header name. The key "STATUS" means the
status line.
`resbody' specifies a extensible string object to store the entity body of the result. If it
- is NULL, it is not used.
+ is `NULL', it is not used.
The return value is the response code or -1 on network error. */
int tthttpfetch(const char *url, TCMAP *reqheads, TCMAP *resheads, TCXSTR *resbody);
@@ -419,8 +419,8 @@ bool ttserviskilled(TTSERV *serv);
*************************************************************************************************/
-#define _TT_VERSION "1.1.16"
-#define _TT_LIBVER 207
+#define _TT_VERSION "1.1.17"
+#define _TT_LIBVER 301
#define _TT_PROTVER "0.9"
@@ -434,6 +434,11 @@ bool ttdaemonize(void);
double ttgetloadavg(void);
+/* tricks for backward compatibility */
+#define tcrdbqrysetmax(TC_tdb, TC_max) \
+ tcrdbqrysetlimit((TC_tdb), (TC_max), 0)
+
+
__TTUTIL_CLINKAGEEND
#endif /* duplication check */

0 comments on commit 264d1c6

Please sign in to comment.
Something went wrong with that request. Please try again.