Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Build fixes, 32 bit support

- 32 bit support based and developed on NetBSD
- MockServer bug when SIGSTOP to netbsd java
- Typos and extra cruft in src/Makefile.PL
- Fixed redefine bugs for perls 5.15.x
- Compression interop tests for memcached (and bugfixes related to
    option specifiers)
- Added 'known issues' section in README
- Handle $Config{lddlflags} if it contains rpath directives
  • Loading branch information...
commit fdc0e6abaa60ec86e5275bc36aed87e46e33f542 1 parent 34d6bd7
@mnunberg mnunberg authored
View
2  Changes
@@ -1,4 +1,6 @@
Revision history for Couchbase-Client
+0.16 Feb 23 2012
+ Added 32 bit support, some more fixes for mock testing
0.01 Date/time
First version, released on an unsuspecting world.
View
2  MANIFEST
@@ -61,7 +61,7 @@ src/Makefile.PL
src/libcouchbase.pm
src/memcached-headers.tar.gz
-src/libcouchbase-1.0.1.tar.gz
+src/libcouchbase-1.0.0_70_ge8ad2ee.tar.gz
src/libvbucket-1.8.0.2.tar.gz
src/libevent-2.0.17-stable.tar.gz
src/libisasl-1.0.0_3_g35e33e3.tar.gz
View
2  Makefile.PL
@@ -34,7 +34,7 @@ EOD
our (@LIBS,$INC);
our $MM_TopLevel;
-our $Constants_INC;
+our $Constants_INC = "";
push @LIBS, $U_LibPath if $U_LibPath;
$INC = $U_IncPath || "";
View
2  PLCB_Config.pm
@@ -16,7 +16,7 @@ my $params = {
#version numbers for libcouchbase and libvbucket
LIBVBUCKET_RELEASE => '1.8.0.2',
- LIBCOUCHBASE_RELEASE => '1.0.1',
+ LIBCOUCHBASE_RELEASE => '1.0.0_70_ge8ad2ee',
LIBISASL_RELEASE => '1.0.0_3_g35e33e3',
LIBEVENT_RELEASE => '2.0.17-stable',
View
41 README.pod
@@ -185,4 +185,45 @@ Which server to connect to (default is C<localhost:8091>)
Required for some tests. This is the authless port for memcached client access.
+=back
+
+=head3 KNOWN ISSUES
+
+=over
+
+=item *
+
+32 Bit perls will have arithmetic results stringified if their value is greater
+than 32 bits.
+
+
+=item *
+
+Some tests within the test suite will fail in some unices (but not linux, from
+what i've seen) with the following message:
+
+ t/01-main.t .. 1/?
+ # Failed test 'have single error'
+ # at /home/mordy/Couchbase-Client-0.16_0/blib/lib/Couchbase/Test/Settings.pm line 262.
+ # (in Couchbase::Test::Settings->T25_multi_server_list)
+ # got: '2'
+ # expected: '1'
+ t/01-main.t .. 162/? # Looks like you failed 1 test of 166.
+ t/01-main.t .. Failed 1/166 subtests
+ (less 1 skipped subtest: 164 okay)
+
+
+This is not a fatal error, and is being worked on
+
+=item *
+
+Asynchronous tests (and the reference POE implementation) will not work properly
+on NetBSD due to a weird L<kernel bug|http://gnats.netbsd.org/cgi-bin/query-pr-single.pl?number=46077>
+
+
+=item *
+
+I have not even bothered to figure out how to compile this on Windows. Mingw32
+will be supported eventually, but probably not MSVC.
+
=back
View
4 build_libraries.pl
@@ -62,7 +62,7 @@ sub lib_2_tarball {
sub tarball_2_dir {
my $tarball = shift;
- runcmd("tar xf $tarball");
+ runcmd("tar xzf $tarball");
my $filename = fileparse($tarball, qr/\.tar\..*/);
return $filename;
}
@@ -94,7 +94,7 @@ sub tarball_2_dir {
mkpath($INCLUDE_PATH);
mkpath($LIB_PATH);
-runcmd("tar xf $MEMCACHED_H_TARBALL");
+runcmd("tar xzf $MEMCACHED_H_TARBALL");
rmtree(File::Spec->catfile($INCLUDE_PATH, 'memcached'));
runcmd("mv include/memcached $INCLUDE_PATH && rm -rf include/memcached");
unless(-e File::Spec->catfile($INCLUDE_PATH, 'memcached', 'protocol_binary.h')) {
View
15 lib/Couchbase/Client.pm
@@ -2,7 +2,7 @@ package Couchbase::Client;
BEGIN {
require XSLoader;
- our $VERSION = '0.15_0';
+ our $VERSION = '0.16_0';
XSLoader::load(__PACKAGE__, $VERSION);
}
@@ -195,6 +195,8 @@ Couchbase::Client - Perl Couchbase Client
This page documents the API of C<Couchbase::Client>. To install this module,
see L<Couchbase::Client::README> for a broader overview.
+See that same page for a list of current known issues as well.
+
=head1 WARNING
The bundled C<libcouchbase> is not an official release version, and might break.
@@ -558,12 +560,13 @@ These two functions are equivalent to doing:
=head4 NOTE ABOUT 32 BIT PERLS
-If your Perl does not support 64 bit integer arithmetic, then L<Math::BigInt> will
-be used for conversion. Since Couchbase internally represents both deltas and values
-as C<int64_t> or C<uint64_t> values.
+If Perl does not support 64 bit integers then the following will happen:
-TODO: would be nice to optionally provide 32-bit integer overflow options for
-performance.
+If the result of an arithmetic operation can be stored within a 32 bit integer,
+then all proceeds as normal and you get a normal Perl integer back. If, however
+the result exceeds 32 bits (i.e. greated than stdint.h's C<UINT32_MAX>) then
+your return value will be B<stringified>, since the underlying C layer can always
+deal with 64 bit integers.
=head3 delete(key [,cas])
View
4 lib/Couchbase/Client/Async.pm
@@ -1,9 +1,7 @@
package Couchbase::Client::Async;
use strict;
use warnings;
-our $VERSION = '0.15_0';
-require XSLoader;
-XSLoader::load('Couchbase::Client', $VERSION);
+our $VERSION = '0.16_0';
use Couchbase::Client;
use Couchbase::Client::IDXConst;
use Log::Fu;
View
9 lib/Couchbase/MockServer.pm
@@ -98,14 +98,17 @@ sub _do_run {
if($pid) {
#Parent: setup harakiri monitoring socket
- $self->pid($pid);
sleep(0.05);
if(waitpid($pid, WNOHANG) > 0) {
die("Child process died prematurely");
}
log_info("Launched CouchbaseMock PID=$pid");
+ #$self->pid(getpgrp($pid));
+ $self->pid($pid);
$self->_accept_harakiri();
} else {
+
+ setpgrp(0, 0);
log_warnf("Executing %s", join(" ", @command));
exec(@command);
warn"exec @command failed: $!";
@@ -143,13 +146,13 @@ sub suspend_process {
my $self = shift;
my $pid = $self->pid;
return unless defined $pid;
- kill SIGSTOP, $pid;
+ kill SIGSTOP, -(getpgrp($pid));
}
sub resume_process {
my $self = shift;
my $pid = $self->pid;
return unless defined $pid;
- kill SIGCONT, $pid;
+ kill SIGCONT, -(getpgrp($pid));
}
sub failover_node {
View
5 lib/Couchbase/Test/Async.pm
@@ -24,6 +24,11 @@ my $can_async = eval {
if(!$can_async) {
__PACKAGE__->SKIP_CLASS("Can't run async tests: $@");
}
+
+if($^O eq 'netbsd') {
+ __PACKAGE__->SKIP_CLASS("Skipping Async tests on netbsd ".
+ "due to weird kernel bug");
+}
$poe_kernel->run();
View
42 lib/Couchbase/Test/Interop.pm
@@ -73,7 +73,9 @@ sub _setup_client :Test(startup) {
note "Have $memd_host";
- my $memd = $MEMD_CLASS->new({servers => [ $memd_host] });
+ my $memd = $MEMD_CLASS->new({servers => [ $memd_host] ,
+ compress_threshold => 100,
+ });
$self->memd($memd);
if($memd->can('set_binary_protocol')) {
$memd->set_binary_protocol(1);
@@ -116,6 +118,44 @@ sub T32_interop_compression :Test(no_plan) {
my $self = shift;
my $key = "Compressed";
my $value = "foobarbaz" x 1000;
+ #return;
+
+ $self->memd->set_compress_threshold(100);
+ $self->memd->set_compress_enable(1);
+
+ diag "Hacking into unexposed Cache::Memcached::libmemcached methods";
+ $self->memd->{compress_savingsS} = 500;
+
+ ok($self->memd->get_compress_enable, "Compression is enabled via memd");
+ ok($self->memd->get_compress_threshold < length($value),
+ "compression threshold is set to <length(value)");
+
+
+ ok($self->memd->set($key, $value), "Set compressed value via memd");
+
+ ok($self->cbo->deconversion_settings, "Deconversion enabled");
+ $self->cbo->deconversion_settings(0);
+ ok(!$self->cbo->deconversion_settings, "Deconversion now disabled");
+ $self->cbo->enable_compress(0);
+
+
+ my $ret = $self->cbo->get($key);
+ ok($ret->is_ok, "Got value via cbo");
+ #diag $ret->value;
+
+ ok(length($ret->value) != length($value),
+ "got compressed value (comp_len < real_len)");
+
+ $self->cbo->deconversion_settings(1);
+ $self->cbo->enable_compress(1);
+
+ $ret = $self->cbo->get($key);
+ ok($ret->is_ok, "Re-got value via cbo");
+ if(!$ret->is_ok) {
+ diag("ERR ", $ret->errstr);
+ return;
+ }
+ is($ret->value, $value, "Decompressed to same value");
}
1;
View
40 src/Makefile.PL
@@ -11,16 +11,19 @@ use Dir::Self;
use Data::Dumper;
use File::Spec;
use Dir::Self;
+use Config;
use Cwd qw(abs_path);
use lib (__DIR__ . '/..');
my $Sharepath = File::Spec->catfile(
- 'auto', 'share', 'dist', 'Couchbase-Client','Libary');
+ 'auto', 'share', 'dist', 'Couchbase-Client', 'Library');
require ExtUtils::Liblist;
+my $LIBCOUCHBASE = "libcouchbase";
+
my $PARENT_MM;
my $SEARCHPATH_S;
@@ -158,11 +161,6 @@ sub create_buildscript_invocation {
$mm->quote_literal($mm->{LD_RUN_PATH})) . "\\",
"\t\t".join(" ", @$deps)
-
-
- #end long commandline invocation
- #"\t".'$(MKPATH) ' . $build,
- #"\t".'$(TOUCH) $@',
);
return @lines;
@@ -170,6 +168,21 @@ sub create_buildscript_invocation {
}
+sub ldrunpath2rpath {
+ my ($parent, $ld_run_path) = @_;
+ # check if Perl has -rpath in its own flags:
+ # inspired by Tony Cook:
+ # http://git.imager.perl.org/imager.git/blob/HEAD:/lib/Imager/Probe.pm#l281
+
+ return unless ($Config{lddlflags} =~ /([^ ]*-(?:rpath|R)[,=]?)([^ ]+)/
+ && -d $2);
+
+ my $prefix = $1;
+ my $existing_flags = $parent->{LDDLFLAGS};
+ my @components = map { "$prefix$_" } split($Config{path_sep}, $ld_run_path);
+ $parent->{LDDLFLAGS} = join(" ", @components) . " " . $Config{lddlflags};
+ log_warn("Mangled compiler line now is: ", $parent->{LDDLFLAGS});
+}
sub mangle_parent_makefile {
my ($parent,$deps) = @_;
@@ -185,7 +198,7 @@ sub mangle_parent_makefile {
my $blib_dep_path = "\$(INST_LIB)\$(DFSEP)$Sharepath";
my $dest_dep_path = "\$(DESTINSTALLSITELIB)\$(DFSEP)$Sharepath";
- my $dep = "$blib_dep_path\$(DFSEP)lib\$(DFSEP)libcouchbase.\$(SO)";
+ my $dep = "$blib_dep_path\$(DFSEP)lib\$(DFSEP)$LIBCOUCHBASE.\$(SO)";
$parent->{MYEXTLIB} = $dep;
@@ -203,12 +216,12 @@ sub mangle_parent_makefile {
my $ldload = $parent->{LDLOADLIBS} || "";
my $runpath = $parent->{LD_RUN_PATH} || "";
-
$runpath = "$blib_dep_path\$(DFSEP)lib:" .
"$dest_dep_path\$(DFSEP)lib".
":$runpath";
$ldload = "-L$blib_dep_path\$(DFSEP)lib";
+
{
my $parent_dir = abs_path("..");
$parent->{INST_LIB} = File::Spec->catfile($parent_dir,
@@ -218,6 +231,8 @@ sub mangle_parent_makefile {
$parent->{LDLOADLIBS} = $ldload;
$parent->{LD_RUN_PATH} = $runpath;
+ ldrunpath2rpath($parent, $runpath);
+
$parent->{INC} .= " -I$blib_dep_path\$(DFSEP)include";
@@ -225,18 +240,9 @@ sub mangle_parent_makefile {
my $inc_oneliner = sprintf("PLCB_ConfUtil::write_tmpflags(qq{%s})",
$parent_inc);
-
no warnings qw(redefine once);
*MY::postamble = sub {
my @lines = (
- #get an absolute reference to $(INST_LIB)
-
- #"INST_LIB := ".
- #'$(shell '.
- # $parent->oneliner('print abs_path("$(INST_LIB)")',
- # [ '-MCwd=abs_path' ])
- #.' )',
-
"$dep:",
(insert_announcement("will build for ultimate target $dep")),
(create_buildscript_invocation($parent,
View
57 xs/ctor.c
@@ -19,6 +19,35 @@ if( (tmp = av_fetch(options, opt_idx, 0)) && SvTRUE(*tmp) ) { \
#undef _assign_options
}
+static void ctor_extract_methpairs(AV *options,
+ int idx, SV **outmeth, SV **inmeth)
+{
+ SV **tmpsv;
+ AV *methav;
+ int ii;
+
+ SV **assgn_array[] = { outmeth, inmeth };
+
+ *outmeth = *inmeth = NULL;
+ if ( (tmpsv = av_fetch(options, idx, 0)) == NULL ) {
+ return;
+ }
+
+ if (SvROK(*tmpsv) == 0 ||
+ ((methav = (AV*)SvRV(*tmpsv)) && SvTYPE(methav) != SVt_PVAV) ||
+ av_len(methav) != 1) {
+ die("Expected an array reference with two elements");
+ }
+
+ for (ii = 0; ii < 2; ii++) {
+ tmpsv = av_fetch(methav, ii, 0);
+ if(SvROK(*tmpsv) == 0 || SvTYPE(SvRV(*tmpsv)) != SVt_PVCV) {
+ die("Expected code reference.");
+ }
+ *(assgn_array[ii]) = newRV_inc(SvRV(*tmpsv));
+ }
+}
+
void plcb_ctor_conversion_opts(PLCB_t *object, AV *options)
{
SV **tmpsv;
@@ -48,20 +77,26 @@ void plcb_ctor_conversion_opts(PLCB_t *object, AV *options)
object->my_flags = SvUV(*tmpsv);
}
- if(meth_assert_getpairs(PLCBf_USE_COMPRESSION,
- PLCB_CTORIDX_COMP_METHODS)) {
- meth_assert_assign(cv_compress, 0, "Compression");
- meth_assert_assign(cv_decompress, 1, "Decompression");
- }
+ ctor_extract_methpairs(options, PLCB_CTORIDX_COMP_METHODS,
+ &object->cv_compress, &object->cv_decompress);
- if(meth_assert_getpairs(PLCBf_USE_STORABLE,
- PLCB_CTORIDX_SERIALIZE_METHODS)) {
- meth_assert_assign(cv_serialize, 0, "Serialize");
- meth_assert_assign(cv_deserialize, 1, "Deserialize");
-
+ if ((object->my_flags & PLCBf_USE_COMPRESSION) &&
+ object->cv_compress == NULL) {
+
+ die("Compression requested but no methods provided");
}
- if( (tmpsv = av_fetch(options, PLCB_CTORIDX_COMP_THRESHOLD, 0))
+
+ ctor_extract_methpairs(options, PLCB_CTORIDX_SERIALIZE_METHODS,
+ &object->cv_serialize, &object->cv_deserialize);
+
+ if ((object->my_flags & PLCBf_USE_STORABLE) &&
+ object->cv_serialize == NULL) {
+
+ die("Serialization requested but no methods provided");
+ }
+
+ if ((tmpsv = av_fetch(options, PLCB_CTORIDX_COMP_THRESHOLD, 0))
&& SvIOK(*tmpsv)) {
object->compress_threshold = SvIV(*tmpsv);
} else {
View
4 xs/perl-couchbase.h
@@ -13,8 +13,8 @@
#if IVSIZE >= 8
#define PLCB_PERL64
-#else
-#error "Perl needs 64 bit integer support"
+//#else
+//#error "Perl needs 64 bit integer support"
#endif
#ifndef mXPUSHs
View
10 xs/plcb-return.h
@@ -35,7 +35,15 @@ static inline void
plcb_ret_set_numval(PLCB_t *obj, AV *ret, uint64_t value, uint64_t cas)
{
SV *isv = newSV(0);
- plcb_sv_from_u64(isv, value);
+#ifdef PLCB_PERL64
+ sv_setuv(isv, value);
+#else
+ if (value < UINT32_MAX) {
+ sv_setuv(isv, value);
+ } else {
+ sv_setpvf(isv, "%llu", value);
+ }
+#endif
av_store(ret, PLCB_RETIDX_VALUE, isv);
plcb_ret_set_cas(obj, ret, &cas);
}
View
8 xs/plcb-util.h
@@ -33,6 +33,12 @@ static inline uint64_t plcb_sv_to_u64(SV *in)
char *sv_blob;
STRLEN blob_len;
uint64_t ret;
+
+ if(SvIOK(in)) {
+ /*Numeric*/
+ return SvUV(in);
+ }
+
sv_blob = SvPV(in, blob_len);
if(blob_len != 8) {
die("expected 8-byte data string. Got %d", blob_len);
@@ -40,7 +46,7 @@ static inline uint64_t plcb_sv_to_u64(SV *in)
ret = *(uint64_t*)sv_blob;
return ret;
}
-#define plcb_sv_to_64(sv) (plcb_sv_to_u64(sv))
+#define plcb_sv_to_64(sv) ((int64_t)(plcb_sv_to_u64(sv)))
#define plcb_sv_from_u64(sv, num) \
(sv_setpvn(sv, (const char const*)&(num), 8))
Please sign in to comment.
Something went wrong with that request. Please try again.