Permalink
Browse files

attach, detach 時に全 kumo-server が WAIT 状態になる現象に対処

  • Loading branch information...
1 parent b0f7ce8 commit 479e94781362d1880874c7aede16bf311c0df041 @tmtm committed Jun 25, 2011
Showing with 12 additions and 4 deletions.
  1. +2 −1 src/logic/server.proto.h
  2. +10 −3 src/logic/server/mod_replace_stream.cc
@@ -317,14 +317,15 @@ struct replicate_flags : msgtype::flags_base {
accum_set_t& map, const address& addr);
RPC_REPLY_DECL(ReplaceOffer, from, res, err, z,
- address addr);
+ address addr, uint32_t counter);
void stream_accepted(int fd, int err);
void stream_connected(int fd, int err);
std::auto_ptr<mp::wavy::core> m_stream_core;
class stream_handler;
friend class stream_handler;
+ uint32_t send_offer_counter;
@end
@@ -33,7 +33,8 @@ namespace server {
mod_replace_stream_t::mod_replace_stream_t(address stream_addr) :
- m_stream_addr(stream_addr)
+ m_stream_addr(stream_addr),
+ send_offer_counter(0)
{ }
mod_replace_stream_t::~mod_replace_stream_t() { }
@@ -121,6 +122,8 @@ void mod_replace_stream_t::send_offer(mod_replace_stream_t::offer_storage& offer
pthread_scoped_lock oflk(m_accum_set_mutex);
offer.commit(&m_accum_set);
+ send_offer_counter++;
+
pthread_scoped_lock relk(net->mod_replace.state_mutex());
for(accum_set_t::iterator it(m_accum_set.begin()),
@@ -133,19 +136,23 @@ void mod_replace_stream_t::send_offer(mod_replace_stream_t::offer_storage& offer
using namespace mp::placeholders;
net->get_node(addr)->call(param, nullz,
- BIND_RESPONSE(mod_replace_stream_t, ReplaceOffer, addr), 160); // FIXME 160
+ BIND_RESPONSE(mod_replace_stream_t, ReplaceOffer, addr, send_offer_counter), 160); // FIXME 160
net->mod_replace.replace_offer_push(replace_time, relk);
}
}
RPC_REPLY_IMPL(mod_replace_stream_t, ReplaceOffer, from, res, err, z,
- address addr)
+ address addr, uint32_t counter)
{
LOG_TRACE("ResReplaceOffer from ",addr," res:",res," err:",err);
// Note: this request always timed out
+ if (counter != send_offer_counter) {
+ return;
+ }
+
pthread_scoped_lock oflk(m_accum_set_mutex);
accum_set_t::iterator it = accum_set_find(m_accum_set, addr);

0 comments on commit 479e947

Please sign in to comment.