Permalink
Browse files

Merge pull request #22 from sejima/1.0.15-develop

replication loop detection
  • Loading branch information...
2 parents aa00227 + cb30ecf commit 679d0a7f4cb7ff4afa78b2656ec43094a953224d @fujimoto committed Sep 20, 2011
Showing with 13 additions and 9 deletions.
  1. +2 −0 src/lib/app.cc
  2. +8 −0 src/lib/cluster.cc
  3. +1 −1 src/lib/connection.cc
  4. +0 −2 src/lib/storage.h
  5. +0 −2 src/lib/storage_tcb.h
  6. +0 −2 src/lib/storage_tch.h
  7. +2 −2 src/lib/util.h
View
@@ -136,6 +136,8 @@ int app::_set_pid() {
ofstream ofs(pid_path.c_str());
if (ofs.fail()) {
log_err("setting pid failed [%s]", pid_path.c_str());
+ ofs.close();
+ return -1;
}
ofs << pid << endl;
ofs.close();
View
@@ -1194,6 +1194,14 @@ cluster::proxy_request cluster::post_proxy_write(op_proxy_write* op, bool sync)
int key_hash_value = e.get_key_hash_value(storage::hash_algorithm_bitshift);
vector<string> proxy = op->get_proxy();
+ if (static_cast<int>(count(proxy.begin(), proxy.end(), this->_node_key)) >= 2) {
+ // nothing to do
+ // The following cases may occur. (count() == 1, w/failover)
+ // e.g.) client -> nodeA(slave) -> nodeB(preparing, changed role from master to slave) -> nodeA(master, failovered) -> nodeB
+ // ^^^^^
+ log_warning("skip proxy request to slave -> storing proxied node list (n=%d, proxy=%s)", proxy.size(), util::vector_join<string>(proxy, ",").c_str());
+ return proxy_request_complete;
+ }
proxy.push_back(this->_node_key);
shared_queue_proxy_write q(new queue_proxy_write(this, this->_storage, proxy, e, op->get_ident()));
q->set_post_proxy(true);
View
@@ -196,7 +196,7 @@ int connection::read(char** p, int expect_len, bool readline, bool& actual) {
return len;
}
- struct pollfd ufds;
+ struct pollfd ufds = {0};
ufds.fd = this->_sock;
ufds.events = POLLIN | POLLPRI;
View
@@ -8,8 +8,6 @@
#ifndef __STORAGE_H__
#define __STORAGE_H__
-#include <boost/shared_ptr.hpp>
-
#include "tcutil.h"
#include "logger.h"
View
@@ -8,8 +8,6 @@
#ifndef __STORAGE_TCB_H__
#define __STORAGE_TCB_H__
-#include <boost/shared_ptr.hpp>
-
#ifdef HAVE_STDLIB_H
# include <stdlib.h>
#endif // HAVE_STDLIB_H
View
@@ -8,8 +8,6 @@
#ifndef __STORAGE_TCH_H__
#define __STORAGE_TCH_H__
-#include <boost/shared_ptr.hpp>
-
#ifdef HAVE_STDLIB_H
# include <stdlib.h>
#endif // HAVE_STDLIB_H
View
@@ -12,7 +12,7 @@
#include <sstream>
#include <boost/lexical_cast.hpp>
-#include <boost/shared_ptr.hpp>
+#include <boost/shared_array.hpp>
#include <boost/tokenizer.hpp>
#include <ctype.h>
@@ -53,7 +53,7 @@ typedef unsigned char uint8_t;
#endif // HAVE_STDINT_H
extern const char* const line_delimiter;
-typedef shared_ptr<uint8_t> shared_byte;
+typedef shared_array<uint8_t> shared_byte;
/**
* utility class (misc methods)

0 comments on commit 679d0a7

Please sign in to comment.