# # # patch "cmd_netsync.cc" # from [624019425573cc5ac20ad0628032d32b9085d718] # to [c84c1664d00926c4079d2c4b9643a9d6e42c6cc6] # # patch "netsync.cc" # from [f628b01320f3378a189993cc5aad2d6af825b4fc] # to [789d01de7c3f8c1985eb9069858603dcc9cc66ff] # ============================================================ --- cmd_netsync.cc 624019425573cc5ac20ad0628032d32b9085d718 +++ cmd_netsync.cc c84c1664d00926c4079d2c4b9643a9d6e42c6cc6 @@ -168,7 +168,7 @@ CMD_NO_WORKSPACE(serve, N_("network"), N_("PATTERN ..."), N_("serve the branches specified by PATTERNs to connecting clients"), - OPT_BIND % OPT_PIDFILE % OPT_EXCLUDE) + OPT_BIND % OPT_STDIO % OPT_PIDFILE % OPT_EXCLUDE) { if (args.size() < 1) throw usage(name); ============================================================ --- netsync.cc f628b01320f3378a189993cc5aad2d6af825b4fc +++ netsync.cc 789d01de7c3f8c1985eb9069858603dcc9cc66ff @@ -2433,7 +2433,7 @@ // 'false' here means not to revert changes when the SockOpt // goes out of scope. - Netxx::SockOpt socket_options(server.get_socketfd(), false); + Netxx::SockOpt socket_options(server->get_socketfd(), false); socket_options.set_non_blocking(); session sess(role, client_voice, @@ -2869,6 +2869,45 @@ } 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(); + } + } + } + // This exception is thrown when bind() fails somewhere in Netxx. + 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; + } + // This exception is thrown when there is no support for the type of + // connection we want to do in the kernel, for example when a socket() + // call fails somewhere in Netxx. + catch (Netxx::Exception &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; + } + } + while(try_again); +} + static void serve_single_connection(//protocol_role role, shared_ptr sess, @@ -2900,6 +2939,8 @@ // no addr, no server + transaction_guard guard(sess->app.db); + // bool live_p = true; while (!sessions.empty()) { @@ -2908,7 +2949,7 @@ arm_sessions_and_calculate_probe(probe, sessions, armed_sessions); - L(F("i/o probe with %d armed\n") % armed_sessions.size()); + 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)); @@ -2918,7 +2959,7 @@ if (fd == -1) { if (armed_sessions.empty()) - L(F("timed out waiting for I/O (listening on %s)\n") + L(FL("timed out waiting for I/O (listening on %s)\n") % sess->peer_id); } @@ -2929,7 +2970,7 @@ i = sessions.find(fd); if (i == sessions.end()) { - L(F("got woken up for action on unknown fd %d\n") % fd); + L(FL("got woken up for action on unknown fd %d\n") % fd); } else { @@ -2950,50 +2991,11 @@ } } } - process_armed_sessions(sessions, armed_sessions); + 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(); - } - } - } - // This exception is thrown when bind() fails somewhere in Netxx. - 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; - } - // This exception is thrown when there is no support for the type of - // connection we want to do in the kernel, for example when a socket() - // call fails somewhere in Netxx. - catch (Netxx::Exception &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; - } - } - while(try_again); -} - - void insert_with_parents(revision_id rev, refiner & ref,