From 1a111277d10db221d35629e1b0b9060f7ba42891 Mon Sep 17 00:00:00 2001 From: Robert Newson Date: Mon, 10 Oct 2011 22:02:07 +0100 Subject: Backport erlang-oauth from master for R15 compat --- src/erlang-oauth/Makefile.am | 4 +++- src/erlang-oauth/oauth.app.in | 2 +- src/erlang-oauth/oauth_hmac_sha1.erl | 2 +- src/erlang-oauth/oauth_http.erl | 2 +- src/erlang-oauth/oauth_plaintext.erl | 2 +- 5 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/erlang-oauth/Makefile.am b/src/erlang-oauth/Makefile.am index 50782e75..48b76482 100644 --- a/src/erlang-oauth/Makefile.am +++ b/src/erlang-oauth/Makefile.am @@ -22,13 +22,15 @@ oauth_file_collection = \ oauth_unix.erl \ oauth_uri.erl +# Removed oauth_rsa_sha1.beam until we require R12B5 or +# we add a ./configure option to enable it. + oauthebin_make_generated_file_list = \ oauth.app \ oauth.beam \ oauth_hmac_sha1.beam \ oauth_http.beam \ oauth_plaintext.beam \ - oauth_rsa_sha1.beam \ oauth_unix.beam \ oauth_uri.beam diff --git a/src/erlang-oauth/oauth.app.in b/src/erlang-oauth/oauth.app.in index 6357b9b0..a8ec17c4 100644 --- a/src/erlang-oauth/oauth.app.in +++ b/src/erlang-oauth/oauth.app.in @@ -1,6 +1,6 @@ {application, oauth, [ {description, "Erlang OAuth implementation"}, - {vsn, "dev"}, + {vsn, "7d85d3ef"}, {modules, [ oauth, oauth_hmac_sha1, diff --git a/src/erlang-oauth/oauth_hmac_sha1.erl b/src/erlang-oauth/oauth_hmac_sha1.erl index 79d59f37..69064edd 100644 --- a/src/erlang-oauth/oauth_hmac_sha1.erl +++ b/src/erlang-oauth/oauth_hmac_sha1.erl @@ -8,4 +8,4 @@ signature(BaseString, CS, TS) -> base64:encode_to_string(crypto:sha_mac(Key, BaseString)). verify(Signature, BaseString, CS, TS) -> - couch_util:verify(signature(BaseString, CS, TS), Signature). + Signature =:= signature(BaseString, CS, TS). diff --git a/src/erlang-oauth/oauth_http.erl b/src/erlang-oauth/oauth_http.erl index bf5a4bac..92c806cc 100644 --- a/src/erlang-oauth/oauth_http.erl +++ b/src/erlang-oauth/oauth_http.erl @@ -10,7 +10,7 @@ post(URL, Data) -> request(post, {URL, [], "application/x-www-form-urlencoded", Data}). request(Method, Request) -> - http:request(Method, Request, [{autoredirect, false}], []). + httpc:request(Method, Request, [{autoredirect, false}], []). response_params(Response) -> oauth_uri:params_from_string(response_body(Response)). diff --git a/src/erlang-oauth/oauth_plaintext.erl b/src/erlang-oauth/oauth_plaintext.erl index 41a1e9b2..d8085e02 100644 --- a/src/erlang-oauth/oauth_plaintext.erl +++ b/src/erlang-oauth/oauth_plaintext.erl @@ -7,4 +7,4 @@ signature(CS, TS) -> oauth_uri:calate("&", [CS, TS]). verify(Signature, CS, TS) -> - couch_util:verify(signature(CS, TS), Signature). + Signature =:= signature(CS, TS). -- cgit v1.2.3 From 605f274ff8fa5d421d7397eef3e719950b853838 Mon Sep 17 00:00:00 2001 From: Robert Newson Date: Mon, 10 Oct 2011 22:06:37 +0100 Subject: Fix R15 warning for etap_web.erl --- src/etap/etap_web.erl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/etap/etap_web.erl b/src/etap/etap_web.erl index fb7aee16..f97edfd7 100644 --- a/src/etap/etap_web.erl +++ b/src/etap/etap_web.erl @@ -42,7 +42,7 @@ simple_404(Url, Desc) -> %% @doc Create and return a request structure. build_request(Method, Url, Headers, Body) when Method==options;Method==get;Method==head;Method==delete;Method==trace -> - try http:request(Method, {Url, Headers}, [{autoredirect, false}], []) of + try httpc:request(Method, {Url, Headers}, [{autoredirect, false}], []) of {ok, {OutStatus, OutHeaders, OutBody}} -> etap_request:new(Method, Url, Headers, Body, OutStatus, OutHeaders, OutBody); _ -> error @@ -56,7 +56,7 @@ build_request(Method, Url, Headers, Body) when Method == post; Method == put -> {value, {"Content-Type", X}} -> X; _ -> [] end, - try http:request(Method, {Url, Headers, ContentType, Body}, [{autoredirect, false}], []) of + try httpc:request(Method, {Url, Headers, ContentType, Body}, [{autoredirect, false}], []) of {ok, {OutStatus, OutHeaders, OutBody}} -> etap_request:new(Method, Url, Headers, Body, OutStatus, OutHeaders, OutBody); _ -> error -- cgit v1.2.3 From 79fa8d7d66d5e869d2a0757bb7fdf9f95fe36f66 Mon Sep 17 00:00:00 2001 From: Filipe David Manana Date: Wed, 12 Oct 2011 12:17:41 +0100 Subject: Remove duplicated word "the" --- src/couchdb/priv/couch_js/help.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/couchdb/priv/couch_js/help.h b/src/couchdb/priv/couch_js/help.h index 84c83c06..c42c9f59 100644 --- a/src/couchdb/priv/couch_js/help.h +++ b/src/couchdb/priv/couch_js/help.h @@ -51,7 +51,7 @@ static const char USAGE_TEMPLATE[] = " -H enable %s cURL bindings (only avaiable\n" " if package was built with cURL available)\n" " -S SIZE specify that the interpreter should set the\n" - " the stack quota for JS contexts to SIZE bytes\n" + " stack quota for JS contexts to SIZE bytes\n" "\n" "Report bugs at <%s>.\n"; -- cgit v1.2.3 From d01047563d932c9d2c0c9c014a98bf4a83ff485a Mon Sep 17 00:00:00 2001 From: Robert Newson Date: Mon, 10 Oct 2011 20:20:59 +0100 Subject: Update CHANGES/NEWS/acinclude.m4.in for 1.1.1 --- CHANGES | 2 -- NEWS | 2 -- acinclude.m4.in | 2 +- 3 files changed, 1 insertion(+), 5 deletions(-) diff --git a/CHANGES b/CHANGES index 0c619ab9..ada57715 100644 --- a/CHANGES +++ b/CHANGES @@ -4,8 +4,6 @@ Apache CouchDB CHANGES Version 1.1.1 ------------- -This version has not been released yet. - * Add configurable maximum to the number of bytes returned by _log. * Allow CommonJS modules to be an empty string. * Bump minimum Erlang version to R13B02. diff --git a/NEWS b/NEWS index 13e6ac56..99cc474f 100644 --- a/NEWS +++ b/NEWS @@ -10,8 +10,6 @@ Each release section notes when backwards incompatible changes have been made. Version 1.1.1 ------------- -This version has not been released yet. - * Add configurable maximum to the number of bytes returned by _log. * Allow CommonJS modules to be an empty string. * Bump minimum Erlang version to R13B02. diff --git a/acinclude.m4.in b/acinclude.m4.in index e74f6336..8466b564 100644 --- a/acinclude.m4.in +++ b/acinclude.m4.in @@ -19,7 +19,7 @@ m4_define([LOCAL_BUG_URI], [https://issues.apache.org/jira/browse/COUCHDB]) m4_define([LOCAL_VERSION_MAJOR], [1]) m4_define([LOCAL_VERSION_MINOR], [1]) m4_define([LOCAL_VERSION_REVISION], [1]) -m4_define([LOCAL_VERSION_STAGE], [a]) +m4_define([LOCAL_VERSION_STAGE], []) m4_define([LOCAL_VERSION_RELEASE], [%release%]) m4_define([LOCAL_VERSION_PRIMARY], [LOCAL_VERSION_MAJOR.LOCAL_VERSION_MINOR.LOCAL_VERSION_REVISION]) -- cgit v1.2.3 From 1e1d07a916f22a29ccc2fff98f44746851b287ff Mon Sep 17 00:00:00 2001 From: Robert Newson Date: Thu, 13 Oct 2011 15:09:02 +0100 Subject: restore couch_util:verify call in oauth. --- src/erlang-oauth/oauth_hmac_sha1.erl | 2 +- src/erlang-oauth/oauth_plaintext.erl | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/erlang-oauth/oauth_hmac_sha1.erl b/src/erlang-oauth/oauth_hmac_sha1.erl index 69064edd..35549cfc 100644 --- a/src/erlang-oauth/oauth_hmac_sha1.erl +++ b/src/erlang-oauth/oauth_hmac_sha1.erl @@ -8,4 +8,4 @@ signature(BaseString, CS, TS) -> base64:encode_to_string(crypto:sha_mac(Key, BaseString)). verify(Signature, BaseString, CS, TS) -> - Signature =:= signature(BaseString, CS, TS). + couch_util:verify(Signature, signature(BaseString, CS, TS)). diff --git a/src/erlang-oauth/oauth_plaintext.erl b/src/erlang-oauth/oauth_plaintext.erl index d8085e02..9544a0af 100644 --- a/src/erlang-oauth/oauth_plaintext.erl +++ b/src/erlang-oauth/oauth_plaintext.erl @@ -7,4 +7,4 @@ signature(CS, TS) -> oauth_uri:calate("&", [CS, TS]). verify(Signature, CS, TS) -> - Signature =:= signature(CS, TS). + couch_util:verify(Signature, signature(CS, TS)). -- cgit v1.2.3 From 7ce9e103e50678a38c78607f2441340cd6d688da Mon Sep 17 00:00:00 2001 From: Paul Joseph Davis Date: Tue, 18 Oct 2011 16:18:01 -0500 Subject: Prevent linking against too new of a SpiderMonkey Versions of SpiderMonkey newer than js185-1.0.0 have removed the JSOPTION_ANONFUNFIX which basically invalidates all CouchDB JavaScript functions ever written. This configure patch prevents the accidental linking to a library that has this new behavior while allowing people to forcefully override the check. --- configure.ac | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/configure.ac b/configure.ac index 5124b8b1..6f9327d0 100644 --- a/configure.ac +++ b/configure.ac @@ -81,6 +81,12 @@ AC_ARG_WITH([js-lib], [AC_HELP_STRING([--with-js-lib=PATH], ]) AC_SUBST(JS_LIB_DIR) +use_js_trunk=no +AC_ARG_ENABLE([js-trunk], [AC_HELP_STRING([--enable-js-trunk], + [allow use of SpiderMonkey versions newer than js185-1.0.0])], [ + use_js_trunk=$enableval +], []) + AC_ARG_VAR([ERLC_FLAGS], [general flags to prepend to ERLC_FLAGS]) AC_ARG_VAR([FLAGS], [general flags to prepend to LDFLAGS and CPPFLAGS]) @@ -177,6 +183,21 @@ AC_CHECK_HEADER([jsapi.h], [], [ Are the Mozilla SpiderMonkey headers installed?]) ])]) +# Prevent people from accidentally using SpiderMonkey's that are too new + +if test "$use_js_trunk" = "no"; then +AC_CHECK_DECL([JSOPTION_ANONFUNFIX], [], [ + AC_MSG_ERROR([Your SpiderMonkey library is too new. + +Versions of SpiderMonkey after the js185-1.0.0 release remove the optional +enforcement of preventing anonymous functions in a statement context. This +will most likely break your existing JavaScript code as well as render all +example code invalid. + +If you wish to ignore this error pass --enable-js-trunk to ./configure.])], + [[#include ]]) +fi + AC_SUBST(JSLIB) AC_LANG_PUSH(C) -- cgit v1.2.3 From 7c6e5f0f4340e997a761ff5ca627422fea90d4cc Mon Sep 17 00:00:00 2001 From: Paul Joseph Davis Date: Tue, 18 Oct 2011 16:19:51 -0500 Subject: Minor fixes to link agianst SpiderMonkey trunk This patch allows couchjs to link against the SpiderMonkey as it existed in the mercurial hash 59c1e6bdb11 from [1]. This does *not* ensure compatibility with CouchDB as there are other things that will also need to be fixed. Specifically, the anonymous function issue for builtin JS functions. [1] http://hg.mozilla.org/mozilla-central/ --- configure.ac | 8 ++++++++ src/couchdb/priv/couch_js/http.c | 12 ++++++------ src/couchdb/priv/couch_js/sm185.c | 2 +- 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/configure.ac b/configure.ac index 6f9327d0..182e0eb5 100644 --- a/configure.ac +++ b/configure.ac @@ -214,6 +214,14 @@ AC_CHECK_LIB([$JS_LIB_BASE], [JS_GetStringCharsAndLength], AC_DEFINE([HAVE_JS_GET_STRING_CHARS_AND_LENGTH], [1], [Use newer JS_GetCharsAndLength function.])) +# Deal with JSScript -> JSObject -> JSScript switcheroo + +AC_CHECK_TYPE([JSScript*], + [AC_DEFINE([JSSCRIPT_TYPE], [JSScript*], [Use JSObject* for scripts])], + [AC_DEFINE([JSSCRIPT_TYPE], [JSObject*], [Use JSScript* for scripts])], + [[#include ]] +) + AC_LANG_POP(C) AC_ARG_WITH([win32-icu-binaries], [AC_HELP_STRING([--with-win32-icu-binaries=PATH], diff --git a/src/couchdb/priv/couch_js/http.c b/src/couchdb/priv/couch_js/http.c index 77078e35..7630c456 100644 --- a/src/couchdb/priv/couch_js/http.c +++ b/src/couchdb/priv/couch_js/http.c @@ -126,7 +126,7 @@ http_open(JSContext* cx, JSObject* req, jsval mth, jsval url, jsval snc) goto done; } - if(mth == JSVAL_VOID) { + if(JSVAL_IS_VOID(mth)) { JS_ReportError(cx, "You must specify a method."); goto done; } @@ -148,7 +148,7 @@ http_open(JSContext* cx, JSObject* req, jsval mth, jsval url, jsval snc) http->method = methid; - if(url == JSVAL_VOID) { + if(JSVAL_IS_VOID(url)) { JS_ReportError(cx, "You must specify a URL."); goto done; } @@ -164,7 +164,7 @@ http_open(JSContext* cx, JSObject* req, jsval mth, jsval url, jsval snc) goto done; } - if(snc != JSVAL_FALSE) { + if(JSVAL_IS_BOOLEAN(snc) && !JSVAL_TO_BOOLEAN(snc)) { JS_ReportError(cx, "Synchronous flag must be false."); goto done; } @@ -200,7 +200,7 @@ http_set_hdr(JSContext* cx, JSObject* req, jsval name, jsval val) goto done; } - if(name == JSVAL_VOID) + if(JSVAL_IS_VOID(name)) { JS_ReportError(cx, "You must speciy a header name."); goto done; @@ -213,7 +213,7 @@ http_set_hdr(JSContext* cx, JSObject* req, jsval name, jsval val) goto done; } - if(val == JSVAL_VOID) + if(JSVAL_IS_VOID(val)) { JS_ReportError(cx, "You must specify a header value."); goto done; @@ -258,7 +258,7 @@ http_send(JSContext* cx, JSObject* req, jsval body) goto done; } - if(body != JSVAL_VOID && body != JS_GetEmptyStringValue(cx)) { + if(!JSVAL_IS_VOID(body)) { bodystr = enc_string(cx, body, &bodylen); if(!bodystr) { JS_ReportError(cx, "Failed to encode body."); diff --git a/src/couchdb/priv/couch_js/sm185.c b/src/couchdb/priv/couch_js/sm185.c index 701d5677..6a4522e7 100644 --- a/src/couchdb/priv/couch_js/sm185.c +++ b/src/couchdb/priv/couch_js/sm185.c @@ -310,7 +310,7 @@ main(int argc, const char* argv[]) JSObject* global = NULL; JSCrossCompartmentCall *call = NULL; JSObject* klass = NULL; - JSObject* script; + JSSCRIPT_TYPE script; JSString* scriptsrc; const jschar* schars; size_t slen; -- cgit v1.2.3 From e37148e14bdaf88a0a568edbade6cf9101afb4af Mon Sep 17 00:00:00 2001 From: Robert Newson Date: Wed, 19 Oct 2011 12:57:25 +0100 Subject: mention 1.8.5 support in NEWS/CHANGES --- CHANGES | 1 + NEWS | 1 + 2 files changed, 2 insertions(+) diff --git a/CHANGES b/CHANGES index ada57715..d62f0e16 100644 --- a/CHANGES +++ b/CHANGES @@ -4,6 +4,7 @@ Apache CouchDB CHANGES Version 1.1.1 ------------- +* Support SpiderMonkey 1.8.5 * Add configurable maximum to the number of bytes returned by _log. * Allow CommonJS modules to be an empty string. * Bump minimum Erlang version to R13B02. diff --git a/NEWS b/NEWS index 99cc474f..52df969d 100644 --- a/NEWS +++ b/NEWS @@ -10,6 +10,7 @@ Each release section notes when backwards incompatible changes have been made. Version 1.1.1 ------------- +* Support SpiderMonkey 1.8.5 * Add configurable maximum to the number of bytes returned by _log. * Allow CommonJS modules to be an empty string. * Bump minimum Erlang version to R13B02. -- cgit v1.2.3 From ac1f52b32b39e8adc2b7d74040da0e0db4894d2a Mon Sep 17 00:00:00 2001 From: Robert Newson Date: Thu, 20 Oct 2011 17:25:25 +0100 Subject: Fix object sealing on sm 1.7.0 --- src/couchdb/priv/couch_js/sm170.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/couchdb/priv/couch_js/sm170.c b/src/couchdb/priv/couch_js/sm170.c index ebb6673f..c900b850 100644 --- a/src/couchdb/priv/couch_js/sm170.c +++ b/src/couchdb/priv/couch_js/sm170.c @@ -217,7 +217,7 @@ seal(JSContext* cx, JSObject* obj, uintN argc, jsval* argv, jsval* rval) return JS_TRUE; } - if(JS_SealObject(cx, obj, deep) != JS_TRUE) + if(JS_SealObject(cx, target, deep) != JS_TRUE) return JS_FALSE; *rval = JSVAL_VOID; -- cgit v1.2.3 From 0d0ed4122370bf279d26057395bdc508bc4ae9f7 Mon Sep 17 00:00:00 2001 From: Paul Joseph Davis Date: Thu, 20 Oct 2011 11:40:25 -0500 Subject: Fix JavaScript CLI test runner. Accidentally inverted the logic of a test when patching for newer versions of SpiderMonkey. --- src/couchdb/priv/couch_js/http.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/couchdb/priv/couch_js/http.c b/src/couchdb/priv/couch_js/http.c index 7630c456..052865aa 100644 --- a/src/couchdb/priv/couch_js/http.c +++ b/src/couchdb/priv/couch_js/http.c @@ -164,7 +164,7 @@ http_open(JSContext* cx, JSObject* req, jsval mth, jsval url, jsval snc) goto done; } - if(JSVAL_IS_BOOLEAN(snc) && !JSVAL_TO_BOOLEAN(snc)) { + if(JSVAL_IS_BOOLEAN(snc) && JSVAL_TO_BOOLEAN(snc)) { JS_ReportError(cx, "Synchronous flag must be false."); goto done; } -- cgit v1.2.3 From 89f7faa6d09248999fb51ffd2a13777168f51805 Mon Sep 17 00:00:00 2001 From: Filipe David Manana Date: Thu, 20 Oct 2011 17:55:58 +0100 Subject: Update CHANGES and NEWS to reflect COUCHDB-1129 --- CHANGES | 1 + NEWS | 1 + 2 files changed, 2 insertions(+) diff --git a/CHANGES b/CHANGES index d62f0e16..8e89305f 100644 --- a/CHANGES +++ b/CHANGES @@ -28,6 +28,7 @@ Version 1.1.1 * Fix replication crash when source database has a document with empty ID. * Fix deadlock when assigning couchjs processes to serve requests. * Fixes to the document multipart PUT API. +* Fixes regarding file descriptor leaks for databases with views. Version 1.1.0 ------------- diff --git a/NEWS b/NEWS index 52df969d..e62289ed 100644 --- a/NEWS +++ b/NEWS @@ -34,6 +34,7 @@ Version 1.1.1 * Fix replication crash when source database has a document with empty ID. * Fix deadlock when assigning couchjs processes to serve requests. * Fixes to the document multipart PUT API. +* Fixes regarding file descriptor leaks for databases with views. Version 1.1.0 ------------- -- cgit v1.2.3 From af7a6ae52890c6c158615068f2a48d40c52ec538 Mon Sep 17 00:00:00 2001 From: Paul Joseph Davis Date: Sun, 23 Oct 2011 12:27:35 -0500 Subject: Hardcode couchjs binary name Windows doesn't have the libgen.h header or an easily identified basename function. Instead of playing games we just configure the name with autoconf and run with that. --- configure.ac | 5 +++++ src/couchdb/priv/couch_js/help.h | 4 +--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/configure.ac b/configure.ac index 182e0eb5..6a5d8653 100644 --- a/configure.ac +++ b/configure.ac @@ -127,7 +127,12 @@ Is the Mozilla SpiderMonkey library installed?])])])])])])]) AC_SUBST(JS_LIB_BASE) +AC_DEFINE([COUCHJS_NAME], ["couchjs"], ["CouchJS executable name."]) + if test x${IS_WINDOWS} = xTRUE; then + + AC_DEFINE([COUCHJS_NAME], ["couchjs.exe"], ["CouchJS executable name."]) + if test -f "$JS_LIB_DIR/$JS_LIB_BASE.dll"; then # seamonkey 1.7- build layout on Windows JS_LIB_BINARY="$JS_LIB_DIR/$JS_LIB_BASE.dll" diff --git a/src/couchdb/priv/couch_js/help.h b/src/couchdb/priv/couch_js/help.h index c42c9f59..41025942 100644 --- a/src/couchdb/priv/couch_js/help.h +++ b/src/couchdb/priv/couch_js/help.h @@ -13,8 +13,6 @@ #ifndef COUCHJS_HELP_H #define COUCHJS_HELP_H -#include - #include "config.h" static const char VERSION_TEMPLATE[] = @@ -55,7 +53,7 @@ static const char USAGE_TEMPLATE[] = "\n" "Report bugs at <%s>.\n"; -#define BASENAME basename((char*)argv[0]) +#define BASENAME COUCHJS_NAME #define couch_version(basename) \ fprintf( \ -- cgit v1.2.3