Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

sync with tokyotyrant-1.1.19.tar.gz

  • Loading branch information...
commit 5398c3567dcf42aec1ed9958e49ff87d62d770fc 1 parent 58f432e
@etrepum etrepum authored
View
12 ChangeLog
@@ -1,5 +1,17 @@
2009-03-14 Mikio Hirabayashi <mikio@users.sourceforge.net>
+ * tcrdb.c (tcrdbqrysearchget): the option for no update log was added.
+
+ * tcrdb.c (tcrdbqrysearchcount): new function.
+
+ * tculog.c (tcreplread): timeout mechanism was added.
+
+ * ttserver.c (do_repl): performance was improved.
+
+ - Release: 1.1.19
+
+2009-03-14 Mikio Hirabayashi <mikio@users.sourceforge.net>
+
* ttservctl: configuration was modified and update log is now disabled by default.
* ttutil.c (ttopensock, ttacceptsock): performance was improved.
View
20 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.18.
+# Generated by GNU Autoconf 2.61 for tokyotyrant 1.1.19.
#
# 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.18'
-PACKAGE_STRING='tokyotyrant 1.1.18'
+PACKAGE_VERSION='1.1.19'
+PACKAGE_STRING='tokyotyrant 1.1.19'
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.18 to adapt to many kinds of systems.
+\`configure' configures tokyotyrant 1.1.19 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.18:";;
+ short | recursive ) echo "Configuration of tokyotyrant 1.1.19:";;
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.18
+tokyotyrant configure 1.1.19
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.18, which was
+It was created by tokyotyrant $as_me 1.1.19, which was
generated by GNU Autoconf 2.61. Invocation command line was
$ $0 $@
@@ -1719,7 +1719,7 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu
# Package information
MYLIBVER=3
-MYLIBREV=2
+MYLIBREV=3
MYPROTVER="0.9"
# Targets
@@ -5912,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.18, which was
+This file was extended by tokyotyrant $as_me 1.1.19, which was
generated by GNU Autoconf 2.61. Invocation command line was
CONFIG_FILES = $CONFIG_FILES
@@ -5955,7 +5955,7 @@ Report bugs to <bug-autoconf@gnu.org>."
_ACEOF
cat >>$CONFIG_STATUS <<_ACEOF
ac_cs_version="\\
-tokyotyrant config.status 1.1.18
+tokyotyrant config.status 1.1.19
configured by $0, generated by GNU Autoconf 2.61,
with options \\"`echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`\\"
View
4 configure.in
@@ -7,11 +7,11 @@
#================================================================
# Package name
-AC_INIT(tokyotyrant, 1.1.18)
+AC_INIT(tokyotyrant, 1.1.19)
# Package information
MYLIBVER=3
-MYLIBREV=2
+MYLIBREV=3
MYPROTVER="0.9"
# Targets
View
15 doc/index.html
@@ -91,7 +91,6 @@
padding: 0.2em;
background-color: #ddddee;
border: 1px solid #bbbbcc;
- border-radius: 4px;
font-size: 95%;
}
li,dt,dd {
@@ -1081,6 +1080,14 @@ <h3 id="tcrdbapi_apitbl">API of the Table Extension</h3>
<dd>Because the object of the return value is created with the function `tcmapnew', it should be deleted with the function `tcmapdel' when it is no longer in use.</dd>
</dl>
+<p>The function `tcrdbqrysearchcount' is used in order to get the count of corresponding records of a query object.</p>
+
+<dl class="api">
+<dt><code>int tcrdbqrysearchcount(RDBQRY *<var>qry</var>);</code></dt>
+<dd>`<var>qry</var>' specifies the query object.</dd>
+<dd>The return value is the count of corresponding records or 0 on failure.</dd>
+</dl>
+
<h3 id="tcrdbapi_example">Example Code</h3>
<p>The following code is an example to use a remote database.</p>
@@ -2072,6 +2079,8 @@ <h3 id="tutorial_tuning">Tuning</h3>
<p>If huge number of clients access the server, make sure the limit number of file descriptors per process is cleared. By default on most systems, it is set as 1024. If so, use `<code>ulimit</code>' to clear it.</p>
+<p>In order to deal with rushing queries at the peak time of your service, replication combining the on-memory hash/tree database and the file hash/tree database is useful. The master server handles the on-memory database and it can come through rushing queries at the peak time. Though the on-memory database can not assure the data persistence, the slave of replication compensates the shortage by storing records in the file database.</p>
+
<h3 id="tutorial_luaext">Lua Extension</h3>
<p>If you want more complex database operations than existing ones, use the Lua extension. For example, prepare the following script and save it as "test.lua". There is a function "fibonacci" which returns the Fibonacci number of a number of the key.</p>
@@ -2188,7 +2197,7 @@ <h3 id="tutorial_http">Using HTTP Client</h3>
<h3 id="tutorial_expcache">Persistent but Expirable Cache</h3>
-<p>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.</p>
+<p>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" but expirable cache. It requires the following preconditions.</p>
<ul>
<li>The server must open a table database.</li>
@@ -2206,7 +2215,7 @@ <h3 id="tutorial_expcache">Persistent but Expirable Cache</h3>
table.insert(args, "out")
local res = _misc("search", args)
if not res then
- _log("expiration was failed")
+ _log("expiration was failed", 2)
end
end
</pre>
View
6 ext/senatus.lua
@@ -348,7 +348,7 @@ end
-- get status of a file
-function stat(key, value)
+function statfile(key, value)
local stat = _stat(key)
if not stat then
return nil
@@ -415,7 +415,7 @@ function expire()
table.insert(args, "out")
local res = _misc("search", args)
if not res then
- _log("expiration was failed")
+ _log("expiration was failed", 2)
end
end
@@ -428,7 +428,7 @@ function expire2()
table.insert(args, "out")
local res = _misc("search", args)
if not res then
- _log("expiration was failed")
+ _log("expiration was failed", 2)
end
end
View
13 man/tcrdb.3
@@ -1147,6 +1147,19 @@ The return value is a map object containing columns.
Because the object of the return value is created with the function `tcmapnew', it should be deleted with the function `tcmapdel' when it is no longer in use.
.RE
.RE
+.PP
+The function `tcrdbqrysearchcount' is used in order to get the count of corresponding records of a query object.
+.PP
+.RS
+.br
+\fBint tcrdbqrysearchcount(RDBQRY *\fIqry\fB);\fR
+.RS
+`\fIqry\fR' specifies the query object.
+.RE
+.RS
+The return value is the count of corresponding records or 0 on failure.
+.RE
+.RE
.SH SEE ALSO
.PP
View
16 tcrdb.c
@@ -1431,7 +1431,7 @@ TCLIST *tcrdbqrysearchget(RDBQRY *qry){
assert(qry);
TCLIST *args = tclistdup(qry->args);
tclistpush2(args, "get");
- TCLIST *rv = tcrdbmisc(qry->rdb, "search", 0, args);
+ TCLIST *rv = tcrdbmisc(qry->rdb, "search", RDBMONOULOG, args);
tclistdel(args);
return rv;
}
@@ -1447,5 +1447,19 @@ TCMAP *tcrdbqryrescols(TCLIST *res, int index){
}
+/* Get the count of corresponding records of a query object. */
+int tcrdbqrysearchcount(RDBQRY *qry){
+ assert(qry);
+ TCLIST *args = tclistdup(qry->args);
+ tclistpush2(args, "count");
+ TCLIST *rv = tcrdbmisc(qry->rdb, "search", RDBMONOULOG, args);
+ tclistdel(args);
+ if(!rv) return 0;
+ int count = tclistnum(rv) > 0 ? tcatoi(tclistval2(rv, 0)) : 0;
+ tclistdel(rv);
+ return count;
+}
+
+
// END OF FILE
View
6 tcrdb.h
@@ -671,6 +671,12 @@ TCLIST *tcrdbqrysearchget(RDBQRY *qry);
TCMAP *tcrdbqryrescols(TCLIST *res, int index);
+/* Get the count of corresponding records of a query object.
+ `qry' specifies the query object.
+ The return value is the count of corresponding records or 0 on failure. */
+int tcrdbqrysearchcount(RDBQRY *qry);
+
+
__TCRDB_CLINKAGEEND
#endif /* duplication check */
View
4 tcrtest.c
@@ -1341,6 +1341,10 @@ static int proctable(const char *host, int port, int cnum, int rnum){
}
tcmapdel(cols);
}
+ if(tclistnum(res) != tcrdbqrysearchcount(qry)){
+ eprint(rdb, "(validation)");
+ err = true;
+ }
tclistdel(res);
tcrdbqrydel(qry);
qry = tcrdbqrynew(rdb);
View
5 tculog.c
@@ -19,6 +19,7 @@
#include "myconf.h"
#define TCULAIOCBNUM 64 // number of AIO tasks
+#define TCREPLTIMEO 5.0 // timeout of the replication socket
/* private function prototypes */
@@ -69,8 +70,8 @@ void tculogdel(TCULOG *ulog){
/* Set AIO control of an update log object. */
bool tculogsetaio(TCULOG *ulog){
- assert(ulog);
#if defined(_SYS_LINUX_)
+ assert(ulog);
if(ulog->base || ulog->aiocbs) return false;
struct aiocb *aiocbs = tcmalloc(sizeof(*aiocbs) * TCULAIOCBNUM);
for(int i = 0; i < TCULAIOCBNUM; i++){
@@ -79,6 +80,7 @@ bool tculogsetaio(TCULOG *ulog){
ulog->aiocbs = aiocbs;
return true;
#else
+ assert(ulog);
return true;
#endif
}
@@ -965,6 +967,7 @@ const char *tcreplread(TCREPL *repl, int *sp, uint64_t *tsp, uint32_t *sidp){
assert(repl && sp && tsp);
int ocs = PTHREAD_CANCEL_DISABLE;
pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, &ocs);
+ ttsocksetlife(repl->sock, TCREPLTIMEO);
int c = ttsockgetc(repl->sock);
if(c == TCULMAGICNOP){
*sp = 0;
View
13 ttserver.c
@@ -2015,6 +2015,7 @@ static void do_repl(TTSOCK *sock, TASKARG *arg, TTREQ *req){
if(ulrd){
pthread_cleanup_push((void (*)(void *))tculrddel, ulrd);
bool err = false;
+ bool idle = true;
const char *rbuf;
int rsiz;
uint64_t rts;
@@ -2023,13 +2024,17 @@ static void do_repl(TTSOCK *sock, TASKARG *arg, TTREQ *req){
while(!err && !ttserviskilled(g_serv)){
ttsocksetlife(sock, UINT_MAX);
req->mtime = tctime() + UINT_MAX;
- *(unsigned char *)stack = TCULMAGICNOP;
- if(!ttsocksend(sock, stack, sizeof(uint8_t))){
- err = true;
- ttservlog(g_serv, TTLOGINFO, "do_repl: connection closed");
+ if(idle){
+ *(unsigned char *)stack = TCULMAGICNOP;
+ if(!ttsocksend(sock, stack, sizeof(uint8_t))){
+ err = true;
+ ttservlog(g_serv, TTLOGINFO, "do_repl: connection closed");
+ }
}
tculrdwait(ulrd);
+ idle = true;
while(!err && (rbuf = tculrdread(ulrd, &rsiz, &rts, &rsid)) != NULL){
+ idle = false;
if(rsid == sid) continue;
int msiz = sizeof(uint8_t) + sizeof(uint64_t) + sizeof(uint32_t) * 2 + rsiz;
char *mbuf = (msiz < TTIOBUFSIZ) ? stack : tcmalloc(msiz);
View
55 ttutil.c
@@ -27,6 +27,7 @@
#define SOCKPATHBUFSIZ 108 // size of a socket path buffer
#define SOCKRCVTIMEO 0.25 // timeout of the recv call of socket
#define SOCKSNDTIMEO 0.25 // timeout of the send call of socket
+#define SOCKCNCTTIMEO 5.0 // timeout of the connect call of socket
#define SOCKLINEBUFSIZ 4096 // size of a line buffer of socket
#define SOCKLINEMAXSIZ (16*1024*1024) // maximum size of a line of socket
#define HTTPBODYMAXSIZ (256*1024*1024) // maximum size of the entity body of HTTP
@@ -94,10 +95,8 @@ int ttopensock(const char *addr, int port){
sain.sin_port = htons(snum);
int fd = socket(PF_INET, SOCK_STREAM, 0);
if(fd == -1) return -1;
- if(connect(fd, (struct sockaddr *)&sain, sizeof(sain)) != 0){
- close(fd);
- return -1;
- }
+ int optint = 1;
+ setsockopt(fd, SOL_SOCKET, SO_KEEPALIVE, (char *)&optint, sizeof(optint));
struct timeval opttv;
opttv.tv_sec = (int)SOCKRCVTIMEO;
opttv.tv_usec = (SOCKRCVTIMEO - (int)SOCKRCVTIMEO) * 1000000;
@@ -105,9 +104,20 @@ int ttopensock(const char *addr, int port){
opttv.tv_sec = (int)SOCKSNDTIMEO;
opttv.tv_usec = (SOCKSNDTIMEO - (int)SOCKSNDTIMEO) * 1000000;
setsockopt(fd, SOL_SOCKET, SO_SNDTIMEO, (char *)&opttv, sizeof(opttv));
- int optint = 1;
+ optint = 1;
setsockopt(fd, IPPROTO_TCP, TCP_NODELAY, (char *)&optint, sizeof(optint));
- return fd;
+ double dl = tctime() + SOCKCNCTTIMEO;
+ do {
+ int ocs = PTHREAD_CANCEL_DISABLE;
+ pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, &ocs);
+ int rv = connect(fd, (struct sockaddr *)&sain, sizeof(sain));
+ pthread_setcancelstate(ocs, NULL);
+ if(rv == 0) return fd;
+ if(errno != EINTR && errno != EAGAIN && errno != EINPROGRESS && errno != EALREADY &&
+ errno != ETIMEDOUT) break;
+ } while(tctime() <= dl);
+ close(fd);
+ return -1;
}
@@ -120,10 +130,8 @@ int ttopensockunix(const char *path){
snprintf(saun.sun_path, SOCKPATHBUFSIZ, "%s", path);
int fd = socket(PF_UNIX, SOCK_STREAM, 0);
if(fd == -1) return -1;
- if(connect(fd, (struct sockaddr *)&saun, sizeof(saun)) != 0){
- close(fd);
- return -1;
- }
+ int optint = 1;
+ setsockopt(fd, SOL_SOCKET, SO_KEEPALIVE, (char *)&optint, sizeof(optint));
struct timeval opttv;
opttv.tv_sec = (int)SOCKRCVTIMEO;
opttv.tv_usec = (SOCKRCVTIMEO - (int)SOCKRCVTIMEO) * 1000000;
@@ -131,7 +139,18 @@ int ttopensockunix(const char *path){
opttv.tv_sec = (int)SOCKSNDTIMEO;
opttv.tv_usec = (SOCKSNDTIMEO - (int)SOCKSNDTIMEO) * 1000000;
setsockopt(fd, SOL_SOCKET, SO_SNDTIMEO, (char *)&opttv, sizeof(opttv));
- return fd;
+ double dl = tctime() + SOCKCNCTTIMEO;
+ do {
+ int ocs = PTHREAD_CANCEL_DISABLE;
+ pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, &ocs);
+ int rv = connect(fd, (struct sockaddr *)&saun, sizeof(saun));
+ pthread_setcancelstate(ocs, NULL);
+ if(rv == 0) return fd;
+ if(errno != EINTR && errno != EAGAIN && errno != EINPROGRESS && errno != EALREADY &&
+ errno != ETIMEDOUT) break;
+ } while(tctime() <= dl);
+ close(fd);
+ return -1;
}
@@ -146,8 +165,8 @@ int ttopenservsock(const char *addr, int port){
sain.sin_port = htons(snum);
int fd = socket(PF_INET, SOCK_STREAM, 0);
if(fd == -1) return -1;
- int optone = 1;
- if(setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, (char *)&optone, sizeof(optone)) != 0){
+ int optint = 1;
+ if(setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, (char *)&optint, sizeof(optint)) != 0){
close(fd);
return -1;
}
@@ -189,8 +208,8 @@ int ttacceptsock(int fd, char *addr, int *pp){
socklen_t slen = sizeof(sain);
int cfd = accept(fd, (struct sockaddr *)&sain, &slen);
if(cfd >= 0){
- int optone = 1;
- setsockopt(fd, SOL_SOCKET, SO_KEEPALIVE, (char *)&optone, sizeof(optone));
+ int optint = 1;
+ setsockopt(fd, SOL_SOCKET, SO_KEEPALIVE, (char *)&optint, sizeof(optint));
struct timeval opttv;
opttv.tv_sec = (int)SOCKRCVTIMEO;
opttv.tv_usec = (SOCKRCVTIMEO - (int)SOCKRCVTIMEO) * 1000000;
@@ -198,7 +217,7 @@ int ttacceptsock(int fd, char *addr, int *pp){
opttv.tv_sec = (int)SOCKSNDTIMEO;
opttv.tv_usec = (SOCKSNDTIMEO - (int)SOCKSNDTIMEO) * 1000000;
setsockopt(cfd, SOL_SOCKET, SO_SNDTIMEO, (char *)&opttv, sizeof(opttv));
- int optint = 1;
+ optint = 1;
setsockopt(cfd, IPPROTO_TCP, TCP_NODELAY, (char *)&optint, sizeof(optint));
if(addr){
if(getnameinfo((struct sockaddr *)&sain, sizeof(sain), addr, TTADDRBUFSIZ,
@@ -218,8 +237,8 @@ int ttacceptsockunix(int fd){
do {
int cfd = accept(fd, NULL, NULL);
if(cfd >= 0){
- int optone = 1;
- setsockopt(fd, SOL_SOCKET, SO_KEEPALIVE, (char *)&optone, sizeof(optone));
+ int optint = 1;
+ setsockopt(fd, SOL_SOCKET, SO_KEEPALIVE, (char *)&optint, sizeof(optint));
struct timeval opttv;
opttv.tv_sec = (int)SOCKRCVTIMEO;
opttv.tv_usec = (SOCKRCVTIMEO - (int)SOCKRCVTIMEO) * 1000000;
View
4 ttutil.h
@@ -419,8 +419,8 @@ bool ttserviskilled(TTSERV *serv);
*************************************************************************************************/
-#define _TT_VERSION "1.1.18"
-#define _TT_LIBVER 302
+#define _TT_VERSION "1.1.19"
+#define _TT_LIBVER 303
#define _TT_PROTVER "0.9"
Please sign in to comment.
Something went wrong with that request. Please try again.