Changeset 7029 in vbox for trunk/src/libs/xpcom18a4/ipc/ipcd/daemon
- Timestamp:
- Feb 20, 2008 11:54:09 AM (17 years ago)
- Location:
- trunk/src/libs/xpcom18a4/ipc/ipcd/daemon/src
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/libs/xpcom18a4/ipc/ipcd/daemon/src/ipcClient.cpp
r1 r7029 96 96 } 97 97 98 void 98 PRBool 99 99 ipcClient::DelName(const char *name) 100 100 { 101 101 LOG(("deleting client name: %s\n", name)); 102 102 103 mNames.FindAndDelete(name);103 return mNames.FindAndDelete(name); 104 104 } 105 105 … … 115 115 } 116 116 117 void 117 PRBool 118 118 ipcClient::DelTarget(const nsID &target) 119 119 { … … 124 124 // 125 125 if (!target.Equals(IPCM_TARGET)) 126 mTargets.FindAndDelete(target); 126 return mTargets.FindAndDelete(target); 127 128 return PR_FALSE; 127 129 } 128 130 … … 185 187 } 186 188 } 187 189 188 190 if (inFlags & PR_POLL_WRITE) { 189 191 LOG(("client socket is now writable\n")); -
trunk/src/libs/xpcom18a4/ipc/ipcd/daemon/src/ipcClient.h
r1 r7029 65 65 66 66 void AddName(const char *name); 67 voidDelName(const char *name);67 PRBool DelName(const char *name); 68 68 PRBool HasName(const char *name) const { return mNames.Find(name) != NULL; } 69 69 70 70 void AddTarget(const nsID &target); 71 voidDelTarget(const nsID &target);71 PRBool DelTarget(const nsID &target); 72 72 PRBool HasTarget(const nsID &target) const { return mTargets.Find(target) != NULL; } 73 73 … … 96 96 // 97 97 // returns: 98 // 0 - to cancel client connection 98 // 0 - to cancel client connection 99 99 // PR_POLL_READ - to poll for a readable socket 100 100 // PR_POLL_WRITE - to poll for a writable socket … … 102 102 // 103 103 // the socket is non-blocking. 104 // 104 // 105 105 int Process(PRFileDesc *sockFD, int pollFlags); 106 106 … … 125 125 // encoded in it. 126 126 PRUint32 mPID; 127 127 128 128 // the hwnd of the client's message window. 129 129 HWND mHwnd; -
trunk/src/libs/xpcom18a4/ipc/ipcd/daemon/src/ipcCommandModule.cpp
r1 r7029 62 62 63 63 const ipcStringNode *node; 64 64 65 65 for (node = nodes; node; node = node->mNext) 66 66 count++; … … 84 84 85 85 const ipcIDNode *node; 86 86 87 87 for (node = nodes; node; node = node->mNext) 88 88 count++; … … 133 133 LOG(("got CLIENT_ADD_NAME\n")); 134 134 135 PRInt32 status = IPCM_OK; 136 PRUint32 requestIndex = IPCM_GetRequestIndex(rawMsg); 137 135 138 ipcMessageCast<ipcmMessageClientAddName> msg(rawMsg); 136 139 const char *name = msg->Name(); 137 if (name) 138 client->AddName(name); 139 140 // TODO: send better status code (e.g., suppose name already defined for client) 141 IPC_SendMsg(client, new ipcmMessageResult(IPCM_GetRequestIndex(rawMsg), IPCM_OK)); 140 if (name) { 141 ipcClient *result = IPC_GetClientByName(msg->Name()); 142 if (result) { 143 LOG((" client with such name already exists (ID = %d)\n", result->ID())); 144 status = IPCM_ERROR_ALREADY_EXISTS; 145 } 146 else 147 client->AddName(name); 148 } 149 else 150 status = IPCM_ERROR_INVALID_ARG; 151 152 IPC_SendMsg(client, new ipcmMessageResult(requestIndex, status)); 142 153 } 143 154 … … 146 157 { 147 158 LOG(("got CLIENT_DEL_NAME\n")); 159 160 PRInt32 status = IPCM_OK; 161 PRUint32 requestIndex = IPCM_GetRequestIndex(rawMsg); 148 162 149 163 ipcMessageCast<ipcmMessageClientDelName> msg(rawMsg); 150 164 const char *name = msg->Name(); 151 if (name) 152 client->DelName(name); 153 154 // TODO: send better status code (e.g., suppose name not defined for client) 155 IPC_SendMsg(client, new ipcmMessageResult(IPCM_GetRequestIndex(rawMsg), IPCM_OK)); 165 if (name) { 166 if (!client->DelName(name)) { 167 LOG((" client doesn't have name '%s'\n", name)); 168 status = IPCM_ERROR_NO_SUCH_DATA; 169 } 170 } 171 else 172 status = IPCM_ERROR_INVALID_ARG; 173 174 IPC_SendMsg(client, new ipcmMessageResult(requestIndex, status)); 156 175 } 157 176 … … 161 180 LOG(("got CLIENT_ADD_TARGET\n")); 162 181 182 PRInt32 status = IPCM_OK; 183 PRUint32 requestIndex = IPCM_GetRequestIndex(rawMsg); 184 163 185 ipcMessageCast<ipcmMessageClientAddTarget> msg(rawMsg); 164 client->AddTarget(msg->Target()); 165 166 // TODO: send better status code (e.g., suppose target already defined for client) 167 IPC_SendMsg(client, new ipcmMessageResult(IPCM_GetRequestIndex(rawMsg), IPCM_OK)); 186 if (client->HasTarget(msg->Target())) { 187 LOG((" target already defined for client\n")); 188 status = IPCM_ERROR_ALREADY_EXISTS; 189 } 190 else 191 client->AddTarget(msg->Target()); 192 193 IPC_SendMsg(client, new ipcmMessageResult(requestIndex, status)); 168 194 } 169 195 … … 173 199 LOG(("got CLIENT_DEL_TARGET\n")); 174 200 201 PRInt32 status = IPCM_OK; 202 PRUint32 requestIndex = IPCM_GetRequestIndex(rawMsg); 203 175 204 ipcMessageCast<ipcmMessageClientDelTarget> msg(rawMsg); 176 client->DelTarget(msg->Target()); 177 178 // TODO: send better status code (e.g., suppose target not defined for client) 179 IPC_SendMsg(client, new ipcmMessageResult(IPCM_GetRequestIndex(rawMsg), IPCM_OK)); 205 if (!client->DelTarget(msg->Target())) { 206 LOG((" client doesn't have the given target\n")); 207 status = IPCM_ERROR_NO_SUCH_DATA; 208 } 209 210 IPC_SendMsg(client, new ipcmMessageResult(requestIndex, status)); 180 211 } 181 212 … … 222 253 else { 223 254 LOG((" client does not exist\n")); 224 IPC_SendMsg(client, new ipcmMessageError(IPCM_ERROR_ CLIENT_NOT_FOUND, msg->RequestIndex()));255 IPC_SendMsg(client, new ipcmMessageError(IPCM_ERROR_NO_CLIENT, msg->RequestIndex())); 225 256 } 226 257 } … … 278 309 type--; 279 310 if (type < 0 || type >= (int) (sizeof(handlers)/sizeof(handlers[0]))) { 280 LOG(("unknown request -- ignoring message\n")); 311 LOG(("unknown request -- ignoring message\n")); 281 312 return; 282 313 }
Note:
See TracChangeset
for help on using the changeset viewer.