Changeset 3049


Ignore:
Timestamp:
13/12/2011 00:43:41 (5 months ago)
Author:
chris
Message:

Add remote host and port to post-login login message, requested by Pete Jalajas.

Location:
box/trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • box/trunk/bin/bbstored/BackupStoreDaemon.cpp

    r3048 r3049  
    330330 
    331331        // Create a context, using this ID 
    332         BackupStoreContext context(id, *this); 
     332        BackupStoreContext context(id, *this, GetConnectionDetails()); 
    333333 
    334334        if (mpTestHook) 
  • box/trunk/lib/backupstore/BackupCommands.cpp

    r3048 r3049  
    132132                "(name=" << rContext.GetAccountName() << "): " << 
    133133                (((mFlags & Flags_ReadOnly) != Flags_ReadOnly) 
    134                 ?"Read/Write":"Read-only")); 
     134                        ?"Read/Write":"Read-only") << " from " << 
     135                rContext.GetConnectionDetails()); 
    135136 
    136137        // Get the usage info for reporting to the client 
  • box/trunk/lib/backupstore/BackupStoreContext.cpp

    r2983 r3049  
    5555// -------------------------------------------------------------------------- 
    5656BackupStoreContext::BackupStoreContext(int32_t ClientID, 
    57         HousekeepingInterface &rDaemon) 
    58         : mClientID(ClientID), 
     57        HousekeepingInterface &rDaemon, const std::string& rConnectionDetails) 
     58        : mConnectionDetails(rConnectionDetails), 
     59          mClientID(ClientID), 
    5960          mrDaemon(rDaemon), 
    6061          mProtocolPhase(Phase_START), 
  • box/trunk/lib/backupstore/BackupStoreContext.h

    r3048 r3049  
    4646{ 
    4747public: 
    48         BackupStoreContext(int32_t ClientID, HousekeepingInterface &rDaemon); 
     48        BackupStoreContext(int32_t ClientID, HousekeepingInterface &rDaemon, 
     49                const std::string& rConnectionDetails); 
    4950        ~BackupStoreContext(); 
    5051private: 
     
    138139        // Info 
    139140        int32_t GetClientID() const {return mClientID;} 
     141        const std::string& GetConnectionDetails() { return mConnectionDetails; } 
    140142 
    141143private: 
     
    147149        int64_t AllocateObjectID(); 
    148150 
     151        std::string mConnectionDetails; 
    149152        int32_t mClientID; 
    150153        HousekeepingInterface &mrDaemon; 
  • box/trunk/lib/server/ServerStream.h

    r2587 r3049  
    4949        { 
    5050        } 
     51 
     52        std::string mConnectionDetails; 
     53 
     54protected: 
     55        const std::string& GetConnectionDetails() 
     56        { 
     57                return mConnectionDetails; 
     58        } 
     59 
    5160public: 
    5261 
     
    123132protected: 
    124133        virtual void NotifyListenerIsReady() { } 
     134        virtual void LogConnectionDetails(std::string details) 
     135        { 
     136                BOX_NOTICE("Handling incoming connection from " << details); 
     137        } 
    125138         
    126139public: 
     
    238251                                        // Get the incoming connection 
    239252                                        // (with zero wait time) 
    240                                         std::string logMessage; 
    241                                         std::auto_ptr<StreamType> connection(psocket->Accept(0, &logMessage)); 
     253                                        std::auto_ptr<StreamType> connection( 
     254                                                psocket->Accept(0, 
     255                                                        &mConnectionDetails)); 
    242256 
    243257                                        // Was there one (there should be...) 
     
    265279                                                                EnterChild(); 
    266280                                                                SetProcessTitle("transaction"); 
     281                                                                LogConnectionDetails(mConnectionDetails); 
    267282                                                                 
    268283                                                                // Memory leak test the forked process 
     
    282297                                                         
    283298                                                        // Log it 
    284                                                         BOX_NOTICE("Message from child process " << pid << ": " << logMessage); 
     299                                                        BOX_TRACE("Forked child process " << pid <<  
     300                                                                "to handle connection from " << 
     301                                                                mConnectionDetails); 
    285302                                                } 
    286303                                                else 
  • box/trunk/lib/server/Socket.cpp

    r2424 r3049  
    124124void Socket::LogIncomingConnection(const struct sockaddr *addr, socklen_t addrlen) 
    125125{ 
    126         if(addr == NULL) {THROW_EXCEPTION(CommonException, BadArguments)} 
    127  
    128         switch(addr->sa_family) 
    129         { 
    130         case AF_UNIX: 
    131                 BOX_INFO("Incoming connection from local (UNIX socket)"); 
    132                 break;           
    133          
    134         case AF_INET: 
    135                 { 
    136                         sockaddr_in *a = (sockaddr_in*)addr; 
    137                         BOX_INFO("Incoming connection from " << 
    138                                 inet_ntoa(a->sin_addr) << " port " << 
    139                                 ntohs(a->sin_port)); 
    140                 } 
    141                 break;           
    142          
    143         default: 
    144                 BOX_WARNING("Incoming connection of unknown type"); 
    145                 break; 
    146         } 
     126        BOX_INFO("Incoming connection from " << 
     127                IncomingConnectionLogMessage(addr, addrlen)); 
    147128} 
    148129 
     
    162143        { 
    163144        case AF_UNIX: 
    164                 return std::string("Incoming connection from local (UNIX socket)"); 
     145                return std::string("local (UNIX socket)"); 
    165146                break;           
    166147         
    167148        case AF_INET: 
    168149                { 
    169                         char msg[256];  // more than enough 
    170150                        sockaddr_in *a = (sockaddr_in*)addr; 
    171                         sprintf(msg, "Incoming connection from %s port %d", inet_ntoa(a->sin_addr), ntohs(a->sin_port)); 
    172                         return std::string(msg); 
     151                        std::ostringstream oss; 
     152                        oss << inet_ntoa(a->sin_addr) << " port " << 
     153                                ntohs(a->sin_port); 
     154                        return oss.str(); 
    173155                } 
    174156                break;           
    175157         
    176158        default: 
    177                 return std::string("Incoming connection of unknown type"); 
     159                { 
     160                        std::ostringstream oss; 
     161                        oss << "unknown socket type " << addr->sa_family; 
     162                        return oss.str(); 
     163                } 
    178164                break; 
    179165        } 
Note: See TracChangeset for help on using the changeset viewer.