Changeset 3049
- Timestamp:
- 13/12/2011 00:43:41 (5 months ago)
- Location:
- box/trunk
- Files:
-
- 6 edited
-
bin/bbstored/BackupStoreDaemon.cpp (modified) (1 diff)
-
lib/backupstore/BackupCommands.cpp (modified) (1 diff)
-
lib/backupstore/BackupStoreContext.cpp (modified) (1 diff)
-
lib/backupstore/BackupStoreContext.h (modified) (3 diffs)
-
lib/server/ServerStream.h (modified) (5 diffs)
-
lib/server/Socket.cpp (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
box/trunk/bin/bbstored/BackupStoreDaemon.cpp
r3048 r3049 330 330 331 331 // Create a context, using this ID 332 BackupStoreContext context(id, *this );332 BackupStoreContext context(id, *this, GetConnectionDetails()); 333 333 334 334 if (mpTestHook) -
box/trunk/lib/backupstore/BackupCommands.cpp
r3048 r3049 132 132 "(name=" << rContext.GetAccountName() << "): " << 133 133 (((mFlags & Flags_ReadOnly) != Flags_ReadOnly) 134 ?"Read/Write":"Read-only")); 134 ?"Read/Write":"Read-only") << " from " << 135 rContext.GetConnectionDetails()); 135 136 136 137 // Get the usage info for reporting to the client -
box/trunk/lib/backupstore/BackupStoreContext.cpp
r2983 r3049 55 55 // -------------------------------------------------------------------------- 56 56 BackupStoreContext::BackupStoreContext(int32_t ClientID, 57 HousekeepingInterface &rDaemon) 58 : mClientID(ClientID), 57 HousekeepingInterface &rDaemon, const std::string& rConnectionDetails) 58 : mConnectionDetails(rConnectionDetails), 59 mClientID(ClientID), 59 60 mrDaemon(rDaemon), 60 61 mProtocolPhase(Phase_START), -
box/trunk/lib/backupstore/BackupStoreContext.h
r3048 r3049 46 46 { 47 47 public: 48 BackupStoreContext(int32_t ClientID, HousekeepingInterface &rDaemon); 48 BackupStoreContext(int32_t ClientID, HousekeepingInterface &rDaemon, 49 const std::string& rConnectionDetails); 49 50 ~BackupStoreContext(); 50 51 private: … … 138 139 // Info 139 140 int32_t GetClientID() const {return mClientID;} 141 const std::string& GetConnectionDetails() { return mConnectionDetails; } 140 142 141 143 private: … … 147 149 int64_t AllocateObjectID(); 148 150 151 std::string mConnectionDetails; 149 152 int32_t mClientID; 150 153 HousekeepingInterface &mrDaemon; -
box/trunk/lib/server/ServerStream.h
r2587 r3049 49 49 { 50 50 } 51 52 std::string mConnectionDetails; 53 54 protected: 55 const std::string& GetConnectionDetails() 56 { 57 return mConnectionDetails; 58 } 59 51 60 public: 52 61 … … 123 132 protected: 124 133 virtual void NotifyListenerIsReady() { } 134 virtual void LogConnectionDetails(std::string details) 135 { 136 BOX_NOTICE("Handling incoming connection from " << details); 137 } 125 138 126 139 public: … … 238 251 // Get the incoming connection 239 252 // (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)); 242 256 243 257 // Was there one (there should be...) … … 265 279 EnterChild(); 266 280 SetProcessTitle("transaction"); 281 LogConnectionDetails(mConnectionDetails); 267 282 268 283 // Memory leak test the forked process … … 282 297 283 298 // 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); 285 302 } 286 303 else -
box/trunk/lib/server/Socket.cpp
r2424 r3049 124 124 void Socket::LogIncomingConnection(const struct sockaddr *addr, socklen_t addrlen) 125 125 { 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)); 147 128 } 148 129 … … 162 143 { 163 144 case AF_UNIX: 164 return std::string(" Incoming connection fromlocal (UNIX socket)");145 return std::string("local (UNIX socket)"); 165 146 break; 166 147 167 148 case AF_INET: 168 149 { 169 char msg[256]; // more than enough170 150 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(); 173 155 } 174 156 break; 175 157 176 158 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 } 178 164 break; 179 165 }
Note: See TracChangeset
for help on using the changeset viewer.
