projects
/
m6w6
/
libmemcached
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
|
github
raw
|
inline
| side by side
Merge lp:~tangent-org/libmemcached/1.0-build/ Build: jenkins-Libmemcached-197
[m6w6/libmemcached]
/
clients
/
memslap.cc
diff --git
a/clients/memslap.cc
b/clients/memslap.cc
index f00ba45764ed24bf43b3e762dbe5dab0b9668dca..d32b1c040e79b6e686506dd3d06f011ae8b11c20 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,7
+36,7
@@
*/
*/
-#include <config.h>
+#include <
mem_
config.h>
#include <cassert>
#include <cstdio>
#include <cassert>
#include <cstdio>
@@
-53,7
+53,9
@@
#include <sys/types.h>
#include <unistd.h>
#include <sys/types.h>
#include <unistd.h>
-#include <libmemcached/memcached.h>
+#include <iostream>
+
+#include <libmemcached-1.0/memcached.h>
#include "client_options.h"
#include "utilities.h"
#include "client_options.h"
#include "utilities.h"
@@
-152,12
+154,12
@@
static unsigned int opt_createial_load= 0;
static unsigned int opt_concurrency= 0;
static int opt_displayflag= 0;
static char *opt_servers= NULL;
static unsigned int opt_concurrency= 0;
static int opt_displayflag= 0;
static char *opt_servers= NULL;
-static
int opt_udp_io= 0
;
+static
bool opt_udp_io= false
;
test_t opt_test= SET_TEST;
extern "C" {
test_t opt_test= SET_TEST;
extern "C" {
-static void *run_task(void *p)
+static
__attribute__((noreturn))
void *run_task(void *p)
{
thread_context_st *context= (thread_context_st *)p;
{
thread_context_st *context= (thread_context_st *)p;
@@
-222,7
+224,15
@@
int main(int argc, char *argv[])
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);
@@
-231,7
+241,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)
@@
-243,26
+253,31
@@
void scheduler(memcached_server_st *servers, conclusions_st *conclusion)
memcached_st *memc= memcached_create(NULL);
memcached_st *memc= memcached_create(NULL);
+ memcached_server_push(memc, servers);
+
/* We need to set udp behavior before adding servers to the client */
if (opt_udp_io)
{
/* We need to set udp behavior before adding servers to the client */
if (opt_udp_io)
{
- memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_USE_UDP,
- (uint64_t)opt_udp_io);
- for (uint32_t x= 0; x < memcached_server_list_count(servers); x++ )
+ if (memcached_failed(memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_USE_UDP, opt_udp_io)))
{
{
- servers[x].type= MEMCACHED_CONNECTION_UDP;
+ std::cerr << "Failed to enable UDP." << std::endl;
+ memcached_free(memc);
+ exit(EXIT_FAILURE);
}
}
}
}
- memcached_server_push(memc, servers);
memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_BINARY_PROTOCOL,
(uint64_t)opt_binary);
if (opt_flush)
memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_BINARY_PROTOCOL,
(uint64_t)opt_binary);
if (opt_flush)
+ {
flush_all(memc);
flush_all(memc);
+ }
if (opt_createial_load)
if (opt_createial_load)
+ {
pairs= load_create_data(memc, opt_createial_load, &actual_loaded);
pairs= load_create_data(memc, opt_createial_load, &actual_loaded);
+ }
char **keys= static_cast<char **>(calloc(actual_loaded, sizeof(char*)));
size_t *key_lengths= static_cast<size_t *>(calloc(actual_loaded, sizeof(size_t)));
char **keys= static_cast<char **>(calloc(actual_loaded, sizeof(char*)));
size_t *key_lengths= static_cast<size_t *>(calloc(actual_loaded, sizeof(size_t)));
@@
-298,7
+313,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);
}
@@
-399,7
+414,7
@@
void options_parse(int argc, char *argv[])
"does not currently support get ops.\n");
exit(1);
}
"does not currently support get ops.\n");
exit(1);
}
- opt_udp_io=
1
;
+ opt_udp_io=
true
;
break;
case OPT_BINARY:
break;
case OPT_BINARY: