# # # patch "ChangeLog" # from [59f3194423f6b5a51e5eb80011105fa1a8f5a87c] # to [02b4406d9c09d0e96e4c73f9f6584f61b9c07fa5] # # patch "NEWS" # from [4b6916fdccad85a3af0b8601508f2e1158bae70f] # to [ef3bd56b18d1386927ffb58c2bb20ef4070712dd] # # patch "netsync.cc" # from [4d15f2c47aed8bb45b5dc8267ab60c35703d49e9] # to [a348f76e9aceea332aa00c5f15e861046bb7d13c] # ============================================================ --- ChangeLog 59f3194423f6b5a51e5eb80011105fa1a8f5a87c +++ ChangeLog 02b4406d9c09d0e96e4c73f9f6584f61b9c07fa5 @@ -1,3 +1,7 @@ +2006-02-12 Nathaniel Smith + + * NEWS: Add things done since last time I did this... + 2006-02-12 Matthew Gregan * {cset,paths,revision,roster,sanity,vocab}.{cc,hh}: GCC 4.1 ============================================================ --- NEWS 4b6916fdccad85a3af0b8601508f2e1158bae70f +++ NEWS ef3bd56b18d1386927ffb58c2bb20ef4070712dd @@ -48,11 +48,14 @@ - Fixed bug that made ticker output from netsync inaccurate. - In 'log', --no-merges is now the default, use --merges to override. + - If the database is in the working copy, then it is always + ignored. Bugs: - 'serve' with no --bind should now work on systems where the C library has IPv6 support, but the kernel does not. + - Compile fixes for GCC 4.1 pre-releases. Other: - Better detection when users have not run "rosterify", and ============================================================ --- netsync.cc 4d15f2c47aed8bb45b5dc8267ab60c35703d49e9 +++ netsync.cc a348f76e9aceea332aa00c5f15e861046bb7d13c @@ -2579,129 +2579,127 @@ // further down. bool try_again=false; - do - { - try - { - try_again = false; + // have to use a pointer, because StreamServer is non-copyable, but we might + // need to throw our first one out and switch to a different one + std::auto_ptr server; - Netxx::Address addr(use_ipv6); + Netxx::Address addr(use_ipv6); - if (!app.bind_address().empty()) - addr.add_address(app.bind_address().c_str(), default_port); - else - addr.add_all_addresses (default_port); + if (!app.bind_address().empty()) + addr.add_address(app.bind_address().c_str(), default_port); + else + addr.add_all_addresses (default_port); - // If se use IPv6 and the initiasation of server fails, we want - // to try again with IPv4. The reason is that someone may have - // downloaded a IPv6-enabled monotone on a system that doesn't - // have IPv6, and which might fail therefore. - // On failure, Netxx::NetworkException is thrown, and we catch - // it further down. - try_again=use_ipv6; + // If se use IPv6 and the initiasation of server fails, we want + // to try again with IPv4. The reason is that someone may have + // downloaded a IPv6-enabled monotone on a system that doesn't + // have IPv6, and which might fail therefore. + // On failure, Netxx::NetworkException is thrown, and we catch + // it further down. + try_again=use_ipv6; - Netxx::StreamServer server(addr, timeout); + Netxx::StreamServer server(addr, timeout); - // If we came this far, whatever we used (IPv6 or IPv4) was - // accepted, so we don't need to try again any more. - try_again=false; + // If we came this far, whatever we used (IPv6 or IPv4) was + // accepted, so we don't need to try again any more. + try_again=false; - const char *name = addr.get_name(); - P(F("beginning service on %s : %s\n") - % (name != NULL ? name : "all interfaces") - % lexical_cast(addr.get_port())); - - map > sessions; - set armed_sessions; - - shared_ptr guard; + const char *name = addr.get_name(); + P(F("beginning service on %s : %s\n") + % (name != NULL ? name : "all interfaces") + % lexical_cast(addr.get_port())); + + map > sessions; + set armed_sessions; + + shared_ptr guard; + + while (true) + { + probe.clear(); + armed_sessions.clear(); + + if (sessions.size() >= session_limit) + W(F("session limit %d reached, some connections " + "will be refused\n") % session_limit); + else + probe.add(server); + + arm_sessions_and_calculate_probe(probe, sessions, armed_sessions); + + L(FL("i/o probe with %d armed\n") % armed_sessions.size()); + Netxx::Probe::result_type res = probe.ready(sessions.empty() ? forever + : (armed_sessions.empty() ? timeout + : instant)); + Netxx::Probe::ready_type event = res.second; + Netxx::socket_type fd = res.first; - while (true) - { - probe.clear(); - armed_sessions.clear(); + if (!guard) + guard = shared_ptr(new transaction_guard(app.db)); - if (sessions.size() >= session_limit) - W(F("session limit %d reached, some connections " - "will be refused\n") % session_limit); - else - probe.add(server); + I(guard); - arm_sessions_and_calculate_probe(probe, sessions, armed_sessions); + if (fd == -1) + { + if (armed_sessions.empty()) + L(FL("timed out waiting for I/O (listening on %s : %s)\n") + % addr.get_name() % lexical_cast(addr.get_port())); + } - L(FL("i/o probe with %d armed\n") % armed_sessions.size()); - Netxx::Probe::result_type res = probe.ready(sessions.empty() ? forever - : (armed_sessions.empty() ? timeout - : instant)); - Netxx::Probe::ready_type event = res.second; - Netxx::socket_type fd = res.first; + // we either got a new connection + else if (fd == server) + handle_new_connection(addr, server, timeout, role, + include_pattern, exclude_pattern, + sessions, app); - if (!guard) - guard = shared_ptr(new transaction_guard(app.db)); + // or an existing session woke up + else + { + map >::iterator i; + i = sessions.find(fd); + if (i == sessions.end()) + { + L(FL("got woken up for action on unknown fd %d\n") % fd); + } + else + { + shared_ptr sess = i->second; + bool live_p = true; - I(guard); - - if (fd == -1) - { - if (armed_sessions.empty()) - L(FL("timed out waiting for I/O (listening on %s : %s)\n") - % addr.get_name() % lexical_cast(addr.get_port())); - } - - // we either got a new connection - else if (fd == server) - handle_new_connection(addr, server, timeout, role, - include_pattern, exclude_pattern, - sessions, app); - - // or an existing session woke up - else - { - map >::iterator i; - i = sessions.find(fd); - if (i == sessions.end()) - { - L(FL("got woken up for action on unknown fd %d\n") % fd); - } - else - { - shared_ptr sess = i->second; - bool live_p = true; + if (event & Netxx::Probe::ready_read) + handle_read_available(fd, sess, sessions, + armed_sessions, live_p); - if (event & Netxx::Probe::ready_read) - handle_read_available(fd, sess, sessions, - armed_sessions, live_p); - - if (live_p && (event & Netxx::Probe::ready_write)) - handle_write_available(fd, sess, sessions, live_p); - - if (live_p && (event & Netxx::Probe::ready_oobd)) - { - P(F("got OOB from peer %s, disconnecting\n") - % sess->peer_id); - sessions.erase(i); - } - } - } - process_armed_sessions(sessions, armed_sessions, *guard); - reap_dead_sessions(sessions, timeout_seconds); + if (live_p && (event & Netxx::Probe::ready_write)) + handle_write_available(fd, sess, sessions, live_p); - if (sessions.empty()) - { - // Let the guard die completely if everything's gone quiet. - guard->commit(); - guard.reset(); - } - } - } - catch (Netxx::NetworkException &e) - { - // If we tried with IPv6 and failed, we want to try again using IPv4. - if (try_again) - { - use_ipv6 = false; - } - // In all other cases, just rethrow the exception. + if (live_p && (event & Netxx::Probe::ready_oobd)) + { + P(F("got OOB from peer %s, disconnecting\n") + % sess->peer_id); + sessions.erase(i); + } + } + } + process_armed_sessions(sessions, armed_sessions, *guard); + reap_dead_sessions(sessions, timeout_seconds); + + if (sessions.empty()) + { + // Let the guard die completely if everything's gone quiet. + guard->commit(); + guard.reset(); + } + } + } + catch (Netxx::NetworkException &e) + { + // If we tried with IPv6 and failed, we want to try again using IPv4. + if (try_again) + { + use_ipv6 = false; + } + // In all other cases, just rethrow the exception. else throw; }