# # # patch "ChangeLog" # from [506b6a568f020ca2395531db6047ac80377609f4] # to [0e52a2f5bd000bf62e97cd6e3b31b305770e9f7a] # # patch "contrib/usher.cc" # from [feda742d0a0ae8051d1d00e989f3fa002cb3309b] # to [ef50473490a7b31e456df91abebade99b4eaa017] # ============================================================ --- ChangeLog 506b6a568f020ca2395531db6047ac80377609f4 +++ ChangeLog 0e52a2f5bd000bf62e97cd6e3b31b305770e9f7a @@ -1,5 +1,15 @@ 2006-04-21 Richard Levitte + * contrib/usher.cc (fork_server): Redirect the logs of the sub- + servers to log files instead of a pipe, and have the main + process read that file instead of the pipe. + (read_server_record): Complain about unrecognised commands, and + continue processing. + (reload_conffile): Parse the logdir command. Complain about + unrecognised commands, and continue processing. + +2006-04-21 Richard Levitte + * contrib/usher.cc (server::set_hosts, server::set_patterns): Explain a little more what is removed from what. ============================================================ --- contrib/usher.cc feda742d0a0ae8051d1d00e989f3fa002cb3309b +++ contrib/usher.cc ef50473490a7b31e456df91abebade99b4eaa017 @@ -22,6 +22,7 @@ // -p a file (deleted on program exit) to record the pid of the usher in // a file that looks like // userpass username password +// logdir directory // // server monotone // host localhost @@ -35,6 +36,7 @@ // // or in general, one block of one or more lines of // userpass +// logdir // followed by any number of blocks of a // server // line followed by one or more @@ -125,6 +127,8 @@ #include #include #include +#include +#include #include #include #include @@ -163,6 +167,7 @@ int listenport = 4691; string listenaddr = "0.0.0.0"; string monotone = "mtn"; +string logdir = "."; // keep local servers around for this many seconds after the last // client disconnects from them (only accurate to ~10 seconds) @@ -490,11 +495,17 @@ return s; } -int fork_server(vector const & args) +int fork_server(const string & name, vector const & args) { + string logfile = logdir + "/" + name + ".log"; int err[2]; - if (pipe(err) < 0) + if ((err[1]=creat(logfile.c_str(),0644)) < 0) return false; + if ((err[0]=open(logfile.c_str(),O_RDONLY)) < 0) + { + close(err[1]); + return false; + } int pid = fork(); if (pid == -1) { close(err[0]); @@ -507,9 +518,13 @@ close(1); close(2); sock::close_all_socks(); - if (dup2(err[1], 2) < 0) { + if (dup2(err[1], 1) < 0) { exit(1); } + close(err[1]); + if (dup2(1, 2) < 0) { + exit(1); + } char ** a = new char*[args.size()+1]; for (unsigned int i = 0; i < args.size(); ++i) { @@ -547,7 +562,8 @@ line = true; got += r; } - } while(r > 0 && !line && got < 256); + } while(r >= 0 && !line && got < 256); + close(err[0]); head[got] = 0; if (string(head).find("beginning service") != string::npos) return pid; @@ -774,6 +790,7 @@ vector args; args.push_back(monotone); args.push_back("serve"); + args.push_back("--ticker=dot"); args.push_back("--bind=" + addr + ":" + lexical_cast(port)); unsigned int n = 0, m = 0; n = arguments.find_first_not_of(" \t"); @@ -782,7 +799,7 @@ args.push_back(arguments.substr(n, m-n)); n = arguments.find_first_not_of(" ", m); } - pid = fork_server(args); + pid = fork_server(by_name->first,args); } } sock s = make_outgoing(port, addr); @@ -890,6 +907,10 @@ hosts.push_back(arg); else if (cmd == "pattern") patterns.push_back(arg); + else + cerr << "Unrecognised directive " << cmd << ", skipping line..." + << std::endl; + line = getline(in); } if (name.empty()) @@ -1176,9 +1197,20 @@ while (!line.empty()) { std::istringstream iss(line); string a, b, c; - iss>>a>>b>>c; + iss>>a; if (a == "userpass") - admins.insert(make_pair(b, c)); + { + iss>>b>>c; + admins.insert(make_pair(b, c)); + } + else if (a == "logdir") + { + iss>>b; + logdir = b; + } + else + cerr << "Unrecognised directive " << a << ", skipping line..." + << std::endl; line = getline(cf); }