Ignore:
Timestamp:
14/09/2007 23:12:28 (5 years ago)
Author:
chris
Message:

Added function to set the named pipe name, for use by any test which calls
HUPServer() or SendCommands?().

File:
1 edited

Legend:

Unmodified
Added
Removed
  • box/chris/general/lib/server/ServerControl.h

    r1526 r1836  
    1010#include "BoxPortsAndFiles.h" 
    1111 
     12static std::string sPipeName; 
     13 
     14static void SetNamedPipeName(const std::string& rPipeName) 
     15{ 
     16        sPipeName = rPipeName; 
     17} 
     18 
    1219static bool SendCommands(const std::string& rCmd) 
    1320{ 
     
    1623        try 
    1724        { 
    18                 connection.Connect(BOX_NAMED_PIPE_NAME); 
     25                connection.Connect(sPipeName); 
    1926        } 
    2027        catch(...) 
    2128        { 
    22                 printf("Failed to connect to daemon control socket.\n"); 
     29                BOX_ERROR("Failed to connect to daemon control socket"); 
    2330                return false; 
    2431        } 
     
    3138        if(!getLine.GetLine(configSummary)) 
    3239        { 
    33                 printf("Failed to receive configuration summary from daemon\n"); 
     40                BOX_ERROR("Failed to receive configuration summary from daemon"); 
    3441                return false; 
    3542        } 
     
    3845        if(getLine.IsEOF()) 
    3946        { 
    40                 printf("Server rejected the connection.\n"); 
     47                BOX_ERROR("Server rejected the connection"); 
    4148                return false; 
    4249        } 
     
    4855                        &minimumFileAge, &maxUploadWait) != 4) 
    4956        { 
    50                 printf("Config summary didn't decode\n"); 
     57                BOX_ERROR("Config summary didn't decode"); 
    5158                return false; 
    5259        } 
     
    8289                else if (line == "error") 
    8390                { 
    84                         printf("ERROR (%s)\n", rCmd.c_str()); 
     91                        BOX_ERROR(rCmd); 
    8592                        break; 
    8693                } 
    8794                else 
    8895                { 
    89                         printf("WARNING: Unexpected response to command '%s': " 
    90                                 "%s", rCmd.c_str(), line.c_str()); 
     96                        BOX_WARNING("Unexpected response to command '" << 
     97                                rCmd << "': " << line) 
    9198                } 
    9299        } 
     
    105112        if (hProcess == NULL) 
    106113        { 
    107                 printf("Failed to open process %d: error %d\n", 
    108                         pid, (int)GetLastError()); 
     114                BOX_ERROR("Failed to open process " << pid << ": " << 
     115                        GetErrorMessage(GetLastError())); 
    109116                return false; 
    110117        } 
     
    112119        if (!TerminateProcess(hProcess, 1)) 
    113120        { 
    114                 printf("Failed to terminate process %d: error %d\n", 
    115                         pid, (int)GetLastError()); 
     121                BOX_ERROR("Failed to terminate process " << pid << ": " << 
     122                        GetErrorMessage(GetLastError())); 
    116123                CloseHandle(hProcess); 
    117124                return false; 
Note: See TracChangeset for help on using the changeset viewer.