projects
/
awesomized
/
libmemcached
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
|
github
raw
|
inline
| side by side
Fix typo
[awesomized/libmemcached]
/
clients
/
memslap.cc
diff --git
a/clients/memslap.cc
b/clients/memslap.cc
index 8b694835d37cbc6cc6f6af1a469b9457d1b28079..05a491fbef9aec5d7a41c94abb69f85cfa64af28 100644
(file)
--- a/
clients/memslap.cc
+++ b/
clients/memslap.cc
@@
-2,7
+2,7
@@
*
* Libmemcached library
*
*
* Libmemcached library
*
- * Copyright (C) 2011 Data Differential, http://datadifferential.com/
+ * Copyright (C) 2011
-2012
Data Differential, http://datadifferential.com/
* Copyright (C) 2006-2009 Brian Aker All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* Copyright (C) 2006-2009 Brian Aker All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@
-36,9
+36,10
@@
*/
*/
-#include <config.h>
+#include <
mem_
config.h>
#include <cassert>
#include <cassert>
+#include <cerrno>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cstring>
@@
-50,12
+51,11
@@
#include <sys/stat.h>
#include <sys/time.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/time.h>
#include <sys/types.h>
-#include <sys/types.h>
#include <unistd.h>
#include <iostream>
#include <unistd.h>
#include <iostream>
-#include <libmemcached/memcached.h>
+#include <libmemcached
-1.0
/memcached.h>
#include "client_options.h"
#include "utilities.h"
#include "client_options.h"
#include "utilities.h"
@@
-212,19
+212,33
@@
int main(int argc, char *argv[])
{
opt_servers= strdup(temp);
}
{
opt_servers= strdup(temp);
}
- else
+
+ if (opt_servers == NULL)
{
{
-
fprintf(stderr, "No Servers provided\n")
;
-
return EXIT_FAILURE
;
+
std::cerr << "No Servers provided" << std::endl
;
+
exit(EXIT_FAILURE)
;
}
}
memcached_server_st *servers= memcached_servers_parse(opt_servers);
}
}
memcached_server_st *servers= memcached_servers_parse(opt_servers);
+ if (servers == NULL or memcached_server_list_count(servers) == 0)
+ {
+ std::cerr << "Invalid server list provided:" << opt_servers << std::endl;
+ return EXIT_FAILURE;
+ }
pthread_mutex_init(&sleeper_mutex, NULL);
pthread_cond_init(&sleep_threshhold, NULL);
pthread_mutex_init(&sleeper_mutex, NULL);
pthread_cond_init(&sleep_threshhold, NULL);
- scheduler(servers, &conclusion);
+ int error_code= EXIT_SUCCESS;
+ try {
+ scheduler(servers, &conclusion);
+ }
+ catch(std::exception& e)
+ {
+ std::cerr << "Died with exception: " << e.what() << std::endl;
+ error_code= EXIT_FAILURE;
+ }
free(opt_servers);
free(opt_servers);
@@
-233,7
+247,7
@@
int main(int argc, char *argv[])
conclusions_print(&conclusion);
memcached_server_list_free(servers);
conclusions_print(&conclusion);
memcached_server_list_free(servers);
- return
EXIT_SUCCESS
;
+ return
error_code
;
}
void scheduler(memcached_server_st *servers, conclusions_st *conclusion)
}
void scheduler(memcached_server_st *servers, conclusions_st *conclusion)
@@
-305,7
+319,7
@@
void scheduler(memcached_server_st *servers, conclusions_st *conclusion)
pthread_t *threads= new (std::nothrow) pthread_t[opt_concurrency];
pthread_t *threads= new (std::nothrow) pthread_t[opt_concurrency];
- if (
not threads
)
+ if (
threads == NULL
)
{
exit(EXIT_FAILURE);
}
{
exit(EXIT_FAILURE);
}
@@
-460,15
+474,33
@@
void options_parse(int argc, char *argv[])
break;
case OPT_SLAP_CONCURRENCY:
break;
case OPT_SLAP_CONCURRENCY:
+ errno= 0;
opt_concurrency= (unsigned int)strtoul(optarg, (char **)NULL, 10);
opt_concurrency= (unsigned int)strtoul(optarg, (char **)NULL, 10);
+ if (errno != 0)
+ {
+ fprintf(stderr, "Invalid value for concurrency: %s\n", optarg);
+ exit(EXIT_FAILURE);
+ }
break;
case OPT_SLAP_EXECUTE_NUMBER:
break;
case OPT_SLAP_EXECUTE_NUMBER:
+ errno= 0;
opt_execute_number= (unsigned int)strtoul(optarg, (char **)NULL, 10);
opt_execute_number= (unsigned int)strtoul(optarg, (char **)NULL, 10);
+ if (errno != 0)
+ {
+ fprintf(stderr, "Invalid value for execute: %s\n", optarg);
+ exit(EXIT_FAILURE);
+ }
break;
case OPT_SLAP_INITIAL_LOAD:
break;
case OPT_SLAP_INITIAL_LOAD:
+ errno= 0;
opt_createial_load= (unsigned int)strtoul(optarg, (char **)NULL, 10);
opt_createial_load= (unsigned int)strtoul(optarg, (char **)NULL, 10);
+ if (errno != 0)
+ {
+ fprintf(stderr, "Invalid value for initial load: %s\n", optarg);
+ exit(EXIT_FAILURE);
+ }
break;
case OPT_QUIET:
break;
case OPT_QUIET: