This commit is contained in:
Evan Weaver 2010-03-01 21:17:56 -08:00
Родитель b285889b88
Коммит da94c05bc6
5 изменённых файлов: 11667 добавлений и 7601 удалений

Просмотреть файл

@ -18,7 +18,6 @@ end
if !ENV["EXTERNAL_LIB"]
$includes = " -I#{HERE}/include"
$defines = " -DLIBMEMCACHED_WITH_SASL_SUPPORT"
$libraries = " -L#{HERE}/lib"
$CFLAGS = "#{$includes} #{$libraries} #{$CFLAGS}"
$LDFLAGS = "#{$libraries} #{$LDFLAGS}"
@ -62,7 +61,7 @@ end
if ENV['SWIG']
puts "Running SWIG."
puts(cmd = "swig #{$defines} #{$includes} -ruby -autorename rlibmemcached.i")
puts(cmd = "swig #{$includes} -ruby -autorename rlibmemcached.i")
raise "'#{cmd}' failed" unless system(cmd)
end

Просмотреть файл

@ -1,7 +1,6 @@
%module rlibmemcached
%{
#include <sasl/sasl.h>
#include <libmemcached/visibility.h>
#include <libmemcached/memcached.h>
%}
@ -15,7 +14,7 @@
%include "libmemcached/visibility.h"
// Register libmemcached's struct free function to prevent memory leaks
%freefunc memcached_st "memcached_free";
// %freefunc memcached_st "memcached_free";
%freefunc memcached_server_st "memcached_server_free";
// %trackobjects; // Doesn't fix any interesting leaks
@ -23,7 +22,7 @@
//// Input maps
%apply unsigned short { uint8_t };
%apply unsigned int { uint16_t };
%apply unsigned int { uint16_t, in_port_t };
%apply unsigned long { uint32_t flags, uint32_t offset, uint32_t weight };
%apply unsigned long long { uint64_t data, uint64_t cas };
@ -137,14 +136,34 @@
//// SWIG includes, for functions, constants, and structs
%include "libmemcached/configure.h"
%include "libmemcached/types.h"
%include "libmemcached/visibility.h"
%include "libmemcached/memcached.h"
%include "libmemcached/allocators.h"
%include "libmemcached/analyze.h"
%include "libmemcached/auto.h"
%include "libmemcached/behavior.h"
%include "libmemcached/callback.h"
%include "libmemcached/constants.h"
%include "libmemcached/delete.h"
%include "libmemcached/dump.h"
%include "libmemcached/fetch.h"
%include "libmemcached/flush.h"
%include "libmemcached/get.h"
%include "libmemcached/storage.h"
%include "libmemcached/hash.h"
%include "libmemcached/parse.h"
%include "libmemcached/quit.h"
%include "libmemcached/result.h"
%include "libmemcached/server.h"
%include "libmemcached/sasl.h"
%include "libmemcached/server.h"
%include "libmemcached/server_list.h"
%include "libmemcached/stats.h"
%include "libmemcached/storage.h"
%include "libmemcached/strerror.h"
%include "libmemcached/string.h"
%include "libmemcached/verbosity.h"
%include "libmemcached/version.h"
//// Custom C functions
@ -201,7 +220,7 @@ VALUE memcached_stat_get_rvalue(memcached_st *ptr, memcached_stat_st *stat, char
memcached_server_st *memcached_select_server_at(memcached_st *in_ptr, int index);
%{
memcached_server_st *memcached_select_server_at(memcached_st *in_ptr, int index) {
return &(in_ptr->hosts[index]);
return &(in_ptr->servers[index]);
};
%}

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -20,7 +20,7 @@ require 'rlibmemcached'
class Memcached
Lib = Rlibmemcached
raise "libmemcached 0.35 required; you somehow linked to #{Lib.memcached_lib_version}." unless "0.35" == Lib.memcached_lib_version
raise "libmemcached 0.38 required; you somehow linked to #{Lib.memcached_lib_version}." unless "0.38" == Lib.memcached_lib_version
VERSION = File.read("#{File.dirname(__FILE__)}/../CHANGELOG")[/v([\d\.]+)\./, 1]
end

Просмотреть файл

@ -85,16 +85,14 @@ Please note that when pipelining is enabled, setter and deleter methods do not r
def self.finalize(id)
# Don't leak clients!
struct = @@structs[id]
@@structs.delete(id)
# Don't leak authentication data either. This will silently fail if it's not set.
Lib.memcached_destroy_sasl_auth_data(struct)
Lib.memcached_free(struct)
if struct = @@structs.delete(id)
Lib.memcached_destroy_sasl_auth_data(struct)
Lib.memcached_free(struct)
end
end
def initialize(servers = nil, opts = {})
@struct = Lib::MemcachedSt.new
Lib.memcached_create(@struct)
@struct = Lib.memcached_create(@struct)
@@structs[object_id] = @struct
# Merge option defaults and discard meaningless keys
@ -236,8 +234,7 @@ Please note that when pipelining is enabled, setter and deleter methods do not r
# Create
# FIXME Duplicates logic with initialize()
@struct = Lib::MemcachedSt.new
Lib.memcached_create(@struct)
@struct = Lib.memcached_create(@struct)
@@structs[object_id] = @struct
set_prefix_key(prev_prefix_key) if with_prefix_key
set_behaviors
@ -280,8 +277,8 @@ Please note that when pipelining is enabled, setter and deleter methods do not r
# Return an array of raw <tt>memcached_host_st</tt> structs for this instance.
def server_structs
array = []
if @struct.hosts
@struct.hosts.count.times do |i|
if @struct.servers
@struct.number_of_hosts.times do |i|
array << Lib.memcached_select_server_at(@struct, i)
end
end