Changeset 2597


Ignore:
Timestamp:
24/01/2010 13:46:23 (2 years ago)
Author:
chris
Message:

Revert the quotes part of [2588] as it breaks the unit tests.

Make LocalProcessStream? constructor take a std::string& for C++ style.

Location:
box/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • box/trunk/bin/bbackupd/BackupDaemon.cpp

    r2588 r2597  
    10181018        int waitInSeconds = (60*5); 
    10191019 
     1020        std::string script(conf.GetKeyValue("SyncAllowScript") +  
     1021                " \"" + GetConfigFileName() + "\""); 
     1022 
    10201023        // Run it? 
    10211024        pid_t pid = 0; 
    10221025        try 
    10231026        { 
    1024                 std::string script("\"" + conf.GetKeyValue("SyncAllowScript") +  
    1025                         "\" \"" + GetConfigFileName() + "\""); 
    1026  
    1027                 std::auto_ptr<IOStream> pscript(LocalProcessStream( 
    1028                         script.c_str(), pid)); 
     1027                std::auto_ptr<IOStream> pscript(LocalProcessStream(script, 
     1028                        pid)); 
    10291029 
    10301030                // Read in the result 
     
    10491049                                { 
    10501050                                        BOX_ERROR("Invalid output from " 
    1051                                                 "SyncAllowScript " << 
    1052                                                 script << ": '" << line << "'"); 
     1051                                                "SyncAllowScript: '" << 
     1052                                                line << "' (" << script << ")"); 
    10531053                                        throw; 
    10541054                                } 
    10551055 
    10561056                                BOX_NOTICE("Delaying sync by " << waitInSeconds 
    1057                                         << " seconds (SyncAllowScript " 
    1058                                         << conf.GetKeyValue("SyncAllowScript") 
    1059                                         << ")"); 
     1057                                        << " seconds due to SyncAllowScript " 
     1058                                        << "(" << script << ")"); 
    10601059                        } 
    10611060                } 
     
    10651064        { 
    10661065                BOX_ERROR("Internal error running SyncAllowScript: " 
    1067                         << e.what()); 
     1066                        << e.what() << " (" << script << ")"); 
    10681067        } 
    10691068        catch(...) 
     
    10711070                // Ignore any exceptions 
    10721071                // Log that something bad happened 
    1073                 BOX_ERROR("Error running SyncAllowScript '" 
    1074                         << conf.GetKeyValue("SyncAllowScript") << "'"); 
     1072                BOX_ERROR("Unknown error running SyncAllowScript (" << 
     1073                        script << ")"); 
    10751074        } 
    10761075 
     
    21892188                { 
    21902189                        BOX_INFO("Not notifying administrator about event " 
    2191                                 << sEventNames[Event] << " -- set NotifyScript " 
     2190                                << sEventNames[Event] << ", set NotifyScript " 
    21922191                                "to do this in future"); 
    21932192                } 
     
    21962195 
    21972196        // Script to run 
    2198         std::string script("\"" + conf.GetKeyValue("NotifyScript") + "\" " + 
     2197        std::string script(conf.GetKeyValue("NotifyScript") + " " + 
    21992198                sEventNames[Event] + " \"" + GetConfigFileName() + "\""); 
    22002199         
    22012200        // Log what we're about to do 
    22022201        BOX_INFO("About to notify administrator about event " 
    2203                 << sEventNames[Event] << ", running script " << script); 
     2202                << sEventNames[Event] << ", running script '" << script << "'"); 
    22042203         
    22052204        // Then do it 
  • box/trunk/lib/server/LocalProcessStream.cpp

    r1822 r2597  
    4444// 
    4545// -------------------------------------------------------------------------- 
    46 std::auto_ptr<IOStream> LocalProcessStream(const char *CommandLine, pid_t &rPidOut) 
     46std::auto_ptr<IOStream> LocalProcessStream(const std::string& rCommandLine, 
     47        pid_t &rPidOut) 
    4748{ 
    4849#ifndef WIN32 
     
    5051        // Split up command 
    5152        std::vector<std::string> command; 
    52         SplitString(std::string(CommandLine), ' ', command); 
     53        SplitString(rCommandLine, ' ', command); 
    5354 
    5455        // Build arguments 
     
    138139        startupInfo.dwFlags   |= STARTF_USESTDHANDLES; 
    139140 
    140         CHAR* commandLineCopy = (CHAR*)malloc(strlen(CommandLine) + 1); 
    141         strcpy(commandLineCopy, CommandLine); 
     141        CHAR* commandLineCopy = (CHAR*)malloc(rCommandLine.size() + 1); 
     142        strcpy(commandLineCopy, rCommandLine.c_str()); 
    142143 
    143144        BOOL result = CreateProcess(NULL,  
     
    156157        if(!result) 
    157158        { 
    158                 BOX_ERROR("Failed to CreateProcess: '" << CommandLine << 
     159                BOX_ERROR("Failed to CreateProcess: '" << rCommandLine << 
    159160                        "': " << GetErrorMessage(GetLastError())); 
    160161                CloseHandle(writeInChild); 
  • box/trunk/lib/server/LocalProcessStream.h

    r217 r2597  
    1414#include "IOStream.h" 
    1515 
    16 std::auto_ptr<IOStream> LocalProcessStream(const char *CommandLine, pid_t &rPidOut); 
     16std::auto_ptr<IOStream> LocalProcessStream(const std::string& rCommandLine, 
     17        pid_t &rPidOut); 
    1718 
    1819#endif // LOCALPROCESSSTREAM__H 
Note: See TracChangeset for help on using the changeset viewer.