- Timestamp:
- Jun 7, 2010 7:57:21 AM (15 years ago)
- Location:
- trunk/src/libs/xpcom18a4/ipc/ipcd/client
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/libs/xpcom18a4/ipc/ipcd/client/public/ipcdclient.h
r1 r30052 68 68 NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_GENERAL, 10) 69 69 70 #ifdef VBOX 71 /* This error code can only be returned by the selector functions called by 72 * WaitTarget. The message should be dropped without processing. */ 73 #define IPC_DISCARD_MESSAGE \ 74 NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_GENERAL, 12) 75 #endif /* VBOX */ 76 70 77 /* This error code is returned by IPC_WaitMessage under certain conditions. */ 71 78 #define IPC_ERROR_WOULD_BLOCK NS_BASE_STREAM_WOULD_BLOCK … … 99 106 * the IPC_WaitMessage function, that will immediately fail with an error. 100 107 * OnClientStateChange is called on the same thread where this function is 101 * called. 108 * called. 102 109 * 103 110 * @returns NS_ERROR_NOT_INITIALIZED if IPC_Init has not been called or if -
trunk/src/libs/xpcom18a4/ipc/ipcd/client/src/ipcdclient.cpp
r26582 r30052 289 289 // message target. the selector is called while inside the target's monitor. 290 290 291 typedef PRBool(* ipcMessageSelector)(291 typedef nsresult (* ipcMessageSelector)( 292 292 void *arg, 293 293 ipcTargetData *td, … … 296 296 297 297 // selects any 298 static PRBool298 static nsresult 299 299 DefaultSelector(void *arg, ipcTargetData *td, const ipcMessage *msg) 300 300 { 301 return PR_TRUE;301 return NS_OK; 302 302 } 303 303 … … 379 379 { 380 380 lastChecked->SetFlag(IPC_MSG_FLAG_IN_PROCESS); 381 PRBool accepted= (aSelector)(aArg, td, lastChecked);381 nsresult acceptedRV = (aSelector)(aArg, td, lastChecked); 382 382 lastChecked->ClearFlag(IPC_MSG_FLAG_IN_PROCESS); 383 383 384 if (accepted )384 if (acceptedRV != IPC_WAIT_NEXT_MESSAGE) 385 385 { 386 386 // remove from pending queue … … 389 389 else 390 390 td->pendingQ.RemoveFirst(); 391 lastChecked->mNext = nsnull; 392 393 *aMsg = lastChecked; 394 break; 391 392 if (acceptedRV != IPC_DISCARD_MESSAGE) 393 { 394 lastChecked->mNext = nsnull; 395 *aMsg = lastChecked; 396 break; 397 } 395 398 } 396 399 } … … 411 414 * This is necessary as there might be several threads waiting for 412 415 * a message from a single client, and only one gets the DOWN msg. */ 413 PRBool alive= (aSelector)(aArg, td, NULL);414 if ( !alive)416 nsresult aliveRV = (aSelector)(aArg, td, NULL); 417 if (aliveRV != IPC_WAIT_NEXT_MESSAGE) 415 418 { 416 419 *aMsg = NULL; … … 598 601 599 602 // selects the next IPCM message with matching request index 600 static PRBool603 static nsresult 601 604 WaitIPCMResponseSelector(void *arg, ipcTargetData *td, const ipcMessage *msg) 602 605 { 603 606 #ifdef VBOX 604 607 if (!msg) 605 return PR_TRUE;608 return IPC_WAIT_NEXT_MESSAGE; 606 609 #endif /* VBOX */ 607 610 PRUint32 requestIndex = *(PRUint32 *) arg; 608 return IPCM_GetRequestIndex(msg) == requestIndex ;611 return IPCM_GetRequestIndex(msg) == requestIndex ? NS_OK : IPC_WAIT_NEXT_MESSAGE; 609 612 } 610 613 … … 929 932 }; 930 933 931 static PRBoolWaitMessageSelector(void *arg, ipcTargetData *td, const ipcMessage *msg)934 static nsresult WaitMessageSelector(void *arg, ipcTargetData *td, const ipcMessage *msg) 932 935 { 933 936 WaitMessageSelectorData *data = (WaitMessageSelectorData *) arg; … … 944 947 nsresult rv = obs->OnMessageAvailable(IPC_SENDER_ANY, nsID(), 0, 0); 945 948 if (rv != IPC_WAIT_NEXT_MESSAGE) 946 {947 949 data->senderDead = PR_TRUE; 948 return PR_FALSE; 949 } 950 return PR_TRUE; 950 951 return rv; 951 952 } 952 953 #endif /* VBOX */ … … 975 976 976 977 data->senderDead = PR_TRUE; 977 return PR_TRUE; // consume the message978 return IPC_DISCARD_MESSAGE; // consume the message 978 979 } 979 980 else … … 990 991 nsresult rv = obs->OnMessageAvailable(status->ClientID(), nsID(), 0, 0); 991 992 if (rv != IPC_WAIT_NEXT_MESSAGE) 992 {993 993 data->senderDead = PR_TRUE; 994 return PR_TRUE; // consume the message 995 }994 995 return IPC_DISCARD_MESSAGE; // consume the message 996 996 } 997 997 } … … 1019 1019 * this case. A client ID wraparound can't falsely trigger 1020 1020 * this, since the waiting thread would have hit the liveness 1021 * check in the mean time. Also, DO NOT consume the message,1022 * otherwise it gets passed to the DConnect message handling1023 * without any further checks. IPCM messages are automatically1024 * discarded if they are left unclaimed. */1021 * check in the mean time. We MUST consume the message, otherwise 1022 * IPCM messages pile up as long as there is a pending call, which 1023 * can lead to severe processing overhead. */ 1024 return IPC_DISCARD_MESSAGE; // consume the message 1025 1025 } 1026 1026 } … … 1031 1031 NS_NOTREACHED("unexpected message"); 1032 1032 } 1033 return PR_FALSE; // continue iterating1033 return IPC_WAIT_NEXT_MESSAGE; // continue iterating 1034 1034 } 1035 1035 … … 1051 1051 1052 1052 // stop iterating if we got a match that the observer accepted. 1053 return rv != IPC_WAIT_NEXT_MESSAGE ;1053 return rv != IPC_WAIT_NEXT_MESSAGE ? NS_OK : IPC_WAIT_NEXT_MESSAGE; 1054 1054 } 1055 1055
Note:
See TracChangeset
for help on using the changeset viewer.