projects
/
awesomized
/
libmemcached
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
|
github
raw
|
patch
|
inline
| side by side (parent:
999006a
)
Update for fix for testing if memcached is running.
author
Brian Aker
<brian@tangent.org>
Tue, 19 Jun 2012 00:15:21 +0000
(17:15 -0700)
committer
Brian Aker
<brian@tangent.org>
Tue, 19 Jun 2012 00:15:21 +0000
(17:15 -0700)
libmemcachedutil/ping.cc
patch
|
blob
|
history
libtest/memcached.cc
patch
|
blob
|
history
libtest/server.cc
patch
|
blob
|
history
libtest/server.h
patch
|
blob
|
history
tests/libmemcached-1.0/parser.cc
patch
|
blob
|
history
diff --git
a/libmemcachedutil/ping.cc
b/libmemcachedutil/ping.cc
index b2192a1dbf79ff5d1aab0c8b03fd25ef4fd54fa9..0154b530d5ba8295345974ab05cc3feb7800fbe2 100644
(file)
--- a/
libmemcachedutil/ping.cc
+++ b/
libmemcachedutil/ping.cc
@@
-54,6
+54,8
@@
bool libmemcached_util_ping(const char *hostname, in_port_t port, memcached_retu
return false;
}
return false;
}
+ (void)memcached_behavior_set(memc_ptr, MEMCACHED_BEHAVIOR_CONNECT_TIMEOUT, 400000);
+
memcached_return_t rc= memcached_server_add(memc_ptr, hostname, port);
if (memcached_success(rc))
{
memcached_return_t rc= memcached_server_add(memc_ptr, hostname, port);
if (memcached_success(rc))
{
diff --git
a/libtest/memcached.cc
b/libtest/memcached.cc
index adf650f8c770df28b23dc73612af957f31437c70..b8838a06a495bd4bbdf8702daf523e1d1953600d 100644
(file)
--- a/
libtest/memcached.cc
+++ b/
libtest/memcached.cc
@@
-97,7
+97,6
@@
public:
libtest::Server(host_arg, port_arg,
MEMCACHED_BINARY, is_memcached_libtool(), is_socket_arg)
{
libtest::Server(host_arg, port_arg,
MEMCACHED_BINARY, is_memcached_libtool(), is_socket_arg)
{
- set_pid_file();
}
virtual const char *sasl() const
}
virtual const char *sasl() const
@@
-115,27
+114,13
@@
public:
return _username;
}
return _username;
}
-
bool wait_for_pid
file() const
+
virtual bool has_pid_
file() const
{
{
- Wait wait(pid(), 4);
-
- return wait.successful();
+ return false;
}
bool ping()
{
}
bool ping()
{
-#if 0
- // Memcached is slow to start, so we need to do this
- if (pid_file().empty() == false)
- {
- if (wait_for_pidfile() == false)
- {
- Error << "Pidfile was not found:" << pid_file() << " :" << running();
- return -1;
- }
- }
-#endif
-
memcached_return_t rc;
bool ret;
memcached_return_t rc;
bool ret;
@@
-150,7
+135,7
@@
public:
if (memcached_failed(rc) or ret == false)
{
if (memcached_failed(rc) or ret == false)
{
-
Error << "libmemcached_util_ping(" << hostname() << ", " << port() << ") error: " << memcached_strerror(NULL, rc
);
+
error(memcached_strerror(NULL, rc)
);
}
return ret;
}
return ret;
@@
-332,16
+317,6
@@
public:
bool ping()
{
bool ping()
{
- // Memcached is slow to start, so we need to do this
- if (pid_file().empty() == false)
- {
- if (wait_for_pidfile() == false)
- {
- Error << "Pidfile was not found:" << pid_file();
- return -1;
- }
- }
-
memcached_return_t rc;
bool ret;
memcached_return_t rc;
bool ret;
@@
-356,7
+331,7
@@
public:
if (memcached_failed(rc) or ret == false)
{
if (memcached_failed(rc) or ret == false)
{
-
Error << "libmemcached_util_ping2(" << hostname() << ", " << port() << ", " << username() << ", " << password() << ") error: " << memcached_strerror(NULL, rc
);
+
error(memcached_strerror(NULL, rc)
);
}
return ret;
}
return ret;
diff --git
a/libtest/server.cc
b/libtest/server.cc
index 78b729f96cb473faeeef973e325865cb0a28689f..a5d801a6fb00b4b4006973b07a309e8c3e26e2d9 100644
(file)
--- a/
libtest/server.cc
+++ b/
libtest/server.cc
@@
-148,9
+148,14
@@
bool Server::cycle()
bool Server::wait_for_pidfile() const
{
bool Server::wait_for_pidfile() const
{
- Wait wait(pid_file(), 4);
+ if (has_pid_file())
+ {
+ Wait wait(pid_file(), 4);
+
+ return wait.successful();
+ }
- return
wait.successful()
;
+ return
true
;
}
bool Server::has_pid() const
}
bool Server::has_pid() const
@@
-206,29
+211,33
@@
bool Server::start()
dream(5, 50000);
}
dream(5, 50000);
}
- size_t repeat= 5;
_app.slurp();
_app.slurp();
-
while (--repeat
)
+
if (has_pid_file()
)
{
{
- if (pid_file().empty() == false)
+ size_t repeat= 5;
+ while (--repeat)
{
{
- Wait wait(pid_file(), 8);
-
- if (wait.successful() == false)
+ if (pid_file().empty() == false)
{
{
- if (_app.check())
+ Error << " here?";
+ Wait wait(pid_file(), 8);
+
+ if (wait.successful() == false)
{
{
- _app.slurp();
- continue;
+ if (_app.check())
+ {
+ _app.slurp();
+ continue;
+ }
+
+ char buf[PATH_MAX];
+ char *getcwd_buf= getcwd(buf, sizeof(buf));
+ throw libtest::fatal(LIBYATL_DEFAULT_PARAM,
+ "Unable to open pidfile in %s for: %s stderr:%s",
+ getcwd_buf ? getcwd_buf : "",
+ _running.c_str(),
+ _app.stderr_c_str());
}
}
-
- char buf[PATH_MAX];
- char *getcwd_buf= getcwd(buf, sizeof(buf));
- throw libtest::fatal(LIBYATL_DEFAULT_PARAM,
- "Unable to open pidfile in %s for: %s stderr:%s",
- getcwd_buf ? getcwd_buf : "",
- _running.c_str(),
- _app.stderr_c_str());
}
}
}
}
}
}
@@
-406,6
+415,7
@@
bool Server::args(Application& app)
}
// Update pid_file
}
// Update pid_file
+ if (has_pid_file())
{
if (_pid_file.empty() and set_pid_file() == false)
{
{
if (_pid_file.empty() and set_pid_file() == false)
{
diff --git
a/libtest/server.h
b/libtest/server.h
index 2f9fa2f1d0682d6b64b66f0a558159b73703b2ee..736810be0ae94b895ecf2523d479fa0bd54c1869 100644
(file)
--- a/
libtest/server.h
+++ b/
libtest/server.h
@@
-210,6
+210,21
@@
public:
bool has_pid() const;
bool has_pid() const;
+ virtual bool has_pid_file() const
+ {
+ return true;
+ }
+
+ const std::string& error()
+ {
+ return _error;
+ }
+
+ void error(std::string arg)
+ {
+ _error= arg;
+ }
+
virtual bool wait_for_pidfile() const;
bool check_pid(pid_t pid_arg) const
virtual bool wait_for_pidfile() const;
bool check_pid(pid_t pid_arg) const
@@
-249,6
+264,7
@@
private:
bool set_log_file();
bool set_socket_file();
void reset_pid();
bool set_log_file();
bool set_socket_file();
void reset_pid();
+ std::string _error;
};
std::ostream& operator<<(std::ostream& output, const libtest::Server &arg);
};
std::ostream& operator<<(std::ostream& output, const libtest::Server &arg);
diff --git
a/tests/libmemcached-1.0/parser.cc
b/tests/libmemcached-1.0/parser.cc
index 03fb73ffa760303e394174d10ba6e267d45b1c64..3cacd26ccf8d9d62fd2e6a5f7ffbb58978295315 100644
(file)
--- a/
tests/libmemcached-1.0/parser.cc
+++ b/
tests/libmemcached-1.0/parser.cc
@@
-748,7
+748,9
@@
test_return_t regression_bug_71231153_connect(memcached_st *)
test_return_t regression_bug_71231153_poll(memcached_st *)
{
if (libmemcached_util_ping("10.0.2.252", 0, NULL)) // If for whatever reason someone has a host at this address, skip
test_return_t regression_bug_71231153_poll(memcached_st *)
{
if (libmemcached_util_ping("10.0.2.252", 0, NULL)) // If for whatever reason someone has a host at this address, skip
+ {
return TEST_SKIPPED;
return TEST_SKIPPED;
+ }
{ // Test the poll timeout, on a bad host we should get MEMCACHED_CONNECTION_FAILURE
memcached_st *memc= memcached(test_literal_param("--SERVER=10.0.2.252 --POLL-TIMEOUT=0"));
{ // Test the poll timeout, on a bad host we should get MEMCACHED_CONNECTION_FAILURE
memcached_st *memc= memcached(test_literal_param("--SERVER=10.0.2.252 --POLL-TIMEOUT=0"));