vinted-memcached 1.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/BENCHMARKS +142 -0
- data/CHANGELOG +176 -0
- data/Gemfile +11 -0
- data/Gemfile.lock +45 -0
- data/LICENSE +184 -0
- data/Manifest +209 -0
- data/README.rdoc +124 -0
- data/Rakefile +134 -0
- data/TODO +1 -0
- data/ext/extconf-make.rb +25 -0
- data/ext/extconf.rb +78 -0
- data/ext/libmemcached-0.32/AUTHORS +7 -0
- data/ext/libmemcached-0.32/COPYING +32 -0
- data/ext/libmemcached-0.32/ChangeLog +303 -0
- data/ext/libmemcached-0.32/INSTALL +302 -0
- data/ext/libmemcached-0.32/Makefile.am +36 -0
- data/ext/libmemcached-0.32/Makefile.in +911 -0
- data/ext/libmemcached-0.32/NEWS +1 -0
- data/ext/libmemcached-0.32/README +33 -0
- data/ext/libmemcached-0.32/THANKS +14 -0
- data/ext/libmemcached-0.32/TODO +11 -0
- data/ext/libmemcached-0.32/aclocal.m4 +2108 -0
- data/ext/libmemcached-0.32/clients/Makefile.am +80 -0
- data/ext/libmemcached-0.32/clients/Makefile.in +773 -0
- data/ext/libmemcached-0.32/clients/client_options.h +32 -0
- data/ext/libmemcached-0.32/clients/execute.c +64 -0
- data/ext/libmemcached-0.32/clients/execute.h +5 -0
- data/ext/libmemcached-0.32/clients/generator.c +74 -0
- data/ext/libmemcached-0.32/clients/generator.h +20 -0
- data/ext/libmemcached-0.32/clients/memcat.c +178 -0
- data/ext/libmemcached-0.32/clients/memcp.c +251 -0
- data/ext/libmemcached-0.32/clients/memdump.c +170 -0
- data/ext/libmemcached-0.32/clients/memerror.c +80 -0
- data/ext/libmemcached-0.32/clients/memflush.c +143 -0
- data/ext/libmemcached-0.32/clients/memrm.c +160 -0
- data/ext/libmemcached-0.32/clients/memslap.c +441 -0
- data/ext/libmemcached-0.32/clients/memstat.c +326 -0
- data/ext/libmemcached-0.32/clients/utilities.c +207 -0
- data/ext/libmemcached-0.32/clients/utilities.h +41 -0
- data/ext/libmemcached-0.32/config/compile +143 -0
- data/ext/libmemcached-0.32/config/config.guess +1561 -0
- data/ext/libmemcached-0.32/config/config.rpath +666 -0
- data/ext/libmemcached-0.32/config/config.sub +1686 -0
- data/ext/libmemcached-0.32/config/depcomp +630 -0
- data/ext/libmemcached-0.32/config/install-sh +520 -0
- data/ext/libmemcached-0.32/config/ltmain.sh +9636 -0
- data/ext/libmemcached-0.32/config/missing +376 -0
- data/ext/libmemcached-0.32/config.h.in +254 -0
- data/ext/libmemcached-0.32/configure +23843 -0
- data/ext/libmemcached-0.32/configure.ac +120 -0
- data/ext/libmemcached-0.32/libmemcached/Makefile.am +111 -0
- data/ext/libmemcached-0.32/libmemcached/Makefile.in +1069 -0
- data/ext/libmemcached-0.32/libmemcached/byteorder.c +31 -0
- data/ext/libmemcached-0.32/libmemcached/common.h +189 -0
- data/ext/libmemcached-0.32/libmemcached/crc.c +86 -0
- data/ext/libmemcached-0.32/libmemcached/hsieh_hash.c +68 -0
- data/ext/libmemcached-0.32/libmemcached/jenkins_hash.c +213 -0
- data/ext/libmemcached-0.32/libmemcached/libmemcached.ver +1 -0
- data/ext/libmemcached-0.32/libmemcached/libmemcached_probes.d +30 -0
- data/ext/libmemcached-0.32/libmemcached/libmemcached_probes.h +82 -0
- data/ext/libmemcached-0.32/libmemcached/md5.c +354 -0
- data/ext/libmemcached-0.32/libmemcached/memcached/README.txt +7 -0
- data/ext/libmemcached-0.32/libmemcached/memcached/protocol_binary.h +385 -0
- data/ext/libmemcached-0.32/libmemcached/memcached.c +153 -0
- data/ext/libmemcached-0.32/libmemcached/memcached.h +305 -0
- data/ext/libmemcached-0.32/libmemcached/memcached.hpp +799 -0
- data/ext/libmemcached-0.32/libmemcached/memcached_allocators.c +72 -0
- data/ext/libmemcached-0.32/libmemcached/memcached_analyze.c +100 -0
- data/ext/libmemcached-0.32/libmemcached/memcached_auto.c +207 -0
- data/ext/libmemcached-0.32/libmemcached/memcached_behavior.c +290 -0
- data/ext/libmemcached-0.32/libmemcached/memcached_callback.c +175 -0
- data/ext/libmemcached-0.32/libmemcached/memcached_configure.h.in +23 -0
- data/ext/libmemcached-0.32/libmemcached/memcached_connect.c +371 -0
- data/ext/libmemcached-0.32/libmemcached/memcached_constants.h +146 -0
- data/ext/libmemcached-0.32/libmemcached/memcached_delete.c +0 -0
- data/ext/libmemcached-0.32/libmemcached/memcached_do.c +72 -0
- data/ext/libmemcached-0.32/libmemcached/memcached_dump.c +79 -0
- data/ext/libmemcached-0.32/libmemcached/memcached_exist.c +114 -0
- data/ext/libmemcached-0.32/libmemcached/memcached_exist.h +20 -0
- data/ext/libmemcached-0.32/libmemcached/memcached_fetch.c +102 -0
- data/ext/libmemcached-0.32/libmemcached/memcached_flush.c +89 -0
- data/ext/libmemcached-0.32/libmemcached/memcached_flush_buffers.c +23 -0
- data/ext/libmemcached-0.32/libmemcached/memcached_get.c +494 -0
- data/ext/libmemcached-0.32/libmemcached/memcached_get.h +87 -0
- data/ext/libmemcached-0.32/libmemcached/memcached_hash.c +252 -0
- data/ext/libmemcached-0.32/libmemcached/memcached_hosts.c +510 -0
- data/ext/libmemcached-0.32/libmemcached/memcached_internal.h +31 -0
- data/ext/libmemcached-0.32/libmemcached/memcached_io.c +594 -0
- data/ext/libmemcached-0.32/libmemcached/memcached_io.h +72 -0
- data/ext/libmemcached-0.32/libmemcached/memcached_key.c +28 -0
- data/ext/libmemcached-0.32/libmemcached/memcached_parse.c +74 -0
- data/ext/libmemcached-0.32/libmemcached/memcached_pool.h +38 -0
- data/ext/libmemcached-0.32/libmemcached/memcached_purge.c +76 -0
- data/ext/libmemcached-0.32/libmemcached/memcached_quit.c +75 -0
- data/ext/libmemcached-0.32/libmemcached/memcached_response.c +529 -0
- data/ext/libmemcached-0.32/libmemcached/memcached_result.c +57 -0
- data/ext/libmemcached-0.32/libmemcached/memcached_result.h +59 -0
- data/ext/libmemcached-0.32/libmemcached/memcached_sasl.c +225 -0
- data/ext/libmemcached-0.32/libmemcached/memcached_sasl.h +44 -0
- data/ext/libmemcached-0.32/libmemcached/memcached_server.c +159 -0
- data/ext/libmemcached-0.32/libmemcached/memcached_server.h +93 -0
- data/ext/libmemcached-0.32/libmemcached/memcached_stats.c +437 -0
- data/ext/libmemcached-0.32/libmemcached/memcached_storage.c +514 -0
- data/ext/libmemcached-0.32/libmemcached/memcached_storage.h +107 -0
- data/ext/libmemcached-0.32/libmemcached/memcached_strerror.c +92 -0
- data/ext/libmemcached-0.32/libmemcached/memcached_string.c +138 -0
- data/ext/libmemcached-0.32/libmemcached/memcached_string.h +53 -0
- data/ext/libmemcached-0.32/libmemcached/memcached_touch.c +60 -0
- data/ext/libmemcached-0.32/libmemcached/memcached_touch.h +31 -0
- data/ext/libmemcached-0.32/libmemcached/memcached_types.h +44 -0
- data/ext/libmemcached-0.32/libmemcached/memcached_util.h +15 -0
- data/ext/libmemcached-0.32/libmemcached/memcached_verbosity.c +36 -0
- data/ext/libmemcached-0.32/libmemcached/memcached_version.c +112 -0
- data/ext/libmemcached-0.32/libmemcached/memcached_watchpoint.h +38 -0
- data/ext/libmemcached-0.32/libmemcached/murmur_hash.c +76 -0
- data/ext/libmemcached-0.32/libmemcached/visibility.h +51 -0
- data/ext/libmemcached-0.32/libmemcachedutil/Makefile.am +11 -0
- data/ext/libmemcached-0.32/libmemcachedutil/Makefile.in +604 -0
- data/ext/libmemcached-0.32/libmemcachedutil/libmemcachedutil.ver +1 -0
- data/ext/libmemcached-0.32/libmemcachedutil/memcached_pool.c +170 -0
- data/ext/libmemcached-0.32/m4/ac_cxx_compile_stdcxx_0x.m4 +103 -0
- data/ext/libmemcached-0.32/m4/ac_cxx_header_stdcxx_98.m4 +67 -0
- data/ext/libmemcached-0.32/m4/acx_pthread.m4 +276 -0
- data/ext/libmemcached-0.32/m4/byteorder.m4 +40 -0
- data/ext/libmemcached-0.32/m4/deprecated.m4 +17 -0
- data/ext/libmemcached-0.32/m4/enable_utillib.m4 +16 -0
- data/ext/libmemcached-0.32/m4/extensions.m4 +94 -0
- data/ext/libmemcached-0.32/m4/hsieh.m4 +18 -0
- data/ext/libmemcached-0.32/m4/lib-prefix.m4 +221 -0
- data/ext/libmemcached-0.32/m4/libtool.m4 +7831 -0
- data/ext/libmemcached-0.32/m4/ltoptions.m4 +369 -0
- data/ext/libmemcached-0.32/m4/ltsugar.m4 +123 -0
- data/ext/libmemcached-0.32/m4/ltversion.m4 +23 -0
- data/ext/libmemcached-0.32/m4/lt~obsolete.m4 +98 -0
- data/ext/libmemcached-0.32/m4/memcached.m4 +30 -0
- data/ext/libmemcached-0.32/m4/pandora_64bit.m4 +55 -0
- data/ext/libmemcached-0.32/m4/pandora_canonical.m4 +151 -0
- data/ext/libmemcached-0.32/m4/pandora_check_compiler_version.m4 +37 -0
- data/ext/libmemcached-0.32/m4/pandora_check_cxx_standard.m4 +16 -0
- data/ext/libmemcached-0.32/m4/pandora_enable_dtrace.m4 +41 -0
- data/ext/libmemcached-0.32/m4/pandora_ensure_gcc_version.m4 +36 -0
- data/ext/libmemcached-0.32/m4/pandora_have_better_malloc.m4 +54 -0
- data/ext/libmemcached-0.32/m4/pandora_have_sasl.m4 +133 -0
- data/ext/libmemcached-0.32/m4/pandora_header_assert.m4 +23 -0
- data/ext/libmemcached-0.32/m4/pandora_libtool.m4 +15 -0
- data/ext/libmemcached-0.32/m4/pandora_optimize.m4 +79 -0
- data/ext/libmemcached-0.32/m4/pandora_shared_ptr.m4 +56 -0
- data/ext/libmemcached-0.32/m4/pandora_vc_build.m4 +32 -0
- data/ext/libmemcached-0.32/m4/pandora_warnings.m4 +262 -0
- data/ext/libmemcached-0.32/m4/pod2man.m4 +7 -0
- data/ext/libmemcached-0.32/m4/protocol_binary.m4 +23 -0
- data/ext/libmemcached-0.32/m4/setsockopt.m4 +57 -0
- data/ext/libmemcached-0.32/m4/visibility.m4 +52 -0
- data/ext/libmemcached-0.32/support/Makefile.am +4 -0
- data/ext/libmemcached-0.32/support/Makefile.in +487 -0
- data/ext/libmemcached-0.32/support/libmemcached-fc.spec.in +105 -0
- data/ext/libmemcached-0.32/support/libmemcached.pc.in +10 -0
- data/ext/libmemcached-0.32/support/libmemcached.spec +105 -0
- data/ext/libmemcached-0.32/support/libmemcached.spec.in +105 -0
- data/ext/libmemcached-0.32/support/set_benchmark.sh +5 -0
- data/ext/libmemcached-0.32/tests/Makefile.am +113 -0
- data/ext/libmemcached-0.32/tests/Makefile.in +762 -0
- data/ext/libmemcached-0.32/tests/atomsmasher.c +245 -0
- data/ext/libmemcached-0.32/tests/function.c +4904 -0
- data/ext/libmemcached-0.32/tests/ketama_test_cases.h +108 -0
- data/ext/libmemcached-0.32/tests/output.cmp +7 -0
- data/ext/libmemcached-0.32/tests/output.res +7 -0
- data/ext/libmemcached-0.32/tests/output2.res +46 -0
- data/ext/libmemcached-0.32/tests/plus.cpp +293 -0
- data/ext/libmemcached-0.32/tests/r/memcat.res +19 -0
- data/ext/libmemcached-0.32/tests/r/memcp.res +27 -0
- data/ext/libmemcached-0.32/tests/r/memrm.res +19 -0
- data/ext/libmemcached-0.32/tests/r/memslap.res +33 -0
- data/ext/libmemcached-0.32/tests/r/memstat.res +33 -0
- data/ext/libmemcached-0.32/tests/server.c +118 -0
- data/ext/libmemcached-0.32/tests/server.h +25 -0
- data/ext/libmemcached-0.32/tests/start.c +16 -0
- data/ext/libmemcached-0.32/tests/t/memcat.test +4 -0
- data/ext/libmemcached-0.32/tests/t/memcp.test +3 -0
- data/ext/libmemcached-0.32/tests/t/memrm.test +3 -0
- data/ext/libmemcached-0.32/tests/t/memslap.test +5 -0
- data/ext/libmemcached-0.32/tests/t/memstat.test +3 -0
- data/ext/libmemcached-0.32/tests/test.c +137 -0
- data/ext/libmemcached-0.32/tests/test.h +46 -0
- data/ext/libmemcached-0.32/tests/udp.c +76 -0
- data/ext/rlibmemcached.i +258 -0
- data/ext/rlibmemcached_wrap.c +13917 -0
- data/lib/memcached/auth.rb +16 -0
- data/lib/memcached/behaviors.rb +78 -0
- data/lib/memcached/exceptions.rb +84 -0
- data/lib/memcached/experimental.rb +48 -0
- data/lib/memcached/marshal_codec.rb +10 -0
- data/lib/memcached/memcached.rb +732 -0
- data/lib/memcached/rails.rb +250 -0
- data/lib/memcached.rb +33 -0
- data/memcached.gemspec +0 -0
- data/test/profile/benchmark.rb +280 -0
- data/test/profile/c_profiler.rb +14 -0
- data/test/profile/exercise.rb +185 -0
- data/test/profile/rb_profiler.rb +21 -0
- data/test/profile/valgrind.rb +10 -0
- data/test/setup.rb +30 -0
- data/test/teardown.rb +0 -0
- data/test/test_helper.rb +18 -0
- data/test/unit/binding_test.rb +8 -0
- data/test/unit/memcached_experimental_test.rb +272 -0
- data/test/unit/memcached_test.rb +1487 -0
- data/test/unit/rails_test.rb +330 -0
- metadata +336 -0
|
@@ -0,0 +1,326 @@
|
|
|
1
|
+
#include "libmemcached/common.h"
|
|
2
|
+
#include <stdio.h>
|
|
3
|
+
#include <sys/types.h>
|
|
4
|
+
#include <sys/stat.h>
|
|
5
|
+
#include <sys/types.h>
|
|
6
|
+
#include <sys/mman.h>
|
|
7
|
+
#include <fcntl.h>
|
|
8
|
+
#include <string.h>
|
|
9
|
+
#include <getopt.h>
|
|
10
|
+
#include <sys/time.h>
|
|
11
|
+
|
|
12
|
+
#include <libmemcached/memcached.h>
|
|
13
|
+
|
|
14
|
+
#include "client_options.h"
|
|
15
|
+
#include "utilities.h"
|
|
16
|
+
|
|
17
|
+
#define PROGRAM_NAME "memstat"
|
|
18
|
+
#define PROGRAM_DESCRIPTION "Output the state of a memcached cluster."
|
|
19
|
+
|
|
20
|
+
/* Prototypes */
|
|
21
|
+
static void options_parse(int argc, char *argv[]);
|
|
22
|
+
static void run_analyzer(memcached_st *memc, memcached_stat_st *memc_stat,
|
|
23
|
+
memcached_server_st *server_list);
|
|
24
|
+
static void print_server_listing(memcached_st *memc, memcached_stat_st *memc_stat,
|
|
25
|
+
memcached_server_st *server_list);
|
|
26
|
+
static void print_analysis_report(memcached_st *memc,
|
|
27
|
+
memcached_analysis_st *report,
|
|
28
|
+
memcached_server_st *server_list);
|
|
29
|
+
|
|
30
|
+
static int opt_verbose= 0;
|
|
31
|
+
static int opt_displayflag= 0;
|
|
32
|
+
static int opt_analyze= 0;
|
|
33
|
+
static char *opt_servers= NULL;
|
|
34
|
+
static char *analyze_mode= NULL;
|
|
35
|
+
|
|
36
|
+
static struct option long_options[]=
|
|
37
|
+
{
|
|
38
|
+
{(OPTIONSTRING)"version", no_argument, NULL, OPT_VERSION},
|
|
39
|
+
{(OPTIONSTRING)"help", no_argument, NULL, OPT_HELP},
|
|
40
|
+
{(OPTIONSTRING)"verbose", no_argument, &opt_verbose, OPT_VERBOSE},
|
|
41
|
+
{(OPTIONSTRING)"debug", no_argument, &opt_verbose, OPT_DEBUG},
|
|
42
|
+
{(OPTIONSTRING)"servers", required_argument, NULL, OPT_SERVERS},
|
|
43
|
+
{(OPTIONSTRING)"flag", no_argument, &opt_displayflag, OPT_FLAG},
|
|
44
|
+
{(OPTIONSTRING)"analyze", optional_argument, NULL, OPT_ANALYZE},
|
|
45
|
+
{0, 0, 0, 0},
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
int main(int argc, char *argv[])
|
|
49
|
+
{
|
|
50
|
+
memcached_return rc;
|
|
51
|
+
memcached_st *memc;
|
|
52
|
+
memcached_stat_st *memc_stat;
|
|
53
|
+
memcached_server_st *servers;
|
|
54
|
+
memcached_server_st *server_list;
|
|
55
|
+
|
|
56
|
+
options_parse(argc, argv);
|
|
57
|
+
|
|
58
|
+
if (!opt_servers)
|
|
59
|
+
{
|
|
60
|
+
char *temp;
|
|
61
|
+
|
|
62
|
+
if ((temp= getenv("MEMCACHED_SERVERS")))
|
|
63
|
+
opt_servers= strdup(temp);
|
|
64
|
+
else
|
|
65
|
+
{
|
|
66
|
+
fprintf(stderr, "No Servers provided\n\n");
|
|
67
|
+
help_command(PROGRAM_NAME, PROGRAM_DESCRIPTION, long_options, 0);
|
|
68
|
+
exit(1);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
memc= memcached_create(NULL);
|
|
73
|
+
|
|
74
|
+
servers= memcached_servers_parse(opt_servers);
|
|
75
|
+
memcached_server_push(memc, servers);
|
|
76
|
+
memcached_server_list_free(servers);
|
|
77
|
+
|
|
78
|
+
memc_stat= memcached_stat(memc, NULL, &rc);
|
|
79
|
+
|
|
80
|
+
if (rc != MEMCACHED_SUCCESS && rc != MEMCACHED_SOME_ERRORS)
|
|
81
|
+
{
|
|
82
|
+
printf("Failure to communicate with servers (%s)\n",
|
|
83
|
+
memcached_strerror(memc, rc));
|
|
84
|
+
exit(1);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
server_list= memcached_server_list(memc);
|
|
88
|
+
|
|
89
|
+
if (opt_analyze)
|
|
90
|
+
run_analyzer(memc, memc_stat, server_list);
|
|
91
|
+
else
|
|
92
|
+
print_server_listing(memc, memc_stat, server_list);
|
|
93
|
+
|
|
94
|
+
free(memc_stat);
|
|
95
|
+
free(opt_servers);
|
|
96
|
+
|
|
97
|
+
memcached_free(memc);
|
|
98
|
+
|
|
99
|
+
return 0;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
static void run_analyzer(memcached_st *memc, memcached_stat_st *memc_stat,
|
|
103
|
+
memcached_server_st *server_list)
|
|
104
|
+
{
|
|
105
|
+
memcached_return rc;
|
|
106
|
+
|
|
107
|
+
if (analyze_mode == NULL)
|
|
108
|
+
{
|
|
109
|
+
memcached_analysis_st *report;
|
|
110
|
+
report= memcached_analyze(memc, memc_stat, &rc);
|
|
111
|
+
if (rc != MEMCACHED_SUCCESS || report == NULL)
|
|
112
|
+
{
|
|
113
|
+
printf("Failure to analyze servers (%s)\n",
|
|
114
|
+
memcached_strerror(memc, rc));
|
|
115
|
+
exit(1);
|
|
116
|
+
}
|
|
117
|
+
print_analysis_report(memc, report, server_list);
|
|
118
|
+
free(report);
|
|
119
|
+
}
|
|
120
|
+
else if (strcmp(analyze_mode, "latency") == 0)
|
|
121
|
+
{
|
|
122
|
+
memcached_st **servers;
|
|
123
|
+
uint32_t x, y, flags, server_count= memcached_server_count(memc);
|
|
124
|
+
uint32_t num_of_tests= 32;
|
|
125
|
+
const char *test_key= "libmemcached_test_key";
|
|
126
|
+
|
|
127
|
+
servers= malloc(sizeof(memcached_st*) * server_count);
|
|
128
|
+
if (!servers)
|
|
129
|
+
{
|
|
130
|
+
fprintf(stderr, "Failed to allocate memory\n");
|
|
131
|
+
return;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
for (x= 0; x < server_count; x++)
|
|
135
|
+
{
|
|
136
|
+
if((servers[x]= memcached_create(NULL)) == NULL)
|
|
137
|
+
{
|
|
138
|
+
fprintf(stderr, "Failed to memcached_create()\n");
|
|
139
|
+
if (x > 0)
|
|
140
|
+
memcached_free(servers[0]);
|
|
141
|
+
x--;
|
|
142
|
+
for (; x > 0; x--)
|
|
143
|
+
memcached_free(servers[x]);
|
|
144
|
+
|
|
145
|
+
free(servers);
|
|
146
|
+
return;
|
|
147
|
+
}
|
|
148
|
+
memcached_server_add(servers[x],
|
|
149
|
+
memcached_server_name(memc, server_list[x]),
|
|
150
|
+
memcached_server_port(memc, server_list[x]));
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
printf("Network Latency Test:\n\n");
|
|
154
|
+
struct timeval start_time, end_time;
|
|
155
|
+
long elapsed_time, slowest_time= 0, slowest_server= 0;
|
|
156
|
+
|
|
157
|
+
for (x= 0; x < server_count; x++)
|
|
158
|
+
{
|
|
159
|
+
gettimeofday(&start_time, NULL);
|
|
160
|
+
for (y= 0; y < num_of_tests; y++)
|
|
161
|
+
{
|
|
162
|
+
size_t vlen;
|
|
163
|
+
char *val= memcached_get(servers[x], test_key, strlen(test_key),
|
|
164
|
+
&vlen, &flags, &rc);
|
|
165
|
+
if (rc != MEMCACHED_NOTFOUND && rc != MEMCACHED_SUCCESS)
|
|
166
|
+
break;
|
|
167
|
+
free(val);
|
|
168
|
+
}
|
|
169
|
+
gettimeofday(&end_time, NULL);
|
|
170
|
+
|
|
171
|
+
elapsed_time= timedif(end_time, start_time);
|
|
172
|
+
elapsed_time /= (long)num_of_tests;
|
|
173
|
+
|
|
174
|
+
if (elapsed_time > slowest_time)
|
|
175
|
+
{
|
|
176
|
+
slowest_server= (long)x;
|
|
177
|
+
slowest_time= elapsed_time;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
if (rc != MEMCACHED_NOTFOUND && rc != MEMCACHED_SUCCESS)
|
|
181
|
+
{
|
|
182
|
+
printf("\t %s (%d) => failed to reach the server\n",
|
|
183
|
+
memcached_server_name(memc, server_list[x]),
|
|
184
|
+
memcached_server_port(memc, server_list[x]));
|
|
185
|
+
}
|
|
186
|
+
else
|
|
187
|
+
{
|
|
188
|
+
printf("\t %s (%d) => %ld.%ld seconds\n",
|
|
189
|
+
memcached_server_name(memc, server_list[x]),
|
|
190
|
+
memcached_server_port(memc, server_list[x]),
|
|
191
|
+
elapsed_time / 1000, elapsed_time % 1000);
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
if (server_count > 1 && slowest_time > 0)
|
|
196
|
+
{
|
|
197
|
+
printf("---\n");
|
|
198
|
+
printf("Slowest Server: %s (%d) => %ld.%ld seconds\n",
|
|
199
|
+
memcached_server_name(memc, server_list[slowest_server]),
|
|
200
|
+
memcached_server_port(memc, server_list[slowest_server]),
|
|
201
|
+
slowest_time / 1000, slowest_time % 1000);
|
|
202
|
+
}
|
|
203
|
+
printf("\n");
|
|
204
|
+
|
|
205
|
+
for (x= 0; x < server_count; x++)
|
|
206
|
+
memcached_free(servers[x]);
|
|
207
|
+
|
|
208
|
+
free(servers);
|
|
209
|
+
free(analyze_mode);
|
|
210
|
+
}
|
|
211
|
+
else
|
|
212
|
+
{
|
|
213
|
+
fprintf(stderr, "Invalid Analyzer Option provided\n");
|
|
214
|
+
free(analyze_mode);
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
static void print_server_listing(memcached_st *memc, memcached_stat_st *memc_stat,
|
|
219
|
+
memcached_server_st *server_list)
|
|
220
|
+
{
|
|
221
|
+
unsigned int x;
|
|
222
|
+
memcached_return rc;
|
|
223
|
+
|
|
224
|
+
printf("Listing %u Server\n\n", memcached_server_count(memc));
|
|
225
|
+
for (x= 0; x < memcached_server_count(memc); x++)
|
|
226
|
+
{
|
|
227
|
+
char **list;
|
|
228
|
+
char **ptr;
|
|
229
|
+
|
|
230
|
+
list= memcached_stat_get_keys(memc, &memc_stat[x], &rc);
|
|
231
|
+
|
|
232
|
+
printf("Server: %s (%u)\n", memcached_server_name(memc, server_list[x]),
|
|
233
|
+
memcached_server_port(memc, server_list[x]));
|
|
234
|
+
for (ptr= list; *ptr; ptr++)
|
|
235
|
+
{
|
|
236
|
+
char *value= memcached_stat_get_value(memc, &memc_stat[x], *ptr, &rc);
|
|
237
|
+
|
|
238
|
+
printf("\t %s: %s\n", *ptr, value);
|
|
239
|
+
free(value);
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
free(list);
|
|
243
|
+
printf("\n");
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
static void print_analysis_report(memcached_st *memc,
|
|
248
|
+
memcached_analysis_st *report,
|
|
249
|
+
memcached_server_st *server_list)
|
|
250
|
+
{
|
|
251
|
+
uint32_t server_count= memcached_server_count(memc);
|
|
252
|
+
|
|
253
|
+
printf("Memcached Cluster Analysis Report\n\n");
|
|
254
|
+
|
|
255
|
+
printf("\tNumber of Servers Analyzed : %d\n", server_count);
|
|
256
|
+
printf("\tAverage Item Size (incl/overhead) : %u bytes\n",
|
|
257
|
+
report->average_item_size);
|
|
258
|
+
|
|
259
|
+
if (server_count == 1)
|
|
260
|
+
{
|
|
261
|
+
printf("\nFor a detailed report, you must supply multiple servers.\n");
|
|
262
|
+
return;
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
printf("\n");
|
|
266
|
+
printf("\tNode with most memory consumption : %s:%u (%llu bytes)\n",
|
|
267
|
+
memcached_server_name(memc, server_list[report->most_consumed_server]),
|
|
268
|
+
memcached_server_port(memc, server_list[report->most_consumed_server]),
|
|
269
|
+
(unsigned long long)report->most_used_bytes);
|
|
270
|
+
printf("\tNode with least free space : %s:%u (%llu bytes remaining)\n",
|
|
271
|
+
memcached_server_name(memc, server_list[report->least_free_server]),
|
|
272
|
+
memcached_server_port(memc, server_list[report->least_free_server]),
|
|
273
|
+
(unsigned long long)report->least_remaining_bytes);
|
|
274
|
+
printf("\tNode with longest uptime : %s:%u (%us)\n",
|
|
275
|
+
memcached_server_name(memc, server_list[report->oldest_server]),
|
|
276
|
+
memcached_server_port(memc, server_list[report->oldest_server]),
|
|
277
|
+
report->longest_uptime);
|
|
278
|
+
printf("\tPool-wide Hit Ratio : %1.f%%\n", report->pool_hit_ratio);
|
|
279
|
+
printf("\n");
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
static void options_parse(int argc, char *argv[])
|
|
283
|
+
{
|
|
284
|
+
memcached_programs_help_st help_options[]=
|
|
285
|
+
{
|
|
286
|
+
{0},
|
|
287
|
+
};
|
|
288
|
+
|
|
289
|
+
int option_index= 0;
|
|
290
|
+
int option_rv;
|
|
291
|
+
|
|
292
|
+
while (1)
|
|
293
|
+
{
|
|
294
|
+
option_rv= getopt_long(argc, argv, "Vhvds:a", long_options, &option_index);
|
|
295
|
+
if (option_rv == -1) break;
|
|
296
|
+
switch (option_rv)
|
|
297
|
+
{
|
|
298
|
+
case 0:
|
|
299
|
+
break;
|
|
300
|
+
case OPT_VERBOSE: /* --verbose or -v */
|
|
301
|
+
opt_verbose = OPT_VERBOSE;
|
|
302
|
+
break;
|
|
303
|
+
case OPT_DEBUG: /* --debug or -d */
|
|
304
|
+
opt_verbose = OPT_DEBUG;
|
|
305
|
+
break;
|
|
306
|
+
case OPT_VERSION: /* --version or -V */
|
|
307
|
+
version_command(PROGRAM_NAME);
|
|
308
|
+
break;
|
|
309
|
+
case OPT_HELP: /* --help or -h */
|
|
310
|
+
help_command(PROGRAM_NAME, PROGRAM_DESCRIPTION, long_options, help_options);
|
|
311
|
+
break;
|
|
312
|
+
case OPT_SERVERS: /* --servers or -s */
|
|
313
|
+
opt_servers= strdup(optarg);
|
|
314
|
+
break;
|
|
315
|
+
case OPT_ANALYZE: /* --analyze or -a */
|
|
316
|
+
opt_analyze= OPT_ANALYZE;
|
|
317
|
+
analyze_mode= (optarg) ? strdup(optarg) : NULL;
|
|
318
|
+
break;
|
|
319
|
+
case '?':
|
|
320
|
+
/* getopt_long already printed an error message. */
|
|
321
|
+
exit(1);
|
|
322
|
+
default:
|
|
323
|
+
abort();
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
}
|
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
#include "libmemcached/common.h"
|
|
2
|
+
#include <stdio.h>
|
|
3
|
+
#include <ctype.h>
|
|
4
|
+
#include <string.h>
|
|
5
|
+
#include "utilities.h"
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
long int timedif(struct timeval a, struct timeval b)
|
|
9
|
+
{
|
|
10
|
+
register int us, s;
|
|
11
|
+
|
|
12
|
+
us = (int)(a.tv_usec - b.tv_usec);
|
|
13
|
+
us /= 1000;
|
|
14
|
+
s = (int)(a.tv_sec - b.tv_sec);
|
|
15
|
+
s *= 1000;
|
|
16
|
+
return s + us;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
void version_command(const char *command_name)
|
|
20
|
+
{
|
|
21
|
+
printf("%s v%u.%u\n", command_name, 1, 0);
|
|
22
|
+
exit(0);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
static const char *lookup_help(memcached_options option)
|
|
26
|
+
{
|
|
27
|
+
switch (option)
|
|
28
|
+
{
|
|
29
|
+
case OPT_SERVERS: return("List which servers you wish to connect to.");
|
|
30
|
+
case OPT_VERSION: return("Display the version of the application and then exit.");
|
|
31
|
+
case OPT_HELP: return("Diplay this message and then exit.");
|
|
32
|
+
case OPT_VERBOSE: return("Give more details on the progression of the application.");
|
|
33
|
+
case OPT_DEBUG: return("Provide output only useful for debugging.");
|
|
34
|
+
case OPT_FLAG: return("Provide flag information for storage operation.");
|
|
35
|
+
case OPT_EXPIRE: return("Set the expire option for the object.");
|
|
36
|
+
case OPT_SET: return("Use set command with memcached when storing.");
|
|
37
|
+
case OPT_REPLACE: return("Use replace command with memcached when storing.");
|
|
38
|
+
case OPT_ADD: return("Use add command with memcached when storing.");
|
|
39
|
+
case OPT_SLAP_EXECUTE_NUMBER: return("Number of times to execute the given test.");
|
|
40
|
+
case OPT_SLAP_INITIAL_LOAD: return("Number of key pairs to load before executing tests.");
|
|
41
|
+
case OPT_SLAP_TEST: return("Test to run (currently \"get\" or \"set\").");
|
|
42
|
+
case OPT_SLAP_CONCURRENCY: return("Number of users to simulate with load.");
|
|
43
|
+
case OPT_SLAP_NON_BLOCK: return("Set TCP up to use non-blocking IO.");
|
|
44
|
+
case OPT_SLAP_TCP_NODELAY: return("Set TCP socket up to use nodelay.");
|
|
45
|
+
case OPT_FLUSH: return("Flush servers before running tests.");
|
|
46
|
+
case OPT_HASH: return("Select hash type.");
|
|
47
|
+
case OPT_BINARY: return("Switch to binary protocol.");
|
|
48
|
+
case OPT_ANALYZE: return("Analyze the provided servers.");
|
|
49
|
+
case OPT_UDP: return("Use UDP protocol when communicating with server.");
|
|
50
|
+
case OPT_USERNAME: return "Username to use for SASL authentication";
|
|
51
|
+
case OPT_PASSWD: return "Password to use for SASL authentication";
|
|
52
|
+
default: WATCHPOINT_ASSERT(0);
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
WATCHPOINT_ASSERT(0);
|
|
56
|
+
return "forgot to document this function :)";
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
void help_command(const char *command_name, const char *description,
|
|
60
|
+
const struct option *long_options,
|
|
61
|
+
memcached_programs_help_st *options __attribute__((unused)))
|
|
62
|
+
{
|
|
63
|
+
unsigned int x;
|
|
64
|
+
|
|
65
|
+
printf("%s v%u.%u\n\n", command_name, 1, 0);
|
|
66
|
+
printf("\t%s\n\n", description);
|
|
67
|
+
printf("Current options. A '=' means the option takes a value.\n\n");
|
|
68
|
+
|
|
69
|
+
for (x= 0; long_options[x].name; x++)
|
|
70
|
+
{
|
|
71
|
+
const char *help_message;
|
|
72
|
+
|
|
73
|
+
printf("\t --%s%c\n", long_options[x].name,
|
|
74
|
+
long_options[x].has_arg ? '=' : ' ');
|
|
75
|
+
if ((help_message= lookup_help(long_options[x].val)))
|
|
76
|
+
printf("\t\t%s\n", help_message);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
printf("\n");
|
|
80
|
+
exit(0);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
void process_hash_option(memcached_st *memc, char *opt_hash)
|
|
84
|
+
{
|
|
85
|
+
uint64_t set;
|
|
86
|
+
memcached_return rc;
|
|
87
|
+
|
|
88
|
+
if (opt_hash == NULL)
|
|
89
|
+
return;
|
|
90
|
+
|
|
91
|
+
set= MEMCACHED_HASH_DEFAULT; /* Just here to solve warning */
|
|
92
|
+
if (!strcasecmp(opt_hash, "CRC"))
|
|
93
|
+
set= MEMCACHED_HASH_CRC;
|
|
94
|
+
else if (!strcasecmp(opt_hash, "FNV1_64"))
|
|
95
|
+
set= MEMCACHED_HASH_FNV1_64;
|
|
96
|
+
else if (!strcasecmp(opt_hash, "FNV1A_64"))
|
|
97
|
+
set= MEMCACHED_HASH_FNV1A_64;
|
|
98
|
+
else if (!strcasecmp(opt_hash, "FNV1_32"))
|
|
99
|
+
set= MEMCACHED_HASH_FNV1_32;
|
|
100
|
+
else if (!strcasecmp(opt_hash, "FNV1A_32"))
|
|
101
|
+
set= MEMCACHED_HASH_FNV1A_32;
|
|
102
|
+
else if (!strcasecmp(opt_hash, "NONE"))
|
|
103
|
+
set= MEMCACHED_HASH_NONE;
|
|
104
|
+
else
|
|
105
|
+
{
|
|
106
|
+
fprintf(stderr, "hash: type not recognized %s\n", opt_hash);
|
|
107
|
+
exit(1);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
rc= memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_HASH, set);
|
|
111
|
+
if (rc != MEMCACHED_SUCCESS)
|
|
112
|
+
{
|
|
113
|
+
fprintf(stderr, "hash: memcache error %s\n", memcached_strerror(memc, rc));
|
|
114
|
+
exit(1);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
static char *username;
|
|
119
|
+
static char *passwd;
|
|
120
|
+
|
|
121
|
+
#ifdef LIBMEMCACHED_WITH_SASL_SUPPORT
|
|
122
|
+
static int get_username(void *context, int id, const char **result,
|
|
123
|
+
unsigned int *len)
|
|
124
|
+
{
|
|
125
|
+
(void)context;
|
|
126
|
+
if (!result || (id != SASL_CB_USER && id != SASL_CB_AUTHNAME))
|
|
127
|
+
return SASL_BADPARAM;
|
|
128
|
+
|
|
129
|
+
*result= username;
|
|
130
|
+
if (len)
|
|
131
|
+
*len= (username == NULL) ? 0 : (unsigned int)strlen(username);
|
|
132
|
+
|
|
133
|
+
return SASL_OK;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
static int get_password(sasl_conn_t *conn, void *context, int id,
|
|
137
|
+
sasl_secret_t **psecret)
|
|
138
|
+
{
|
|
139
|
+
(void)context;
|
|
140
|
+
static sasl_secret_t* x;
|
|
141
|
+
|
|
142
|
+
if (!conn || ! psecret || id != SASL_CB_PASS)
|
|
143
|
+
return SASL_BADPARAM;
|
|
144
|
+
|
|
145
|
+
if (passwd == NULL)
|
|
146
|
+
{
|
|
147
|
+
*psecret= NULL;
|
|
148
|
+
return SASL_OK;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
size_t len= strlen(passwd);
|
|
152
|
+
x = realloc(x, sizeof(sasl_secret_t) + len);
|
|
153
|
+
if (!x)
|
|
154
|
+
return SASL_NOMEM;
|
|
155
|
+
|
|
156
|
+
x->len = len;
|
|
157
|
+
strcpy((void *)x->data, passwd);
|
|
158
|
+
|
|
159
|
+
*psecret = x;
|
|
160
|
+
return SASL_OK;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
/* callbacks we support */
|
|
164
|
+
static sasl_callback_t sasl_callbacks[] = {
|
|
165
|
+
{
|
|
166
|
+
SASL_CB_USER, &get_username, NULL
|
|
167
|
+
}, {
|
|
168
|
+
SASL_CB_AUTHNAME, &get_username, NULL
|
|
169
|
+
}, {
|
|
170
|
+
SASL_CB_PASS, &get_password, NULL
|
|
171
|
+
}, {
|
|
172
|
+
SASL_CB_LIST_END, NULL, NULL
|
|
173
|
+
}
|
|
174
|
+
};
|
|
175
|
+
#endif
|
|
176
|
+
|
|
177
|
+
bool initialize_sasl(memcached_st *memc, char *user, char *password)
|
|
178
|
+
{
|
|
179
|
+
#ifdef LIBMEMCACHED_WITH_SASL_SUPPORT
|
|
180
|
+
if (user != NULL && password != NULL)
|
|
181
|
+
{
|
|
182
|
+
username= user;
|
|
183
|
+
passwd= password;
|
|
184
|
+
|
|
185
|
+
if (sasl_client_init(NULL) != SASL_OK)
|
|
186
|
+
{
|
|
187
|
+
fprintf(stderr, "Failed to initialize sasl library!\n");
|
|
188
|
+
return false;
|
|
189
|
+
}
|
|
190
|
+
memcached_set_sasl_callbacks(memc, sasl_callbacks);
|
|
191
|
+
}
|
|
192
|
+
#else
|
|
193
|
+
(void)memc;
|
|
194
|
+
(void)user;
|
|
195
|
+
(void)passwd;
|
|
196
|
+
#endif
|
|
197
|
+
|
|
198
|
+
return true;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
void shutdown_sasl(void)
|
|
202
|
+
{
|
|
203
|
+
#if LIBMEMCACHED_WITH_SASL_SUPPORT
|
|
204
|
+
if (username != NULL || passwd != NULL)
|
|
205
|
+
sasl_done();
|
|
206
|
+
#endif
|
|
207
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
#include <getopt.h>
|
|
2
|
+
#include <libmemcached/memcached.h>
|
|
3
|
+
#include "client_options.h"
|
|
4
|
+
|
|
5
|
+
#if TIME_WITH_SYS_TIME
|
|
6
|
+
# include <sys/time.h>
|
|
7
|
+
# include <time.h>
|
|
8
|
+
#else
|
|
9
|
+
# if HAVE_SYS_TIME_H
|
|
10
|
+
# include <sys/time.h>
|
|
11
|
+
# else
|
|
12
|
+
# include <time.h>
|
|
13
|
+
# endif
|
|
14
|
+
#endif
|
|
15
|
+
|
|
16
|
+
#ifdef __sun
|
|
17
|
+
/* For some odd reason the option struct on solaris defines the argument
|
|
18
|
+
* as char* and not const char*
|
|
19
|
+
*/
|
|
20
|
+
#define OPTIONSTRING char*
|
|
21
|
+
#else
|
|
22
|
+
#define OPTIONSTRING const char*
|
|
23
|
+
#endif
|
|
24
|
+
|
|
25
|
+
typedef struct memcached_programs_help_st memcached_programs_help_st;
|
|
26
|
+
|
|
27
|
+
struct memcached_programs_help_st
|
|
28
|
+
{
|
|
29
|
+
char *not_used_yet;
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
char *strdup_cleanup(const char *str);
|
|
33
|
+
void cleanup(void);
|
|
34
|
+
long int timedif(struct timeval a, struct timeval b);
|
|
35
|
+
void version_command(const char *command_name);
|
|
36
|
+
void help_command(const char *command_name, const char *description,
|
|
37
|
+
const struct option *long_options,
|
|
38
|
+
memcached_programs_help_st *options);
|
|
39
|
+
void process_hash_option(memcached_st *memc, char *opt_hash);
|
|
40
|
+
bool initialize_sasl(memcached_st *memc, char *user, char *password);
|
|
41
|
+
void shutdown_sasl(void);
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
#! /bin/sh
|
|
2
|
+
# Wrapper for compilers which do not understand `-c -o'.
|
|
3
|
+
|
|
4
|
+
scriptversion=2009-04-28.21; # UTC
|
|
5
|
+
|
|
6
|
+
# Copyright (C) 1999, 2000, 2003, 2004, 2005, 2009 Free Software
|
|
7
|
+
# Foundation, Inc.
|
|
8
|
+
# Written by Tom Tromey <tromey@cygnus.com>.
|
|
9
|
+
#
|
|
10
|
+
# This program is free software; you can redistribute it and/or modify
|
|
11
|
+
# it under the terms of the GNU General Public License as published by
|
|
12
|
+
# the Free Software Foundation; either version 2, or (at your option)
|
|
13
|
+
# any later version.
|
|
14
|
+
#
|
|
15
|
+
# This program is distributed in the hope that it will be useful,
|
|
16
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
17
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
18
|
+
# GNU General Public License for more details.
|
|
19
|
+
#
|
|
20
|
+
# You should have received a copy of the GNU General Public License
|
|
21
|
+
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
22
|
+
|
|
23
|
+
# As a special exception to the GNU General Public License, if you
|
|
24
|
+
# distribute this file as part of a program that contains a
|
|
25
|
+
# configuration script generated by Autoconf, you may include it under
|
|
26
|
+
# the same distribution terms that you use for the rest of that program.
|
|
27
|
+
|
|
28
|
+
# This file is maintained in Automake, please report
|
|
29
|
+
# bugs to <bug-automake@gnu.org> or send patches to
|
|
30
|
+
# <automake-patches@gnu.org>.
|
|
31
|
+
|
|
32
|
+
case $1 in
|
|
33
|
+
'')
|
|
34
|
+
echo "$0: No command. Try \`$0 --help' for more information." 1>&2
|
|
35
|
+
exit 1;
|
|
36
|
+
;;
|
|
37
|
+
-h | --h*)
|
|
38
|
+
cat <<\EOF
|
|
39
|
+
Usage: compile [--help] [--version] PROGRAM [ARGS]
|
|
40
|
+
|
|
41
|
+
Wrapper for compilers which do not understand `-c -o'.
|
|
42
|
+
Remove `-o dest.o' from ARGS, run PROGRAM with the remaining
|
|
43
|
+
arguments, and rename the output as expected.
|
|
44
|
+
|
|
45
|
+
If you are trying to build a whole package this is not the
|
|
46
|
+
right script to run: please start by reading the file `INSTALL'.
|
|
47
|
+
|
|
48
|
+
Report bugs to <bug-automake@gnu.org>.
|
|
49
|
+
EOF
|
|
50
|
+
exit $?
|
|
51
|
+
;;
|
|
52
|
+
-v | --v*)
|
|
53
|
+
echo "compile $scriptversion"
|
|
54
|
+
exit $?
|
|
55
|
+
;;
|
|
56
|
+
esac
|
|
57
|
+
|
|
58
|
+
ofile=
|
|
59
|
+
cfile=
|
|
60
|
+
eat=
|
|
61
|
+
|
|
62
|
+
for arg
|
|
63
|
+
do
|
|
64
|
+
if test -n "$eat"; then
|
|
65
|
+
eat=
|
|
66
|
+
else
|
|
67
|
+
case $1 in
|
|
68
|
+
-o)
|
|
69
|
+
# configure might choose to run compile as `compile cc -o foo foo.c'.
|
|
70
|
+
# So we strip `-o arg' only if arg is an object.
|
|
71
|
+
eat=1
|
|
72
|
+
case $2 in
|
|
73
|
+
*.o | *.obj)
|
|
74
|
+
ofile=$2
|
|
75
|
+
;;
|
|
76
|
+
*)
|
|
77
|
+
set x "$@" -o "$2"
|
|
78
|
+
shift
|
|
79
|
+
;;
|
|
80
|
+
esac
|
|
81
|
+
;;
|
|
82
|
+
*.c)
|
|
83
|
+
cfile=$1
|
|
84
|
+
set x "$@" "$1"
|
|
85
|
+
shift
|
|
86
|
+
;;
|
|
87
|
+
*)
|
|
88
|
+
set x "$@" "$1"
|
|
89
|
+
shift
|
|
90
|
+
;;
|
|
91
|
+
esac
|
|
92
|
+
fi
|
|
93
|
+
shift
|
|
94
|
+
done
|
|
95
|
+
|
|
96
|
+
if test -z "$ofile" || test -z "$cfile"; then
|
|
97
|
+
# If no `-o' option was seen then we might have been invoked from a
|
|
98
|
+
# pattern rule where we don't need one. That is ok -- this is a
|
|
99
|
+
# normal compilation that the losing compiler can handle. If no
|
|
100
|
+
# `.c' file was seen then we are probably linking. That is also
|
|
101
|
+
# ok.
|
|
102
|
+
exec "$@"
|
|
103
|
+
fi
|
|
104
|
+
|
|
105
|
+
# Name of file we expect compiler to create.
|
|
106
|
+
cofile=`echo "$cfile" | sed 's|^.*[\\/]||; s|^[a-zA-Z]:||; s/\.c$/.o/'`
|
|
107
|
+
|
|
108
|
+
# Create the lock directory.
|
|
109
|
+
# Note: use `[/\\:.-]' here to ensure that we don't use the same name
|
|
110
|
+
# that we are using for the .o file. Also, base the name on the expected
|
|
111
|
+
# object file name, since that is what matters with a parallel build.
|
|
112
|
+
lockdir=`echo "$cofile" | sed -e 's|[/\\:.-]|_|g'`.d
|
|
113
|
+
while true; do
|
|
114
|
+
if mkdir "$lockdir" >/dev/null 2>&1; then
|
|
115
|
+
break
|
|
116
|
+
fi
|
|
117
|
+
sleep 1
|
|
118
|
+
done
|
|
119
|
+
# FIXME: race condition here if user kills between mkdir and trap.
|
|
120
|
+
trap "rmdir '$lockdir'; exit 1" 1 2 15
|
|
121
|
+
|
|
122
|
+
# Run the compile.
|
|
123
|
+
"$@"
|
|
124
|
+
ret=$?
|
|
125
|
+
|
|
126
|
+
if test -f "$cofile"; then
|
|
127
|
+
mv "$cofile" "$ofile"
|
|
128
|
+
elif test -f "${cofile}bj"; then
|
|
129
|
+
mv "${cofile}bj" "$ofile"
|
|
130
|
+
fi
|
|
131
|
+
|
|
132
|
+
rmdir "$lockdir"
|
|
133
|
+
exit $ret
|
|
134
|
+
|
|
135
|
+
# Local Variables:
|
|
136
|
+
# mode: shell-script
|
|
137
|
+
# sh-indentation: 2
|
|
138
|
+
# eval: (add-hook 'write-file-hooks 'time-stamp)
|
|
139
|
+
# time-stamp-start: "scriptversion="
|
|
140
|
+
# time-stamp-format: "%:y-%02m-%02d.%02H"
|
|
141
|
+
# time-stamp-time-zone: "UTC"
|
|
142
|
+
# time-stamp-end: "; # UTC"
|
|
143
|
+
# End:
|