tabled: use httpstor API from libhail
PATCH 1/1 tabled: use httpstor API from libhail
Just committed the following to tabled.git on my local laptop, on a side branch. This won't be pushed onto the main tabled branch until Friday, to give people time to convert as zaitcev suggested in the 'new hail repository' thread.
As a side note, this requires a couple hail.git commits that will be pushed to upstream hail.git from my local laptop in a couple hours (movement of uri_parse from tabled's libhttpstor into libhail), so you'll need to update hail.git before being able to use the patch below.
commit d4cfbcac3f00088cf38df2834a880f7e75ca6f0b
Author: Jeff Garzik <[email protected]> Date: Wed Jul 7 18:29:26 2010 -0400
Link with libhail, eliminating much local code.
.gitignore | 9 autogen.sh | 6 configure.ac | 32 - include/Makefile.am | 2 include/httpstor.h | 100 ---- include/httputil.h | 84 --- lib/.gitignore | 10 lib/Makefile.am | 23 lib/httpstor.c | 944 -------------------------------------- lib/httputil.c | 366 -------------- lib/libhttpstor-uninstalled.pc.in | 12 lib/libhttpstor.pc.in | 13 lib/uri.c | 289 ----------- server/.gitignore | 4 server/Makefile.am | 2 server/bucket.c | 18 server/object.c | 34 - server/server.c | 30 - server/status.c | 6 server/tabled.h | 2 test/Makefile.am | 9 test/basic-bucket.c | 29 - test/basic-object.c | 19 test/hdr-content-type.c | 23 test/hdr-meta.c | 23 test/it-works.c | 17 test/large-object.c | 27 - test/libtest.c | 36 + test/test.h | 3 test/wait-for-listen.c | 1 30 files changed, 165 insertions(+), 2008 deletions(-)
.gitignore +0 -9
@@ -19,15 +19,6 @@ install-sh missing push stamp-h1 -libtool -ltmain.sh - -# app-specific -tabled -tdbadm - -libtabled.a -libtdb.a tabled*.tar.gz tabled-config.h*
autogen.sh +1 -5
@@ -5,12 +5,8 @@ set -e -# libtoolize needs to be run twice, for some reason -# to avoid errors relating to ltmain.sh installation - -libtoolize --force aclocal autoheader automake --gnu --add-missing --copy autoconf -libtoolize --force +
configure.ac +1 -31
@@ -17,21 +17,6 @@ dnl You should have received a copy of the GNU General Public License dnl along with this program; if not, write to the Free Software dnl Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -m4_define([libhttpstor_major_version], [1]) -m4_define([libhttpstor_minor_version], [1]) -m4_define([libhttpstor_micro_version], [1]) -m4_define([libhttpstor_interface_age], [1]) -# If you need a modifier for the version number. -# Normally empty, but can be used to make "fixup" releases. -m4_define([libhttpstor_extraversion], []) - -dnl libtool versioning from libhttpstor -m4_define([libhttpstor_current], [m4_eval(100 * libhttpstor_minor_version + libhttpstor_micro_version - libhttpstor_interface_age)]) -m4_define([libhttpstor_binary_age], [m4_eval(100 * libhttpstor_minor_version + libhttpstor_micro_version)]) -m4_define([libhttpstor_revision], [libhttpstor_interface_age]) -m4_define([libhttpstor_age], [m4_eval(libhttpstor_binary_age - libhttpstor_interface_age)]) -m4_define([libhttpstor_version], [libhttpstor_major_version().libhttpstor_minor_version().libhttpstor_micro_version()libhttpstor_extraversion()]) - AC_INIT([tabled], [0.5], [http://hail.wiki.kernel.org/])
@@ -40,26 +25,13 @@ AC_CONFIG_SRCDIR([server/server.c]) AM_INIT_AUTOMAKE([gnu]) AC_CONFIG_HEADERS([tabled-config.h]) -LIBHTTPSTOR_MAJOR_VERSION=libhttpstor_major_version -LIBHTTPSTOR_MINOR_VERSION=libhttpstor_minor_version -LIBHTTPSTOR_MICRO_VERSION=libhttpstor_micro_version -LIBHTTPSTOR_INTERFACE_AGE=libhttpstor_interface_age - -LIBHTTPSTOR_CURRENT=libhttpstor_current -LIBHTTPSTOR_REVISION=libhttpstor_revision -LIBHTTPSTOR_AGE=libhttpstor_age - -AC_SUBST(LIBHTTPSTOR_CURRENT) -AC_SUBST(LIBHTTPSTOR_REVISION) -AC_SUBST(LIBHTTPSTOR_AGE) - dnl Make sure anyone changing configure.ac/Makefile.am has a clue AM_MAINTAINER_MODE dnl Checks for programs AC_PROG_CC AC_PROG_GCC_TRADITIONAL -AM_PROG_LIBTOOL +AC_PROG_RANLIB PKG_PROG_PKG_CONFIG dnl Checks for header files.
@@ -119,8 +91,6 @@ dnl AC_SUBST(CHUNKDC_LIBS) AC_CONFIG_FILES([doc/Makefile lib/Makefile - lib/libhttpstor.pc - lib/libhttpstor-uninstalled.pc include/Makefile server/Makefile test/Makefile
include/Makefile.am +0 -2
@@ -1,5 +1,3 @@ -include_HEADERS = httpstor.h - EXTRA_DIST = elist.h httputil.h tdb.h
include/httpstor.h deleted +0 -100
100 lines not on this page · raw message
include/httputil.h +0 -84
91 lines not on this page · raw message
lib/.gitignore +3 -7
@@ -1,7 +1,3 @@ -*.lo -*.la -.libs -libhttputil.a -libhttpstor.a -libhttpstor-uninstalled.pc -libhttpstor.pc + +libtdb.a +
lib/Makefile.am +2 -21
@@ -1,27 +1,8 @@ INCLUDES = -I$(top_srcdir)/include \ - @LIBCURL_CPPFLAGS@ @GLIB_CFLAGS@ @XML_CPPFLAGS@ + @GLIB_CFLAGS@ -noinst_LIBRARIES = libhttputil.a libtdb.a - -libhttputil_a_SOURCES = httputil.c uri.c readport.c +noinst_LIBRARIES = libtdb.a libtdb_a_SOURCES = tdb.c -EXTRA_DIST = - libhttpstor.pc.in libhttpstor-uninstalled.pc.in - -LINK = $(LIBTOOL) --mode=link $(CC) $(CFLAGS) $(LDFLAGS) -o $@ - -lib_LTLIBRARIES = libhttpstor.la - -libhttpstor_la_SOURCES = httpstor.c - -libhttpstor_la_LDFLAGS = \ - -version-info $(LIBHTTPSTOR_CURRENT):$(LIBHTTPSTOR_REVISION):$(LIBHTTPSTOR_AGE) \ - -no-undefined \ - -export-symbols-regex "^[^_].*" - -pkgconfigdir = $(libdir)/pkgconfig -pkgconfig_DATA = libhttpstor.pc -
lib/httpstor.c deleted +0 -944
944 lines not on this page · raw message
lib/httputil.c deleted +0 -366
366 lines not on this page · raw message
lib/libhttpstor-uninstalled.pc.in deleted +0 -12
@@ -1,12 +0,0 @@ -prefix=@prefix@ -exec_prefix=@exec_prefix@ -libdir=@libdir@ -includedir=@includedir@ -libhttpstor_serverdir=@libexecdir@ - -Name: libhttpstor -Description: libhttpstor -Requires: glib-2.0 -Version: @VERSION@ -Libs: ${pc_top_builddir}/${pcfiledir}/libhttpstor.la -#Cflags: -I${pc_top_builddir}/${pcfiledir}/..
lib/libhttpstor.pc.in deleted +0 -13
@@ -1,13 +0,0 @@ -prefix=@prefix@ -exec_prefix=@exec_prefix@ -libdir=@libdir@ -includedir=@includedir@ -libhttpstor_serverdir=@libexecdir@ -localstatedir=@localstatedir@ - -Name: libhttpstor -Description: libhttpstor -Requires: glib-2.0 -Version: @VERSION@ -Libs: -L${libdir} -lhttpstor -#Cflags: -I${includedir}/libhttpstor-2.0
lib/uri.c deleted +0 -289
289 lines not on this page · raw message
server/.gitignore new file +4 -0
@@ -0,0 +1,4 @@ + +tabled +tdbadm +
server/Makefile.am +1 -1
@@ -6,7 +6,7 @@ sbin_PROGRAMS = tabled tdbadm tabled_SOURCES = tabled.h \ bucket.c cldu.c config.c object.c replica.c \ server.c status.c storage.c storparse.c util.c -tabled_LDADD = ../lib/libhttputil.a ../lib/libtdb.a \ +tabled_LDADD = ../lib/libtdb.a \ @HAIL_LIBS@ @PCRE_LIBS@ @GLIB_LIBS@ \ @CRYPTO_LIBS@ @DB4_LIBS@ @EVENT_LIBS@ @SSL_LIBS@
server/bucket.c +9 -9
@@ -265,7 +265,7 @@ bool service_list(struct client *cli, const char *user)" </Bucket>\r\n" , ent->name, -time2str (timestr,sizeof (timestr), +hutil_time2str (timestr,sizeof (timestr), GUINT64_FROM_LE(ent->time_create)));if (!s) goto err_out_content;
@@ -467,7 +467,7 @@ bool bucket_add(struct client *cli, const char *user, const char *bucket)/* prepare parameters */ setacl = false;if (cli->req.uri.query_len) { -switch (req_is_query (&cli->req)) { +switch (hreq_is_query (&cli->req)) {case URIQ_ACL : setacl = true;break ;
@@ -477,7 +477,7 @@ bool bucket_add(struct client *cli, const char *user, const char *bucket) } } -if ((rc =req_acl_canned (&cli->req)) ==ACLCNUM ) { +if ((rc =hreq_acl_canned (&cli->req)) ==ACLCNUM ) { err = InvalidArgument; goto err_par; }
@@ -562,7 +562,7 @@ bool bucket_add(struct client *cli, const char *user, const char *bucket) "\r\n", cli->req.major, cli->req.minor, - time2str(timestr, sizeof(timestr), time(NULL)), + hutil_time2str(timestr, sizeof(timestr), time(NULL)), bucket) < 0)return cli_err (cli, InternalError);
@@ -715,7 +715,7 @@ bool bucket_del(struct client *cli, const char *user, const char *bucket) "\r\n", cli->req.major, cli->req.minor, - time2str(timestr, sizeof(timestr), time(NULL))) < 0) + hutil_time2str(timestr, sizeof(timestr), time(NULL))) < 0)return cli_err (cli, InternalError); rc =cli_writeq (cli, hdr,strlen (hdr), cli_cb_free, hdr);
@@ -939,7 +939,7 @@ static bool bucket_list_keys(struct client *cli, const char *user, }/* parse URI query string */ - param =req_query (&cli->req); + param =hreq_query (&cli->req);if (!param) goto err_out;
@@ -1110,7 +1110,7 @@ static bool bucket_list_keys(struct client *cli, const char *user," </Contents>\r\n" , vp->key, -time2str (timestr,sizeof (timestr), vp->mtime /1000000 ), +hutil_time2str (timestr,sizeof (timestr), vp->mtime /1000000 ), vp->md5, (unsigned long long ) vp->size, vp->owner,
@@ -1185,7 +1185,7 @@ bool access_list(struct client *cli, const char *bucket, const char *key, }/* parse URI query string */ - param =req_query (&cli->req); + param =hreq_query (&cli->req);if (!param) goto err_out;
@@ -1360,7 +1360,7 @@ bool bucket_list(struct client *cli, const char *user, const char *bucket) getacl = false;if (cli->req.uri.query_len) { -switch (req_is_query (&cli->req)) { +switch (hreq_is_query (&cli->req)) {case URIQ_ACL : getacl = true;break ;
server/object.c +17 -17
@@ -224,7 +224,7 @@ bool object_del(struct client *cli, const char *user, "\r\n", cli->req.major, cli->req.minor, - time2str(timestr, sizeof(timestr), time(NULL))) < 0) + hutil_time2str(timestr, sizeof(timestr), time(NULL))) < 0)return cli_err (cli, InternalError); rc =cli_writeq (cli, hdr,strlen (hdr), cli_cb_free, hdr);
@@ -337,7 +337,7 @@ static bool object_put_end(struct client *cli)uint64_t tmp_time;void *mem; -if (http11 (&cli->req)) +if (hreq_http11 (&cli->req)) cli->state = evt_recycle;else cli->state = evt_dispose;
@@ -376,7 +376,7 @@ static bool object_put_end(struct client *cli)md5str (md, md5); - type =req_hdr (&cli->req,"content-type" ); + type =hreq_hdr (&cli->req,"content-type" );if (!type) type ="binary/octet-stream" ;else
@@ -515,7 +515,7 @@ static bool object_put_end(struct client *cli) cli->req.major, cli->req.minor, md5, - time2str(timestr, sizeof(timestr), time(NULL))) < 0) { + hutil_time2str(timestr, sizeof(timestr), time(NULL))) < 0) {/* FIXME: cleanup failure */ applog (LOG_ERR ,"OOM in object_put_end" );return cli_err (cli, InternalError);
@@ -878,13 +878,13 @@ static bool object_put_acls(struct client *cli, const char *user,if (!user || !has_access (user, bucket, key,"WRITE_ACP" ))return cli_err (cli, AccessDenied); -if ((rc =req_acl_canned (&cli->req)) ==ACLCNUM ) { +if ((rc =hreq_acl_canned (&cli->req)) ==ACLCNUM ) { err = InvalidArgument; goto err_out_parm; } canacl = (rc ==-1 )?ACLC_PRIV : rc; -if (http11 (&cli->req)) +if (hreq_http11 (&cli->req)) cli->state = evt_recycle;else cli->state = evt_dispose;
@@ -929,7 +929,7 @@ static bool object_put_acls(struct client *cli, const char *user, "\r\n", cli->req.major, cli->req.minor, - time2str(timestr, sizeof(timestr), time(NULL))) < 0) { + hutil_time2str(timestr, sizeof(timestr), time(NULL))) < 0) {/* FIXME: cleanup failure */ applog (LOG_ERR ,"OOM in object_put_end" );return cli_err (cli, InternalError);
@@ -959,7 +959,7 @@ bool object_put(struct client *cli, const char *user, const char *bucket, setacl = false;if (cli->req.uri.query_len) { -switch (req_is_query (&cli->req)) { +switch (hreq_is_query (&cli->req)) {case URIQ_ACL : setacl = true;break ;
@@ -1162,7 +1162,7 @@ static bool object_get_body(struct client *cli, const char *user, md5 = obj->md5; - hdr =req_hdr (&cli->req,"if-match" ); + hdr =hreq_hdr (&cli->req,"if-match" );if (hdr &&strcmp (md5, hdr)) { err = PreconditionFailed; goto err_out_reset;
@@ -1250,11 +1250,11 @@ static bool object_get_body(struct client *cli, const char *user,stor_node_put (stnode); - hdr =req_hdr (&cli->req,"if-unmodified-since" ); + hdr =hreq_hdr (&cli->req,"if-unmodified-since" );if (hdr) {time_t t; - t =str2time (hdr); + t =hutil_str2time (hdr);if (!t) { err = InvalidArgument; goto err_out_in_end;
@@ -1266,11 +1266,11 @@ static bool object_get_body(struct client *cli, const char *user, } } - hdr =req_hdr (&cli->req,"if-modified-since" ); + hdr =hreq_hdr (&cli->req,"if-modified-since" );if (hdr) {time_t t; - t =str2time (hdr); + t =hutil_str2time (hdr);if (!t) { err = InvalidArgument; goto err_out_in_end;
@@ -1282,7 +1282,7 @@ static bool object_get_body(struct client *cli, const char *user, } } - hdr =req_hdr (&cli->req,"if-none-match" ); + hdr =hreq_hdr (&cli->req,"if-none-match" );if (hdr && (!strcmp (md5, hdr))) { modified = false; want_body = false;
@@ -1302,8 +1302,8 @@ static bool object_get_body(struct client *cli, const char *user, modified ?200 :304 , (unsigned long long )GUINT64_FROM_LE (obj->size), md5, -time2str (timestr,sizeof (timestr),time (NULL )), -time2str (modstr,sizeof (modstr), +hutil_time2str (timestr,sizeof (timestr),time (NULL )), +hutil_time2str (modstr,sizeof (modstr),GUINT64_FROM_LE (obj->mtime) /1000000 ), extra_hdr->str) < 0) goto err_out_in_end;
@@ -1396,7 +1396,7 @@ bool object_get(struct client *cli, const char *user, const char *bucket, getacl = false;if (cli->req.uri.query_len) { -switch (req_is_query (&cli->req)) { +switch (hreq_is_query (&cli->req)) {case URIQ_ACL : getacl = true;break ;
server/server.c +15 -15
@@ -356,7 +356,7 @@ static int authcheck(struct http_req *req, char *extra_bucket, pass = val.data; } -req_sign (req, extra_bucket, pass, b64sig); +hreq_sign (req, extra_bucket, pass, b64sig);free (pass);if (strncmp (b64sig, auth + captured[4 ], usiglen) !=0 ) {
@@ -493,7 +493,7 @@ static void cli_free(struct client *cli)close (cli->fd); } -req_free (&cli->req); +hreq_free (&cli->req);if (cli->write_cnt_max > tabled_srv.stats.max_write_buf) tabled_srv.stats.max_write_buf = cli->write_cnt_max;
@@ -519,7 +519,7 @@ static bool cli_evt_recycle(struct client *cli, unsigned int events) {unsigned int slop; -req_free (&cli->req); +hreq_free (&cli->req); cli->hdr_start =NULL ; cli->hdr_end =NULL ;
@@ -769,7 +769,7 @@ bool cli_err(struct client *cli, enum errcode code) cli->req.minor, err_info[code].status,strlen (content), -time2str (timestr,sizeof (timestr),time (NULL )), +hutil_time2str (timestr,sizeof (timestr),time (NULL )), "*");if (rc <0 ) {free (content);
@@ -788,7 +788,7 @@ bool cli_err(struct client *cli, enum errcode code) cli->req.minor, err_info[code].status,strlen (content), - time2str(timestr, sizeof(timestr), time(NULL))); + hutil_time2str(timestr, sizeof(timestr), time(NULL)));if (rc <0 ) {free (content);return false;
@@ -819,7 +819,7 @@ static bool cli_resp(struct client *cli, int http_status, {int rc;char *hdr, timestr[50 ]; -bool rcb, cxn_close = !http11 (&cli->req); +bool rcb, cxn_close = !hreq_http11 (&cli->req); if (asprintf(&hdr, "HTTP/%d.%d %d x\r\n"
@@ -834,7 +834,7 @@ static bool cli_resp(struct client *cli, int http_status, http_status, content_type,strlist_len (content ), - time2str(timestr, sizeof(timestr), time(NULL)), + hutil_time2str(timestr, sizeof(timestr), time(NULL)), cxn_close ? "Connection: close\r\n" : "") < 0) {__strlist_free (content );return false;
@@ -901,11 +901,11 @@ static bool cli_evt_http_req(struct client *cli, unsigned int events) }/* grab useful headers */ - host =req_hdr (req,"host" ); - content_len_str =req_hdr (req,"content-length" ); - auth =req_hdr (req,"authorization" ); + host =hreq_hdr (req,"host" ); + content_len_str =hreq_hdr (req,"content-length" ); + auth =hreq_hdr (req,"authorization" );if (req->major >1 || req->minor >0 ) { -char *expect =req_hdr (req,"expect" ); +char *expect =hreq_hdr (req,"expect" );if (expect &&strcasestr (expect,"100-continue" )) expect_cont = true; }
@@ -947,7 +947,7 @@ static bool cli_evt_http_req(struct client *cli, unsigned int events)* the operations below may override this next-state setting, * however. */ -if (http11 (req)) +if (hreq_http11 (req)) cli->state = evt_recycle;else cli->state = evt_dispose;
@@ -1113,7 +1113,7 @@ static bool cli_hdr_flush(struct client *cli, bool *loop_state) *tmp =0 ;/* add to list of headers */ -if (req_hdr_push (&cli->req, cli->hdr_start, tmp +1 )) { +if (hreq_hdr_push (&cli->req, cli->hdr_start, tmp +1 )) { err_resp = InvalidArgument; goto err_out; }
@@ -1246,14 +1246,14 @@ static bool cli_evt_parse_req(struct client *cli, unsigned int events)strup (cli->req.method);/* URI is the second token, immediately following the first space */ -if (!uri_parse (&cli->req.uri, sp1 +1 )) { +if (!huri_parse (&cli->req.uri, sp1 +1 )) { err_resp = InvalidURI; goto err_out; } cli->req.orig_path =g_strndup (cli->req.uri.path, cli->req.uri.path_len); - cli->req.uri.path_len =field_unescape (cli->req.uri.path, + cli->req.uri.path_len =huri_field_unescape (cli->req.uri.path, cli->req.uri.path_len);/* HTTP version is the final token, following second space */
server/status.c +3 -3
@@ -102,7 +102,7 @@ static bool stat_err(struct client *cli, enum errcode code)"\r\n" , cli->req.major, cli->req.minor, err_status,strlen (content), - time2str(timestr, sizeof(timestr), time(NULL))); + hutil_time2str(timestr, sizeof(timestr), time(NULL)));if (rc <0 ) goto out_hdr;
@@ -160,7 +160,7 @@ bool stat_evt_http_req(struct client *cli, unsigned int events)bool rcb;/* grab useful headers */ -// content_len_str = req_hdr(req, "content-length"); +// content_len_str = hreq_hdr(req, "content-length"); path =strdup (req->uri.path);if (!path)
@@ -178,7 +178,7 @@ bool stat_evt_http_req(struct client *cli, unsigned int events)* the operations below may override this next-state setting, * however. */ -if (http11 (req)) +if (hreq_http11 (req)) cli->state = evt_recycle;else cli->state = evt_dispose;
server/tabled.h +1 -1
@@ -27,7 +27,7 @@#include <glib.h> #include <pcre.h> #include <event.h> -#include <httputil.h> +#include <hstor.h> #include <elist.h> #include <tdb.h> #include <hail_log.h>
test/Makefile.am +4 -5
@@ -34,10 +34,9 @@ check_PROGRAMS = basic-bucket basic-object it-works large-object \ noinst_LIBRARIES = libtest.a -TESTLDADD = ../lib/libhttpstor.la \ - ../lib/libhttputil.a \ - libtest.a \ - @LIBCURL@ @GLIB_LIBS@ @CRYPTO_LIBS@ @XML_LIBS@ +TESTLDADD = libtest.a \ + @HAIL_LIBS@ @GLIB_LIBS@ \ + @LIBCURL@ @CRYPTO_LIBS@ @XML_LIBS@ basic_bucket_LDADD = $(TESTLDADD) basic_object_LDADD = $(TESTLDADD) large_object_LDADD = $(TESTLDADD)
@@ -45,6 +44,6 @@ hdr_content_type_LDADD = $(TESTLDADD) hdr_meta_LDADD = $(TESTLDADD) it_works_LDADD = $(TESTLDADD) -wait_for_listen_LDADD = ../lib/libhttputil.a +wait_for_listen_LDADD = libtest.a TESTS_ENVIRONMENT=top_srcdir=$(top_srcdir)
test/basic-bucket.c +14 -15
@@ -22,15 +22,14 @@#include <string.h> #include <locale.h> -#include <httpstor.h> -#include <httputil.h> +#include <hstor.h> #include "test.h" int main (int argc,char *argv[]) { -struct httpstor_client *httpstor; -struct httpstor_blist *blist; -struct httpstor_bucket *buck; +struct hstor_client *hstor; +struct hstor_blist *blist; +struct hstor_bucket *buck;bool rcb;char accbuf[80 ];int rc;
@@ -40,22 +39,22 @@ int main(int argc, char *argv[]) rc =tb_readport (TEST_FILE_TB , accbuf,sizeof (accbuf));OK (rc >0 ); - httpstor =httpstor_new (accbuf,TEST_HOST ,TEST_USER ,TEST_USER_KEY ); -OK (httpstor); + hstor =hstor_new (accbuf,TEST_HOST ,TEST_USER ,TEST_USER_KEY ); +OK (hstor);/* make sure bucket list is empty */ - blist =httpstor_list_buckets (httpstor); + blist =hstor_list_buckets (hstor);OK (blist);OK (!blist->list); -httpstor_free_blist (blist); +hstor_free_blist (blist);/* add bucket */ - rcb =httpstor_add_bucket (httpstor,"test1" ); + rcb =hstor_add_bucket (hstor,"test1" );OK (rcb);/* make sure bucket list contains one item */ - blist =httpstor_list_buckets (httpstor); + blist =hstor_list_buckets (hstor);OK (blist);OK (blist->list);OK (blist->list->next ==NULL );
@@ -63,18 +62,18 @@ int main(int argc, char *argv[]) buck = blist->list->data;OK (!strcmp (buck->name,"test1" )); -httpstor_free_blist (blist); +hstor_free_blist (blist);/* delete bucket */ - rcb =httpstor_del_bucket (httpstor,"test1" ); + rcb =hstor_del_bucket (hstor,"test1" );OK (rcb);/* make sure bucket list is empty */ - blist =httpstor_list_buckets (httpstor); + blist =hstor_list_buckets (hstor);OK (blist);OK (!blist->list); -httpstor_free_blist (blist); +hstor_free_blist (blist);return 0 ; }
test/basic-object.c +9 -10
@@ -22,15 +22,14 @@#include <string.h> #include <locale.h> -#include <httpstor.h> -#include <httputil.h> +#include <hstor.h> #include "test.h" int main (int argc,char *argv[]) {static char bucket[] ="test1" ;static char key[] ="my first key" ; -struct httpstor_client *httpstor; +struct hstor_client *hstor;char accbuf[80 ];int rc;bool rcb;
@@ -43,29 +42,29 @@ int main(int argc, char *argv[]) rc =tb_readport (TEST_FILE_TB , accbuf,sizeof (accbuf));OK (rc >0 ); - httpstor =httpstor_new (accbuf,TEST_HOST ,TEST_USER ,TEST_USER_KEY ); -OK (httpstor); + hstor =hstor_new (accbuf,TEST_HOST ,TEST_USER ,TEST_USER_KEY ); +OK (hstor);/* add bucket */ - rcb =httpstor_add_bucket (httpstor, bucket); + rcb =hstor_add_bucket (hstor, bucket);OK (rcb);/* store object */ - rcb =httpstor_put_inline (httpstor, bucket, key, val,strlen (val),NULL ); + rcb =hstor_put_inline (hstor, bucket, key, val,strlen (val),NULL );OK (rcb);/* get object */ - mem =httpstor_get_inline (httpstor, bucket, key, false, &len); + mem =hstor_get_inline (hstor, bucket, key, false, &len);OK (mem);OK (len ==strlen (val));OK (!memcmp (val, mem,strlen (val)));/* delete object */ - rcb =httpstor_del (httpstor, bucket, key); + rcb =hstor_del (hstor, bucket, key);OK (rcb);/* delete bucket */ - rcb =httpstor_del_bucket (httpstor, bucket); + rcb =hstor_del_bucket (hstor, bucket);OK (rcb);return 0 ;
test/hdr-content-type.c +11 -12
@@ -25,8 +25,7 @@#include <stdlib.h> #include <ctype.h> #include <locale.h> -#include <httpstor.h> -#include <httputil.h> +#include <hstor.h> #include "test.h" static char bucket[] ="test-hdr-ctt" ;
@@ -38,17 +37,17 @@ static char *user_hdrs[] = { NULL }; -static void runtest (struct httpstor_client *httpstor) +static void runtest (struct hstor_client *hstor) {bool rcb;void *data =NULL ;size_t data_len =0 ; - rcb =httpstor_put_inline (httpstor, bucket, key, + rcb =hstor_put_inline (hstor, bucket, key, value,strlen (value) +1 , user_hdrs);OK (rcb); - data =httpstor_get_inline (httpstor, bucket, key, true, &data_len); + data =hstor_get_inline (hstor, bucket, key, true, &data_len);OK (data);OK (data_len >0 );
@@ -60,7 +59,7 @@ static void runtest(struct httpstor_client *httpstor)int main (int argc,char *argv[]) { -struct httpstor_client *httpstor; +struct hstor_client *hstor;char accbuf[80 ];int rc;bool rcb;
@@ -70,19 +69,19 @@ int main(int argc, char *argv[]) rc =tb_readport (TEST_FILE_TB , accbuf,sizeof (accbuf));OK (rc >0 ); - httpstor =httpstor_new (accbuf,TEST_HOST ,TEST_USER ,TEST_USER_KEY ); -OK (httpstor); + hstor =hstor_new (accbuf,TEST_HOST ,TEST_USER ,TEST_USER_KEY ); +OK (hstor);/* add bucket - since tests are independent, we do not rely on others */ - rcb =httpstor_add_bucket (httpstor, bucket); + rcb =hstor_add_bucket (hstor, bucket);OK (rcb); -runtest (httpstor); +runtest (hstor); - rcb =httpstor_del (httpstor, bucket, key); + rcb =hstor_del (hstor, bucket, key);OK (rcb); - rcb =httpstor_del_bucket (httpstor, bucket); + rcb =hstor_del_bucket (hstor, bucket);OK (rcb);return 0 ;
test/hdr-meta.c +11 -12
@@ -25,8 +25,7 @@#include <stdlib.h> #include <ctype.h> #include <locale.h> -#include <httpstor.h> -#include <httputil.h> +#include <hstor.h> #include "test.h" static char bucket[] ="test-hdr-meta" ;
@@ -39,18 +38,18 @@ static char *user_hdrs[] = { NULL }; -static void runtest (struct httpstor_client *httpstor) +static void runtest (struct hstor_client *hstor) {bool rcb;void *data =NULL ;size_t data_len =0 ;int idx; - rcb =httpstor_put_inline (httpstor, bucket, key, + rcb =hstor_put_inline (hstor, bucket, key, value,strlen (value) +1 , user_hdrs);OK (rcb); - data =httpstor_get_inline (httpstor, bucket, key, true, &data_len); + data =hstor_get_inline (hstor, bucket, key, true, &data_len);OK (data);OK (data_len >0 );
@@ -67,7 +66,7 @@ static void runtest(struct httpstor_client *httpstor)int main (int argc,char *argv[]) { -struct httpstor_client *httpstor; +struct hstor_client *hstor;char accbuf[80 ];int rc;bool rcb;
@@ -77,19 +76,19 @@ int main(int argc, char *argv[]) rc =tb_readport (TEST_FILE_TB , accbuf,sizeof (accbuf));OK (rc >0 ); - httpstor =httpstor_new (accbuf,TEST_HOST ,TEST_USER ,TEST_USER_KEY ); -OK (httpstor); + hstor =hstor_new (accbuf,TEST_HOST ,TEST_USER ,TEST_USER_KEY ); +OK (hstor);/* add bucket - since tests are independent, we do not rely on others */ - rcb =httpstor_add_bucket (httpstor, bucket); + rcb =hstor_add_bucket (hstor, bucket);OK (rcb); -runtest (httpstor); +runtest (hstor); - rcb =httpstor_del (httpstor, bucket, key); + rcb =hstor_del (hstor, bucket, key);OK (rcb); - rcb =httpstor_del_bucket (httpstor, bucket); + rcb =hstor_del_bucket (hstor, bucket);OK (rcb);return 0 ;
test/it-works.c +8 -9
@@ -22,14 +22,13 @@#include <string.h> #include <locale.h> -#include <httpstor.h> -#include <httputil.h> +#include <hstor.h> #include "test.h" int main (int argc,char *argv[]) { -struct httpstor_client *httpstor; -struct httpstor_blist *blist; +struct hstor_client *hstor; +struct hstor_blist *blist;char accbuf[80 ];int rc;
@@ -38,14 +37,14 @@ int main(int argc, char *argv[]) rc =tb_readport (TEST_FILE_TB , accbuf,sizeof (accbuf));OK (rc >0 ); - httpstor =httpstor_new (accbuf,TEST_HOST ,TEST_USER ,TEST_USER_KEY ); -OK (httpstor); + hstor =hstor_new (accbuf,TEST_HOST ,TEST_USER ,TEST_USER_KEY ); +OK (hstor); - blist =httpstor_list_buckets (httpstor); + blist =hstor_list_buckets (hstor);OK (blist); -OK (!strcmp (blist->own_id, httpstor->user)); -OK (!strcmp (blist->own_name, httpstor->user)); +OK (!strcmp (blist->own_id, hstor->user)); +OK (!strcmp (blist->own_name, hstor->user));OK (!blist->list);return 0 ;
test/large-object.c +13 -14
@@ -30,8 +30,7 @@#include <string.h> #include <stdlib.h> #include <locale.h> -#include <httpstor.h> -#include <httputil.h> +#include <hstor.h> #include "test.h" #define BLKSZ0 1024
@@ -162,7 +161,7 @@ static size_t get_cb(void *ptr, size_t membsize, size_t nmemb, void *user_data)return nmemb; } -static void runtest (struct httpstor_client *httpstor, +static void runtest (struct hstor_client *hstor,size_t blklen,int nblks) {off_t total = blklen * nblks;
@@ -176,7 +175,7 @@ static void runtest(struct httpstor_client *httpstor, putctx.blksize = blklen; putctx.total = total; - rcb =httpstor_put (httpstor, bucket, key, put_cb, total, &putctx,NULL ); + rcb =hstor_put (hstor, bucket, key, put_cb, total, &putctx,NULL );OK (rcb);OK (putctx.off == total);
@@ -186,7 +185,7 @@ static void runtest(struct httpstor_client *httpstor, getctx.csum =CSUM_INIT ; getctx.blksize = blklen; - rcb =httpstor_get (httpstor, bucket, key, get_cb, &getctx, false); + rcb =hstor_get (hstor, bucket, key, get_cb, &getctx, false);OK (rcb);OK (getctx.off == total);
@@ -195,7 +194,7 @@ static void runtest(struct httpstor_client *httpstor,int main (int argc,char *argv[]) { -struct httpstor_client *httpstor; +struct hstor_client *hstor;char accbuf[80 ];int rc;bool rcb;
@@ -205,21 +204,21 @@ int main(int argc, char *argv[]) rc =tb_readport (TEST_FILE_TB , accbuf,sizeof (accbuf));OK (rc >0 ); - httpstor =httpstor_new (accbuf,TEST_HOST ,TEST_USER ,TEST_USER_KEY ); -OK (httpstor); + hstor =hstor_new (accbuf,TEST_HOST ,TEST_USER ,TEST_USER_KEY ); +OK (hstor);/* add bucket - since tests are independent, we do not rely on others */ - rcb =httpstor_add_bucket (httpstor, bucket); + rcb =hstor_add_bucket (hstor, bucket);OK (rcb); -runtest (httpstor,BLKSZ0 ,NBLKS0 ); -runtest (httpstor,BLKSZ1 ,NBLKS1 ); -runtest (httpstor,BLKSZ2 ,NBLKS2 ); +runtest (hstor,BLKSZ0 ,NBLKS0 ); +runtest (hstor,BLKSZ1 ,NBLKS1 ); +runtest (hstor,BLKSZ2 ,NBLKS2 ); - rcb =httpstor_del (httpstor, bucket, key); + rcb =hstor_del (hstor, bucket, key);OK (rcb); - rcb =httpstor_del_bucket (httpstor, bucket); + rcb =hstor_del_bucket (hstor, bucket);OK (rcb);return 0 ;
test/libtest.c +36 -0
@@ -17,9 +17,14 @@* */ +#include <sys/types.h> +#include <sys/stat.h> #include <string.h> #include <stdbool.h> +#include <unistd.h> #include <ctype.h> +#include <errno.h> +#include <fcntl.h> #include "test.h" bool find_our_hdr (const char *hdr,const void *data,size_t data_len)
@@ -61,3 +66,34 @@ bool find_our_hdr(const char *hdr, const void *data, size_t data_len)return false; } +/* +* Read a port number from a port file, fill buffer. +* Unlike cld_readport, host is included as well, and we use strings. +*/ +int tb_readport (const char *fname,char *buf,size_t len) +{ +int fd; +char *s; +int rc; + +if (len <3 ) +return -EDOM ; +if ((fd =open (fname,O_RDONLY )) ==-1 ) +return -errno; + rc =read (fd, buf, len-1 ); +close (fd); +if (rc <0 ) +return -errno; +if (rc ==0 ) +return -EPIPE ; + buf[rc] =0 ; + + s =strchr (buf,'\n' ); +if (s) { + *s =0 ; + rc = s - buf; + } + +return rc; +} +
test/test.h +2 -1
@@ -19,7 +19,7 @@* */ - +#include <stdbool.h> #include <stdlib.h> #include <stdio.h>
@@ -39,5 +39,6 @@ } while (0) extern bool find_our_hdr(const char *hdr, const void *data, size_t data_len); +extern int tb_readport (const char *fname,char *buf,size_t len);#endif /* __TABLED_TEST_H__ */
test/wait-for-listen.c +0 -1
@@ -34,7 +34,6 @@#include <time.h> #include <unistd.h> #include <netdb.h> -#include <httputil.h> #include "test.h" #define ADDRSIZE 24/* Enough for IPv6, including port. */
Quoted 4 lines · Jeff Garzik
Just committed the following to tabled.git on my local laptop, on a side branch. This won't be pushed onto the main tabled branch until Friday, to give people time to convert as zaitcev suggested in the 'new hail repository' thread.
This has now been pushed, as branch 'libhail-merge'.
Branch master, aka the main trunk, remains untouched until Friday (unless some critical tabled issue arises before then, of course).
Quoted 4 lines
As a side note, this requires a couple hail.git commits that will be pushed to upstream hail.git from my local laptop in a couple hours (movement of
uri_parsefrom tabled's libhttpstor into libhail), so you'll need to update hail.git before being able to use the patch below.
These hail.git commits have now been pushed:
commit c7b833069e28cf9bddb69f46bb5e09138ab4984d
libhail: add huri_parse API (imported from tabled)
commit 55b0c57ca8f2b6beecea5a4680d76f45a7c32c28
Fix .gitignore issue causing test/chunkd/ to be completely ignored.
commit 5188f48dd3c73ce86f2bc453a326ee0bf40fd6db
libhail: Import httpstor, httputil modules from tabled
Jeff
Quoted 10 lines · Jeff Garzik
Quoted 4 lines · Jeff Garzik
Just committed the following to tabled.git on my local laptop, on a side branch. This won't be pushed onto the main tabled branch until Friday, to give people time to convert as zaitcev suggested in the 'new hail repository' thread.
This has now been pushed, as branch 'libhail-merge'.
Branch master, aka the main trunk, remains untouched until Friday (unless some critical tabled issue arises before then, of course).
Sigh. It looks like I screwed up, and accidentally pushed to the wrong branch (master). Since it was destined for upstream, might as well leave it the way it is.
If anybody wants to recover the pre-libhail tabled.git tree, it can easily be done with
git checkout -b tmp cd0105320322ee32d8db4256bfafc4c73670cd73
which creates branch 'tmp' based on the specified commit.
Jeff
Quoted 2 lines · On Wed, 7 Jul 2010 21:05:09 -0400 Jeff Garzik <[email protected]> wrote:
If anybody wants to recover the pre-libhail tabled.git tree, it can easily be done with
Naah, I hate git branches (except the mandatory ones, of course).
-- Pete