projects
/
awesomized
/
libmemcached
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
|
github
raw
|
inline
| side by side
Big fix for async mode to make sure all data has been pushed through socket
[awesomized/libmemcached]
/
src
/
memrm.c
diff --git
a/src/memrm.c
b/src/memrm.c
index e07654f3cad4a7968c5c90ec3fcf97f0dfffe0c4..09f58ea4d76b83eeeca69c02798b0cb11b5c982f 100644
(file)
--- a/
src/memrm.c
+++ b/
src/memrm.c
@@
-2,6
+2,7
@@
#include <unistd.h>
#include <getopt.h>
#include <memcached.h>
#include <unistd.h>
#include <getopt.h>
#include <memcached.h>
+#include <string.h>
#include "client_options.h"
#include "utilities.h"
#include "client_options.h"
#include "utilities.h"
@@
-9,6
+10,9
@@
static int opt_verbose= 0;
static time_t opt_expire= 0;
static char *opt_servers= NULL;
static time_t opt_expire= 0;
static char *opt_servers= NULL;
+#define PROGRAM_NAME "memrm"
+#define PROGRAM_DESCRIPTION "Erase a key or set of keys from a memcached cluster."
+
/* Prototypes */
void options_parse(int argc, char *argv[]);
/* Prototypes */
void options_parse(int argc, char *argv[]);
@@
-21,11
+25,18
@@
int main(int argc, char *argv[])
options_parse(argc, argv);
if (!opt_servers)
options_parse(argc, argv);
if (!opt_servers)
- return 0;
+ {
+ char *temp;
+
+ if ((temp= getenv("MEMCACHED_SERVERS")))
+ opt_servers= strdup(temp);
+ else
+ exit(1);
+ }
- memc= memcached_
init
(NULL);
+ memc= memcached_
create
(NULL);
- servers=
parse_opt_servers
(opt_servers);
+ servers=
memcached_servers_parse
(opt_servers);
memcached_server_push(memc, servers);
memcached_server_list_free(servers);
memcached_server_push(memc, servers);
memcached_server_list_free(servers);
@@
-37,14
+48,17
@@
int main(int argc, char *argv[])
if (rc != MEMCACHED_SUCCESS)
{
if (rc != MEMCACHED_SUCCESS)
{
- fprintf(stderr, "memrm: %s: memcache error %s
\n
",
+ fprintf(stderr, "memrm: %s: memcache error %s",
argv[optind], memcached_strerror(memc, rc));
argv[optind], memcached_strerror(memc, rc));
+ if (memc->cached_errno)
+ fprintf(stderr, " system error %s", strerror(memc->cached_errno));
+ fprintf(stderr, "\n");
}
optind++;
}
}
optind++;
}
- memcached_
deinit
(memc);
+ memcached_
free
(memc);
free(opt_servers);
free(opt_servers);
@@
-54,6
+68,11
@@
int main(int argc, char *argv[])
void options_parse(int argc, char *argv[])
{
void options_parse(int argc, char *argv[])
{
+ memcached_programs_help_st help_options[]=
+ {
+ {0},
+ };
+
static struct option long_options[]=
{
{"version", no_argument, NULL, OPT_VERSION},
static struct option long_options[]=
{
{"version", no_argument, NULL, OPT_VERSION},
@@
-82,12
+101,10
@@
void options_parse(int argc, char *argv[])
opt_verbose = OPT_DEBUG;
break;
case OPT_VERSION: /* --version or -V */
opt_verbose = OPT_DEBUG;
break;
case OPT_VERSION: /* --version or -V */
- printf("memcache tools, memrm, v1.0\n");
- exit(0);
+ version_command(PROGRAM_NAME);
break;
case OPT_HELP: /* --help or -h */
break;
case OPT_HELP: /* --help or -h */
- printf("useful help messages go here\n");
- exit(0);
+ help_command(PROGRAM_NAME, PROGRAM_DESCRIPTION, long_options, help_options);
break;
case OPT_SERVERS: /* --servers or -s */
opt_servers= strdup(optarg);
break;
case OPT_SERVERS: /* --servers or -s */
opt_servers= strdup(optarg);