Changeset 39498 in vbox
- Timestamp:
- Dec 1, 2011 7:59:21 PM (13 years ago)
- Location:
- trunk
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/iprt/mangling.h
r39447 r39498 1016 1016 # define RTRandU64 RT_MANGLER(RTRandU64) 1017 1017 # define RTRandU64Ex RT_MANGLER(RTRandU64Ex) 1018 # define RTReq Alloc RT_MANGLER(RTReqAlloc)1019 # define RTReq Call RT_MANGLER(RTReqCall)1020 # define RTReq CallEx RT_MANGLER(RTReqCallEx)1021 # define RTReq CallV RT_MANGLER(RTReqCallV)1022 # define RTReq CallVoid RT_MANGLER(RTReqCallVoid)1023 # define RTReq CreateQueue RT_MANGLER(RTReqCreateQueue)1024 # define RTReq DestroyQueue RT_MANGLER(RTReqDestroyQueue)1018 # define RTReqQueueAlloc RT_MANGLER(RTReqQueueAlloc) 1019 # define RTReqQueueCall RT_MANGLER(RTReqQueueCall) 1020 # define RTReqQueueCallEx RT_MANGLER(RTReqQueueCallEx) 1021 # define RTReqQueueCallV RT_MANGLER(RTReqQueueCallV) 1022 # define RTReqQueueCallVoid RT_MANGLER(RTReqQueueCallVoid) 1023 # define RTReqQueueCreate RT_MANGLER(RTReqQueueCreate) 1024 # define RTReqQueueDestroy RT_MANGLER(RTReqQueueDestroy) 1025 1025 # define RTReqFree RT_MANGLER(RTReqFree) 1026 # define RTReq IsBusy RT_MANGLER(RTReqIsBusy)1027 # define RTReq Process RT_MANGLER(RTReqProcess)1028 # define RTReq Queue RT_MANGLER(RTReqQueue)1026 # define RTReqQueueIsBusy RT_MANGLER(RTReqQueueIsBusy) 1027 # define RTReqQueueProcess RT_MANGLER(RTReqQueueProcess) 1028 # define RTReqSubmit RT_MANGLER(RTReqSubmit) 1029 1029 # define RTReqWait RT_MANGLER(RTReqWait) 1030 1030 # define RTS3BucketsDestroy RT_MANGLER(RTS3BucketsDestroy) -
trunk/include/iprt/req.h
r33540 r39498 1 1 /** @file 2 * IPRT - Request packets2 * IPRT - Request Queue & Pool. 3 3 */ 4 4 5 5 /* 6 * Copyright (C) 2006-20 07Oracle Corporation6 * Copyright (C) 2006-2011 Oracle Corporation 7 7 * 8 8 * This file is part of VirtualBox Open Source Edition (OSE), as … … 34 34 RT_C_DECLS_BEGIN 35 35 36 /** @defgroup grp_rt_req RTReq - Request Packet Management36 /** @defgroup grp_rt_req RTReq - Request Queue & Pool. 37 37 * @ingroup grp_rt 38 38 * @{ 39 39 */ 40 41 /** Request queue handle. */ 42 typedef struct RTREQQUEUEINT *RTREQQUEUE; 43 /** Pointer to a request queue handle. */ 44 typedef RTREQQUEUE *PRTREQQUEUE; 45 /** NIL request queue handle. */ 46 #define NIL_RTREQQUEUE ((RTREQQUEUE)0) 47 48 /** Request thread pool handle. */ 49 typedef struct RTREQPOOLINT *RTREQPOOL; 50 /** Poiner to a request thread pool handle. */ 51 typedef RTREQPOOL *PRTREQPOOL; 52 /** NIL request pool handle. */ 53 #define NIL_RTREQPOOL ((RTREQPOOL)0) 54 40 55 41 56 /** … … 86 101 } RTREQFLAGS; 87 102 88 /** Pointer to a request queue. */89 typedef struct RTREQQUEUE *PRTREQQUEUE;90 103 91 104 /** … … 99 112 struct RTREQ * volatile pNext; 100 113 /** Pointer to the queue this packet belongs to. */ 101 PRTREQQUEUE pQueue;114 RTREQQUEUE hQueue; 102 115 /** Request state. */ 103 116 volatile RTREQSTATE enmState; … … 133 146 typedef RTREQ *PRTREQ; 134 147 135 /** @todo hide this */136 typedef struct RTREQQUEUE137 {138 /** Head of the request queue. Atomic. */139 volatile PRTREQ pReqs;140 /** The last index used during alloc/free. */141 volatile uint32_t iReqFree;142 /** Number of free request packets. */143 volatile uint32_t cReqFree;144 /** Array of pointers to lists of free request packets. Atomic. */145 volatile PRTREQ apReqFree[9];146 /** Requester event sem.147 * The request can use this event semaphore to wait/poll for new requests.148 */149 RTSEMEVENT EventSem;150 /** Set if busy (pending or processing requests). */151 bool volatile fBusy;152 } RTREQQUEUE;153 148 154 149 #ifdef IN_RING3 … … 158 153 * 159 154 * @returns iprt status code. 160 * @param ppQueue Where to store the request queue pointer. 161 */ 162 RTDECL(int) RTReqCreateQueue(PRTREQQUEUE *ppQueue); 163 155 * @param phQueue Where to store the request queue handle. 156 */ 157 RTDECL(int) RTReqQueueCreate(PRTREQQUEUE phQueue); 164 158 165 159 /** … … 167 161 * 168 162 * @returns iprt status code. 169 * @param pQueue The request queue. 170 */ 171 RTDECL(int) RTReqDestroyQueue(PRTREQQUEUE pQueue); 172 163 * @param hQueue The request queue. 164 */ 165 RTDECL(int) RTReqQueueDestroy(RTREQQUEUE hQueue); 173 166 174 167 /** … … 178 171 * @returns VERR_TIMEOUT if cMillies was reached without the packet being added. 179 172 * 180 * @param pQueue The request queue.173 * @param hQueue The request queue. 181 174 * @param cMillies Number of milliseconds to wait for a pending request. 182 175 * Use RT_INDEFINITE_WAIT to only wait till one is added. 183 176 */ 184 RTDECL(int) RTReqProcess(PRTREQQUEUE pQueue, RTMSINTERVAL cMillies); 185 177 RTDECL(int) RTReqQueueProcess(RTREQQUEUE hQueue, RTMSINTERVAL cMillies); 186 178 187 179 /** … … 197 189 * @returns VERR_TIMEOUT if cMillies was reached without the packet being completed. 198 190 * 199 * @param pQueue The request queue.191 * @param hQueue The request queue. 200 192 * @param ppReq Where to store the pointer to the request. 201 193 * This will be NULL or a valid request pointer not matter what happens. … … 207 199 * @param ... Function arguments. 208 200 * 209 * @remarks See remarks on RTReqCallV. 210 */ 211 RTDECL(int) RTReqCall(PRTREQQUEUE pQueue, PRTREQ *ppReq, RTMSINTERVAL cMillies, PFNRT pfnFunction, unsigned cArgs, ...); 212 201 * @remarks See remarks on RTReqQueueCallV. 202 */ 203 RTDECL(int) RTReqQueueCall(RTREQQUEUE hQueue, PRTREQ *ppReq, RTMSINTERVAL cMillies, PFNRT pfnFunction, unsigned cArgs, ...); 213 204 214 205 /** … … 224 215 * @returns VERR_TIMEOUT if cMillies was reached without the packet being completed. 225 216 * 226 * @param pQueue The request queue.217 * @param hQueue The request queue. 227 218 * @param ppReq Where to store the pointer to the request. 228 219 * This will be NULL or a valid request pointer not matter what happens. … … 234 225 * @param ... Function arguments. 235 226 * 236 * @remarks See remarks on RTReqCallV. 237 */ 238 RTDECL(int) RTReqCallVoid(PRTREQQUEUE pQueue, PRTREQ *ppReq, RTMSINTERVAL cMillies, PFNRT pfnFunction, unsigned cArgs, ...); 239 227 * @remarks See remarks on RTReqQueueCallV. 228 */ 229 RTDECL(int) RTReqQueueCallVoid(RTREQQUEUE hQueue, PRTREQ *ppReq, RTMSINTERVAL cMillies, PFNRT pfnFunction, unsigned cArgs, ...); 240 230 241 231 /** … … 251 241 * @returns VERR_TIMEOUT if cMillies was reached without the packet being completed. 252 242 * 253 * @param pQueue The request queue.243 * @param hQueue The request queue. 254 244 * @param ppReq Where to store the pointer to the request. 255 245 * This will be NULL or a valid request pointer not matter what happens, unless fFlags … … 263 253 * @param ... Function arguments. 264 254 * 265 * @remarks See remarks on RTReqCallV. 266 */ 267 RTDECL(int) RTReqCallEx(PRTREQQUEUE pQueue, PRTREQ *ppReq, RTMSINTERVAL cMillies, unsigned fFlags, PFNRT pfnFunction, unsigned cArgs, ...); 268 255 * @remarks See remarks on RTReqQueueCallV. 256 */ 257 RTDECL(int) RTReqQueueCallEx(RTREQQUEUE hQueue, PRTREQ *ppReq, RTMSINTERVAL cMillies, unsigned fFlags, PFNRT pfnFunction, unsigned cArgs, ...); 269 258 270 259 /** … … 280 269 * @returns VERR_TIMEOUT if cMillies was reached without the packet being completed. 281 270 * 282 * @param pQueue The request queue.271 * @param hQueue The request queue. 283 272 * @param ppReq Where to store the pointer to the request. 284 273 * This will be NULL or a valid request pointer not matter what happens, unless fFlags … … 301 290 * Use (void *)NULL or (uintptr_t)0 instead of NULL. 302 291 */ 303 RTDECL(int) RTReqCallV(PRTREQQUEUE pQueue, PRTREQ *ppReq, RTMSINTERVAL cMillies, unsigned fFlags, PFNRT pfnFunction, unsigned cArgs, va_list Args); 304 292 RTDECL(int) RTReqQueueCallV(RTREQQUEUE hQueue, PRTREQ *ppReq, RTMSINTERVAL cMillies, unsigned fFlags, PFNRT pfnFunction, unsigned cArgs, va_list Args); 293 294 /** 295 * Checks if the queue is busy or not. 296 * 297 * The caller is responsible for dealing with any concurrent submitts. 298 * 299 * @returns true if busy, false if idle. 300 * @param hQueue The queue. 301 */ 302 RTDECL(bool) RTReqQueueIsBusy(RTREQQUEUE hQueue); 305 303 306 304 /** … … 312 310 * @returns iprt status code. 313 311 * 314 * @param pQueue The request queue.312 * @param hQueue The request queue. 315 313 * @param ppReq Where to store the pointer to the allocated packet. 316 314 * @param enmType Package type. 317 315 */ 318 RTDECL(int) RTReq Alloc(PRTREQQUEUE pQueue, PRTREQ *ppReq, RTREQTYPE enmType);316 RTDECL(int) RTReqQueueAlloc(RTREQQUEUE hQueue, PRTREQ *ppReq, RTREQTYPE enmType); 319 317 320 318 … … 333 331 * Queue a request. 334 332 * 335 * The quest must be allocated using RTReqAlloc() and contain 336 * all the required data. 333 * The quest must be allocated using RTReqQueueAlloc() or RTReqPoolAlloc() and 334 * contain all the required data. 335 * 337 336 * If it's desired to poll on the completion of the request set cMillies 338 337 * to 0 and use RTReqWait() to check for completion. In the other case … … 348 347 * wait till it's completed. 349 348 */ 350 RTDECL(int) RTReq Queue(PRTREQ pReq, RTMSINTERVAL cMillies);349 RTDECL(int) RTReqSubmit(PRTREQ pReq, RTMSINTERVAL cMillies); 351 350 352 351 … … 364 363 RTDECL(int) RTReqWait(PRTREQ pReq, RTMSINTERVAL cMillies); 365 364 366 /**367 * Checks if the queue is busy or not.368 *369 * The caller is responsible for dealing with any concurrent submitts.370 *371 * @returns true if busy, false if idle.372 * @param pQueue The queue.373 */374 RTDECL(bool) RTReqIsBusy(PRTREQQUEUE pQueue);375 365 376 366 #endif /* IN_RING3 */ -
trunk/src/VBox/Devices/Network/DrvNAT.cpp
r39465 r39498 154 154 PPDMTHREAD pSlirpThread; 155 155 /** Queue for NAT-thread-external events. */ 156 PRTREQQUEUE pSlirpReqQueue;156 RTREQQUEUE hSlirpReqQueue; 157 157 /** The guest IP for port-forwarding. */ 158 158 uint32_t GuestIP; … … 185 185 RTSEMEVENT EventUrgRecv; 186 186 /** Receive Req queue (deliver packets to the guest) */ 187 PRTREQQUEUE pRecvReqQueue;187 RTREQQUEUE hRecvReqQueue; 188 188 /** Receive Urgent Req queue (deliver packets to the guest). */ 189 PRTREQQUEUE pUrgRecvReqQueue;189 RTREQQUEUE hUrgRecvReqQueue; 190 190 191 191 /** makes access to device func RecvAvail and Recv atomical. */ … … 219 219 while (pThread->enmState == PDMTHREADSTATE_RUNNING) 220 220 { 221 RTReq Process(pThis->pRecvReqQueue, 0);221 RTReqQueueProcess(pThis->hRecvReqQueue, 0); 222 222 if (ASMAtomicReadU32(&pThis->cPkts) == 0) 223 223 RTSemEventWait(pThis->EventRecv, RT_INDEFINITE_WAIT); … … 246 246 while (pThread->enmState == PDMTHREADSTATE_RUNNING) 247 247 { 248 RTReq Process(pThis->pUrgRecvReqQueue, 0);248 RTReqQueueProcess(pThis->hUrgRecvReqQueue, 0); 249 249 if (ASMAtomicReadU32(&pThis->cUrgPkts) == 0) 250 250 { … … 535 535 536 536 #ifdef VBOX_WITH_SLIRP_MT 537 PRTREQQUEUE pQueue = (PRTREQQUEUE)slirp_get_queue(pThis->pNATState);537 RTREQQUEUE hQueue = (RTREQQUEUE)slirp_get_queue(pThis->pNATState); 538 538 #else 539 PRTREQQUEUE pQueue = pThis->pSlirpReqQueue;539 RTREQQUEUE hQueue = pThis->hSlirpReqQueue; 540 540 #endif 541 rc = RTReq CallEx(pQueue, NULL /*ppReq*/, 0 /*cMillies*/, RTREQFLAGS_VOID | RTREQFLAGS_NO_WAIT,542 (PFNRT)drvNATSendWorker, 2, pThis, pSgBuf);541 rc = RTReqQueueCallEx(hQueue, NULL /*ppReq*/, 0 /*cMillies*/, RTREQFLAGS_VOID | RTREQFLAGS_NO_WAIT, 542 (PFNRT)drvNATSendWorker, 2, pThis, pSgBuf); 543 543 if (RT_SUCCESS(rc)) 544 544 { … … 637 637 638 638 PRTREQ pReq; 639 int rc = RTReq CallEx(pThis->pSlirpReqQueue, &pReq, 0 /*cMillies*/, RTREQFLAGS_VOID,640 (PFNRT)drvNATNotifyLinkChangedWorker, 2, pThis, enmLinkState);639 int rc = RTReqQueueCallEx(pThis->hSlirpReqQueue, &pReq, 0 /*cMillies*/, RTREQFLAGS_VOID, 640 (PFNRT)drvNATNotifyLinkChangedWorker, 2, pThis, enmLinkState); 641 641 if (RT_LIKELY(rc == VERR_TIMEOUT)) 642 642 { … … 684 684 PDRVNAT pThis = RT_FROM_MEMBER(pInterface, DRVNAT, INetworkNATCfg); 685 685 PRTREQ pReq; 686 int rc = RTReq CallEx(pThis->pSlirpReqQueue, &pReq, 0 /*cMillies*/, RTREQFLAGS_VOID,687 (PFNRT)drvNATNotifyApplyPortForwardCommand, 7, pThis, fRemove,688 fUdp, pHostIp, u16HostPort, pGuestIp, u16GuestPort);686 int rc = RTReqQueueCallEx(pThis->hSlirpReqQueue, &pReq, 0 /*cMillies*/, RTREQFLAGS_VOID, 687 (PFNRT)drvNATNotifyApplyPortForwardCommand, 7, pThis, fRemove, 688 fUdp, pHostIp, u16HostPort, pGuestIp, u16GuestPort); 689 689 if (RT_LIKELY(rc == VERR_TIMEOUT)) 690 690 { … … 707 707 * dedicated thread. We take care that this thread does not become the 708 708 * bottleneck: If the guest wants to send, a request is enqueued into the 709 * pSlirpReqQueue and handled asynchronously by this thread. If this thread709 * hSlirpReqQueue and handled asynchronously by this thread. If this thread 710 710 * wants to deliver packets to the guest, it enqueues a request into 711 * pRecvReqQueue which is later handled by the Recv thread.711 * hRecvReqQueue which is later handled by the Recv thread. 712 712 */ 713 713 static DECLCALLBACK(int) drvNATAsyncIoThread(PPDMDRVINS pDrvIns, PPDMTHREAD pThread) … … 792 792 } 793 793 /* process _all_ outstanding requests but don't wait */ 794 RTReq Process(pThis->pSlirpReqQueue, 0);794 RTReqQueueProcess(pThis->hSlirpReqQueue, 0); 795 795 RTMemFree(polls); 796 796 … … 819 819 slirp_select_poll(pThis->pNATState, /* fTimeout=*/false, /* fIcmp=*/(dwEvent == WSA_WAIT_EVENT_0)); 820 820 /* process _all_ outstanding requests but don't wait */ 821 RTReq Process(pThis->pSlirpReqQueue, 0);821 RTReqQueueProcess(pThis->hSlirpReqQueue, 0); 822 822 # ifdef VBOX_NAT_DELAY_HACK 823 823 if (cBreak++ > 128) … … 903 903 904 904 ASMAtomicIncU32(&pThis->cUrgPkts); 905 int rc = RTReq CallEx(pThis->pUrgRecvReqQueue, NULL /*ppReq*/, 0 /*cMillies*/, RTREQFLAGS_VOID | RTREQFLAGS_NO_WAIT,906 (PFNRT)drvNATUrgRecvWorker, 4, pThis, pu8Buf, cb, m);905 int rc = RTReqQueueCallEx(pThis->hUrgRecvReqQueue, NULL /*ppReq*/, 0 /*cMillies*/, RTREQFLAGS_VOID | RTREQFLAGS_NO_WAIT, 906 (PFNRT)drvNATUrgRecvWorker, 4, pThis, pu8Buf, cb, m); 907 907 AssertRC(rc); 908 908 drvNATUrgRecvWakeup(pThis->pDrvIns, pThis->pUrgRecvThread); … … 937 937 938 938 ASMAtomicIncU32(&pThis->cPkts); 939 int rc = RTReq CallEx(pThis->pRecvReqQueue, NULL /*ppReq*/, 0 /*cMillies*/, RTREQFLAGS_VOID | RTREQFLAGS_NO_WAIT,940 (PFNRT)drvNATRecvWorker, 4, pThis, pu8Buf, cb, m);939 int rc = RTReqQueueCallEx(pThis->hRecvReqQueue, NULL /*ppReq*/, 0 /*cMillies*/, RTREQFLAGS_VOID | RTREQFLAGS_NO_WAIT, 940 (PFNRT)drvNATRecvWorker, 4, pThis, pu8Buf, cb, m); 941 941 AssertRC(rc); 942 942 drvNATRecvWakeup(pThis->pDrvIns, pThis->pRecvThread); … … 1119 1119 } 1120 1120 1121 RTReq DestroyQueue(pThis->pSlirpReqQueue);1122 pThis-> pSlirpReqQueue = NULL;1123 1124 RTReq DestroyQueue(pThis->pUrgRecvReqQueue);1125 pThis-> pUrgRecvReqQueue = NULL;1121 RTReqQueueDestroy(pThis->hSlirpReqQueue); 1122 pThis->hSlirpReqQueue = NIL_RTREQQUEUE; 1123 1124 RTReqQueueDestroy(pThis->hUrgRecvReqQueue); 1125 pThis->hUrgRecvReqQueue = NIL_RTREQQUEUE; 1126 1126 1127 1127 RTSemEventDestroy(pThis->EventRecv); … … 1172 1172 pThis->pszBootFile = NULL; 1173 1173 pThis->pszNextServer = NULL; 1174 pThis-> pSlirpReqQueue = NULL;1175 pThis-> pUrgRecvReqQueue = NULL;1174 pThis->hSlirpReqQueue = NIL_RTREQQUEUE; 1175 pThis->hUrgRecvReqQueue = NIL_RTREQQUEUE; 1176 1176 pThis->EventRecv = NIL_RTSEMEVENT; 1177 1177 pThis->EventUrgRecv = NIL_RTSEMEVENT; … … 1301 1301 */ 1302 1302 rc = PDMDrvHlpSSMRegisterLoadDone(pDrvIns, drvNATLoadDone); 1303 AssertRCReturn(rc, rc); 1304 1305 rc = RTReqCreateQueue(&pThis->pSlirpReqQueue); 1306 if (RT_FAILURE(rc)) 1307 { 1308 LogRel(("NAT: Can't create request queue\n")); 1309 return rc; 1310 } 1311 1312 rc = RTReqCreateQueue(&pThis->pRecvReqQueue); 1313 if (RT_FAILURE(rc)) 1314 { 1315 LogRel(("NAT: Can't create request queue\n")); 1316 return rc; 1317 } 1318 1319 rc = RTReqCreateQueue(&pThis->pUrgRecvReqQueue); 1320 if (RT_FAILURE(rc)) 1321 { 1322 LogRel(("NAT: Can't create request queue\n")); 1323 return rc; 1324 } 1303 AssertLogRelRCReturn(rc, rc); 1304 1305 rc = RTReqQueueCreate(&pThis->hSlirpReqQueue); 1306 AssertLogRelRCReturn(rc, rc); 1307 1308 rc = RTReqQueueCreate(&pThis->hRecvReqQueue); 1309 AssertLogRelRCReturn(rc, rc); 1310 1311 rc = RTReqQueueCreate(&pThis->hUrgRecvReqQueue); 1312 AssertLogRelRCReturn(rc, rc); 1325 1313 1326 1314 rc = PDMDrvHlpThreadCreate(pDrvIns, &pThis->pRecvThread, pThis, drvNATRecv, -
trunk/src/VBox/Devices/Network/slirp/slirp.c
r39471 r39498 622 622 QSOCKET_LOCK_CREATE(tcb); 623 623 QSOCKET_LOCK_CREATE(udb); 624 rc = RTReq CreateQueue(&pData->pReqQueue);624 rc = RTReqQueueCreate(&pData->pReqQueue); 625 625 AssertReleaseRC(rc); 626 626 #endif … … 1950 1950 void slirp_process_queue(PNATState pData) 1951 1951 { 1952 RTReq Process(pData->pReqQueue, RT_INDEFINITE_WAIT);1952 RTReqQueueProcess(pData->pReqQueue, RT_INDEFINITE_WAIT); 1953 1953 } 1954 1954 void *slirp_get_queue(PNATState pData) -
trunk/src/VBox/Devices/Network/slirp/slirp_state.h
r39287 r39498 136 136 int soMaxConn; 137 137 #ifdef VBOX_WITH_SLIRP_MT 138 PRTREQQUEUE pReqQueue;138 RTREQQUEUE hReqQueue; 139 139 #endif 140 140 #ifdef RT_OS_WINDOWS … … 474 474 PRTREQ pReq; \ 475 475 int rc; \ 476 rc = RTReq CallVoid((data)->pReqQueue, &pReq, 0 /*cMillies*/,\477 (PFNRT)tcp_output 2, data, sotcb);\476 rc = RTReqQueueCallVoid((data)->hReqQueue, &pReq, 0 /*cMillies*/, \ 477 (PFNRT)tcp_output 2, data, sotcb); \ 478 478 if (RT_LIKELY(rc == VERR_TIMEOUT)) \ 479 479 { \ … … 491 491 do { \ 492 492 int rc; \ 493 rc = RTReq CallEx((data)->pReqQueue, NULL, 0 /*cMillies*/,\494 RTREQFLAGS_VOID | RTREQFLAGS_NO_WAIT,\495 (PFNRT)tcp_input, 4, data, mbuf, size, so);\493 rc = RTReqQueueCallEx((data)->hReqQueue, NULL, 0 /*cMillies*/, \ 494 RTREQFLAGS_VOID | RTREQFLAGS_NO_WAIT, \ 495 (PFNRT)tcp_input, 4, data, mbuf, size, so); \ 496 496 AssertReleaseRC(rc); \ 497 497 } while(0) … … 501 501 PRTREQ pReq; \ 502 502 int rc; \ 503 rc = RTReq CallVoid((data)->pReqQueue, &pReq, 0 /*cMillies*/,\504 (PFNRT)tcp_connect, 2, data, so);\503 rc = RTReqQueueCallVoid((data)->hReqQueue, &pReq, 0 /*cMillies*/, \ 504 (PFNRT)tcp_connect, 2, data, so); \ 505 505 if (RT_LIKELY(rc == VERR_TIMEOUT)) \ 506 506 { \ … … 519 519 PRTREQ pReq; \ 520 520 int rc; \ 521 rc = RTReq CallVoid((data)->pReqQueue, &pReq, 0 /*cMillies*/,\522 (PFNRT)soread_queue, 4,\523 data, so, ifclose, &(ret));\521 rc = RTReqQueueCallVoid((data)->hReqQueue, &pReq, 0 /*cMillies*/, \ 522 (PFNRT)soread_queue, 4, \ 523 data, so, ifclose, &(ret)); \ 524 524 if (RT_LIKELY(rc == VERR_TIMEOUT)) \ 525 525 { \ … … 538 538 PRTREQ pReq; \ 539 539 int rc; \ 540 rc = RTReq Call((data)->pReqQueue, &pReq, 0 /*cMillies*/,\541 (PFNRT)sowrite, 2, data, so);\540 rc = RTReqQueueCall((data)->hReqQueue, &pReq, 0 /*cMillies*/, \ 541 (PFNRT)sowrite, 2, data, so); \ 542 542 if (RT_LIKELY(rc == VERR_TIMEOUT)) \ 543 543 { \ … … 556 556 PRTREQ pReq; \ 557 557 int rc; \ 558 rc = RTReq CallVoid((data)->pReqQueue, &pReq, 0 /*cMillies */,\559 (PFNRT)sorecvfrom, 2, data, so);\558 rc = RTReqQueueCallVoid((data)->hReqQueue, &pReq, 0 /*cMillies */, \ 559 (PFNRT)sorecvfrom, 2, data, so); \ 560 560 if (RT_LIKELY(rc == VERR_TIMEOUT)) \ 561 561 { \ … … 574 574 PRTREQ pReq; \ 575 575 int rc; \ 576 rc = RTReq CallVoid((data)->pReqQueue, &pReq, 0 /* cMillies*/,\577 (PFNRT)udp_detach, 2, data, so);\576 rc = RTReqQueueCallVoid((data)->hReqQueue, &pReq, 0 /* cMillies*/, \ 577 (PFNRT)udp_detach, 2, data, so); \ 578 578 if (RT_LIKELY(rc == VERR_TIMEOUT)) \ 579 579 { \ -
trunk/src/VBox/Devices/Storage/DrvSCSI.cpp
r38878 r39498 91 91 PPDMTHREAD pAsyncIOThread; 92 92 /** Queue for passing the requests to the thread. */ 93 PRTREQQUEUE pQueueRequests;93 RTREQQUEUE hQueueRequests; 94 94 /** Request that we've left pending on wakeup or reset. */ 95 95 PRTREQ pPendingDummyReq; … … 398 398 { 399 399 /* I/O thread. */ 400 rc = RTReq CallEx(pThis->pQueueRequests, NULL, 0, RTREQFLAGS_NO_WAIT,401 (PFNRT)drvscsiProcessRequestOne, 2, pThis, hVScsiIoReq);400 rc = RTReqQueueCallEx(pThis->hQueueRequests, NULL, 0, RTREQFLAGS_NO_WAIT, 401 (PFNRT)drvscsiProcessRequestOne, 2, pThis, hVScsiIoReq); 402 402 } 403 403 … … 486 486 while (pThread->enmState == PDMTHREADSTATE_RUNNING) 487 487 { 488 rc = RTReq Process(pThis->pQueueRequests, RT_INDEFINITE_WAIT);488 rc = RTReqQueueProcess(pThis->hQueueRequests, RT_INDEFINITE_WAIT); 489 489 AssertMsg(rc == VWRN_STATE_CHANGED, ("Left RTReqProcess and error code is not VWRN_STATE_CHANGED rc=%Rrc\n", rc)); 490 490 } … … 519 519 int rc; 520 520 521 AssertMsgReturn(pThis-> pQueueRequests, ("pQueueRequests is NULL\n"), VERR_INVALID_STATE);521 AssertMsgReturn(pThis->hQueueRequests != NIL_RTREQQUEUE, ("hQueueRequests is NULL\n"), VERR_INVALID_STATE); 522 522 523 523 if (!drvscsiAsyncIOLoopNoPendingDummy(pThis, 10000 /* 10 sec */)) … … 527 527 } 528 528 529 rc = RTReq Call(pThis->pQueueRequests, &pReq, 10000 /* 10 sec. */, (PFNRT)drvscsiAsyncIOLoopWakeupFunc, 1, pThis);529 rc = RTReqQueueCall(pThis->hQueueRequests, &pReq, 10000 /* 10 sec. */, (PFNRT)drvscsiAsyncIOLoopWakeupFunc, 1, pThis); 530 530 if (RT_SUCCESS(rc)) 531 531 RTReqFree(pReq); … … 634 634 if (!pThis->pDrvBlockAsync) 635 635 { 636 if ( !pThis->pQueueRequests)636 if (pThis->hQueueRequests != NIL_RTREQQUEUE) 637 637 return; 638 638 … … 640 640 if (drvscsiAsyncIOLoopNoPendingDummy(pThis, 0 /*ms*/)) 641 641 { 642 if (!RTReq IsBusy(pThis->pQueueRequests))642 if (!RTReqQueueIsBusy(pThis->hQueueRequests)) 643 643 { 644 644 ASMAtomicWriteBool(&pThis->fDummySignal, false); … … 647 647 648 648 PRTREQ pReq; 649 int rc = RTReq Call(pThis->pQueueRequests, &pReq, 0 /*ms*/, (PFNRT)drvscsiAsyncIOLoopSyncCallback, 1, pThis);649 int rc = RTReqQueueCall(pThis->hQueueRequests, &pReq, 0 /*ms*/, (PFNRT)drvscsiAsyncIOLoopSyncCallback, 1, pThis); 650 650 if (RT_SUCCESS(rc)) 651 651 { … … 760 760 PDMDRV_CHECK_VERSIONS_RETURN_VOID(pDrvIns); 761 761 762 if (pThis-> pQueueRequests)762 if (pThis->hQueueRequests != NIL_RTREQQUEUE) 763 763 { 764 764 if (!drvscsiAsyncIOLoopNoPendingDummy(pThis, 100 /*ms*/)) 765 765 LogRel(("drvscsiDestruct#%u: previous dummy request is still pending\n", pDrvIns->iInstance)); 766 766 767 int rc = RTReq DestroyQueue(pThis->pQueueRequests);767 int rc = RTReqQueueDestroy(pThis->hQueueRequests); 768 768 AssertMsgRC(rc, ("Failed to destroy queue rc=%Rrc\n", rc)); 769 pThis->hQueueRequests = NIL_RTREQQUEUE; 769 770 } 770 771 … … 792 793 LogFlowFunc(("pDrvIns=%#p pCfg=%#p\n", pDrvIns, pCfg)); 793 794 PDMDRV_CHECK_VERSIONS_RETURN(pDrvIns); 795 796 /* 797 * Initialize the instance data. 798 */ 799 pThis->pDrvIns = pDrvIns; 800 pThis->ISCSIConnector.pfnSCSIRequestSend = drvscsiRequestSend; 801 802 pDrvIns->IBase.pfnQueryInterface = drvscsiQueryInterface; 803 804 pThis->IPort.pfnQueryDeviceLocation = drvscsiQueryDeviceLocation; 805 pThis->IPortAsync.pfnTransferCompleteNotify = drvscsiTransferCompleteNotify; 806 pThis->hQueueRequests = NIL_RTREQQUEUE; 807 808 /* Query the SCSI port interface above. */ 809 pThis->pDevScsiPort = PDMIBASE_QUERY_INTERFACE(pDrvIns->pUpBase, PDMISCSIPORT); 810 AssertMsgReturn(pThis->pDevScsiPort, ("Missing SCSI port interface above\n"), VERR_PDM_MISSING_INTERFACE); 811 812 /* Query the optional LED interface above. */ 813 pThis->pLedPort = PDMIBASE_QUERY_INTERFACE(pDrvIns->pUpBase, PDMILEDPORTS); 814 if (pThis->pLedPort != NULL) 815 { 816 /* Get The Led. */ 817 rc = pThis->pLedPort->pfnQueryStatusLed(pThis->pLedPort, 0, &pThis->pLed); 818 if (RT_FAILURE(rc)) 819 pThis->pLed = &pThis->Led; 820 } 821 else 822 pThis->pLed = &pThis->Led; 794 823 795 824 /* … … 804 833 return PDMDRV_SET_ERROR(pDrvIns, rc, 805 834 N_("SCSI configuration error: failed to read \"NonRotationalMedium\" as boolean")); 806 807 /*808 * Initialize the instance data.809 */810 pThis->pDrvIns = pDrvIns;811 pThis->ISCSIConnector.pfnSCSIRequestSend = drvscsiRequestSend;812 813 pDrvIns->IBase.pfnQueryInterface = drvscsiQueryInterface;814 815 pThis->IPort.pfnQueryDeviceLocation = drvscsiQueryDeviceLocation;816 pThis->IPortAsync.pfnTransferCompleteNotify = drvscsiTransferCompleteNotify;817 818 /* Query the SCSI port interface above. */819 pThis->pDevScsiPort = PDMIBASE_QUERY_INTERFACE(pDrvIns->pUpBase, PDMISCSIPORT);820 AssertMsgReturn(pThis->pDevScsiPort, ("Missing SCSI port interface above\n"), VERR_PDM_MISSING_INTERFACE);821 822 /* Query the optional LED interface above. */823 pThis->pLedPort = PDMIBASE_QUERY_INTERFACE(pDrvIns->pUpBase, PDMILEDPORTS);824 if (pThis->pLedPort != NULL)825 {826 /* Get The Led. */827 rc = pThis->pLedPort->pfnQueryStatusLed(pThis->pLedPort, 0, &pThis->pLed);828 if (RT_FAILURE(rc))829 pThis->pLed = &pThis->Led;830 }831 else832 pThis->pLed = &pThis->Led;833 835 834 836 /* … … 895 897 { 896 898 /* Create request queue. */ 897 rc = RTReq CreateQueue(&pThis->pQueueRequests);899 rc = RTReqQueueCreate(&pThis->hQueueRequests); 898 900 AssertMsgReturn(RT_SUCCESS(rc), ("Failed to create request queue rc=%Rrc\n"), rc); 899 901 /* Create I/O thread. */ -
trunk/src/VBox/Devices/Storage/DrvSCSIHost.cpp
r37596 r39498 63 63 PPDMTHREAD pAsyncIOThread; 64 64 /** Queue for passing the requests to the thread. */ 65 PRTREQQUEUE pQueueRequests;65 RTREQQUEUE hQueueRequests; 66 66 } DRVSCSIHOST, *PDRVSCSIHOST; 67 67 … … 352 352 while (pThread->enmState == PDMTHREADSTATE_RUNNING) 353 353 { 354 rc = RTReq Process(pThis->pQueueRequests, RT_INDEFINITE_WAIT);354 rc = RTReqQueueProcess(pThis->hQueueRequests, RT_INDEFINITE_WAIT); 355 355 AssertMsg(rc == VWRN_STATE_CHANGED, ("Left RTReqProcess and error code is not VWRN_STATE_CHANGED rc=%Rrc\n", rc)); 356 356 } … … 365 365 PRTREQ pReq; 366 366 367 Assert MsgReturn(pThis->pQueueRequests, ("pQueueRequests is NULL\n"), VERR_INVALID_STATE);368 369 rc = RTReq Call(pThis->pQueueRequests, &pReq, 10000 /* 10 sec. */, (PFNRT)drvscsihostAsyncIOLoopWakeupFunc, 0);367 AssertReturn(pThis->hQueueRequests != NIL_RTREQQUEUE, VERR_INVALID_STATE); 368 369 rc = RTReqQueueCall(pThis->hQueueRequests, &pReq, 10000 /* 10 sec. */, (PFNRT)drvscsihostAsyncIOLoopWakeupFunc, 0); 370 370 AssertMsgRC(rc, ("Inserting request into queue failed rc=%Rrc\n")); 371 371 … … 382 382 PRTREQ pReq; 383 383 384 Assert MsgReturn(pThis->pQueueRequests, ("pQueueRequests is NULL\n"), VERR_INVALID_STATE);385 386 rc = RTReq CallEx(pThis->pQueueRequests, &pReq, 0, RTREQFLAGS_NO_WAIT, (PFNRT)drvscsihostProcessRequestOne, 2, pThis, pSCSIRequest);384 AssertReturn(pThis->hQueueRequests != NIL_RTREQQUEUE, VERR_INVALID_STATE); 385 386 rc = RTReqQueueCallEx(pThis->hQueueRequests, &pReq, 0, RTREQFLAGS_NO_WAIT, (PFNRT)drvscsihostProcessRequestOne, 2, pThis, pSCSIRequest); 387 387 AssertMsgReturn(RT_SUCCESS(rc), ("Inserting request into queue failed rc=%Rrc\n", rc), rc); 388 388 … … 429 429 } 430 430 431 if (pThis-> pQueueRequests)432 { 433 int rc = RTReq DestroyQueue(pThis->pQueueRequests);431 if (pThis->hQueueRequests != NIL_RTREQQUEUE) 432 { 433 int rc = RTReqQueueDestroy(pThis->hQueueRequests); 434 434 AssertMsgRC(rc, ("Failed to destroy queue rc=%Rrc\n", rc)); 435 pThis->hQueueRequests = NIL_RTREQQUEUE; 435 436 } 436 437 … … 447 448 LogFlowFunc(("pDrvIns=%#p pCfg=%#p\n", pDrvIns, pCfg)); 448 449 PDMDRV_CHECK_VERSIONS_RETURN(pDrvIns); 450 451 /* 452 * Initialize the instance data first because of the destructor. 453 */ 454 pDrvIns->IBase.pfnQueryInterface = drvscsihostQueryInterface; 455 pThis->ISCSIConnector.pfnSCSIRequestSend = drvscsihostRequestSend; 456 pThis->pDrvIns = pDrvIns; 457 pThis->hDeviceFile = NIL_RTFILE; 458 pThis->hQueueRequests = NIL_RTREQQUEUE; 449 459 450 460 /* … … 455 465 N_("Invalid configuration for host scsi access driver")); 456 466 457 /*458 * Initialize interfaces.459 */460 pDrvIns->IBase.pfnQueryInterface = drvscsihostQueryInterface;461 pThis->ISCSIConnector.pfnSCSIRequestSend = drvscsihostRequestSend;462 pThis->pDrvIns = pDrvIns;463 pThis->hDeviceFile = NIL_RTFILE;464 467 465 468 /* Query the SCSI port interface above. */ … … 468 471 469 472 /* Create request queue. */ 470 int rc = RTReq CreateQueue(&pThis->pQueueRequests);473 int rc = RTReqQueueCreate(&pThis->hQueueRequests); 471 474 AssertMsgReturn(RT_SUCCESS(rc), ("Failed to create request queue rc=%Rrc\n"), rc); 472 475 -
trunk/src/VBox/NetworkServices/NAT/VBoxNetNAT.cpp
r39468 r39498 101 101 RTSEMEVENT m_EventUrgSend; 102 102 103 PRTREQQUEUE m_pReqQueue;104 PRTREQQUEUE m_pSendQueue;105 PRTREQQUEUE m_pUrgSendQueue;103 RTREQQUEUE m_hReqQueue; 104 RTREQQUEUE m_hSendQueue; 105 RTREQQUEUE m_hUrgSendQueue; 106 106 volatile uint32_t cUrgPkt; 107 107 volatile uint32_t cPkt; … … 186 186 slirp_register_external_event(m_pNATState, m_hWakeupEvent, VBOX_WAKEUP_EVENT_INDEX); 187 187 #endif 188 rc = RTReq CreateQueue(&m_pReqQueue);189 AssertReleaseRC(rc); 190 191 rc = RTReq CreateQueue(&m_pSendQueue);192 AssertReleaseRC(rc); 193 194 rc = RTReq CreateQueue(&m_pUrgSendQueue);188 rc = RTReqQueueCreate(&m_hReqQueue); 189 AssertReleaseRC(rc); 190 191 rc = RTReqQueueCreate(&m_hSendQueue); 192 AssertReleaseRC(rc); 193 194 rc = RTReqQueueCreate(&m_hUrgSendQueue); 195 195 AssertReleaseRC(rc); 196 196 … … 226 226 WaitReq.cMillies = 2000; /* 2 secs - the sleep is for some reason uninterruptible... */ /** @todo fix interruptability in SrvIntNet! */ 227 227 #if 0 228 RTReqProcess(m_ pSendQueue, 0);229 RTReqProcess(m_ pUrgSendQueue, 0);228 RTReqProcess(m_hSendQueue, 0); 229 RTReqProcess(m_hUrgSendQueue, 0); 230 230 #endif 231 231 int rc = SUPR3CallVMMR0Ex(NIL_RTR0PTR, NIL_VMCPUID, VMMR0_DO_INTNET_IF_WAIT, 0, &WaitReq.Hdr); … … 267 267 268 268 /* don't wait, we may have to wakeup the NAT thread first */ 269 rc = RTReq CallEx(m_pReqQueue, NULL /*ppReq*/, 0 /*cMillies*/, RTREQFLAGS_VOID | RTREQFLAGS_NO_WAIT,270 (PFNRT)SendWorker, 2, m, cbFrame);269 rc = RTReqQueueCallEx(m_hReqQueue, NULL /*ppReq*/, 0 /*cMillies*/, RTREQFLAGS_VOID | RTREQFLAGS_NO_WAIT, 270 (PFNRT)SendWorker, 2, m, cbFrame); 271 271 natNotifyNATThread(); 272 272 AssertReleaseRC(rc); … … 301 301 memcpy(pvSlirpFrame, pvSegFrame, cbSegFrame); 302 302 303 rc = RTReq CallEx(m_pReqQueue, NULL /*ppReq*/, 0 /*cMillies*/,304 RTREQFLAGS_VOID | RTREQFLAGS_NO_WAIT,305 (PFNRT)SendWorker, 2, m, cbSegFrame);303 rc = RTReqQueueCallEx(m_hReqQueue, NULL /*ppReq*/, 0 /*cMillies*/, 304 RTREQFLAGS_VOID | RTREQFLAGS_NO_WAIT, 305 (PFNRT)SendWorker, 2, m, cbSegFrame); 306 306 AssertReleaseRC(rc); 307 307 } … … 357 357 { 358 358 LogFlowFunc(("ENTER: m:%p, pu8Buf:%p, cb:%d\n", m, pu8Buf, cb)); 359 int rc = RTReq CallEx(g_pNAT->m_pUrgSendQueue, NULL /*ppReq*/, 0 /*cMillies*/, RTREQFLAGS_VOID | RTREQFLAGS_NO_WAIT,360 (PFNRT)IntNetSendWorker, 4, (uintptr_t)1, (uintptr_t)pu8Buf, (uintptr_t)cb, (uintptr_t)m);359 int rc = RTReqQueueCallEx(g_pNAT->m_hUrgSendQueue, NULL /*ppReq*/, 0 /*cMillies*/, RTREQFLAGS_VOID | RTREQFLAGS_NO_WAIT, 360 (PFNRT)IntNetSendWorker, 4, (uintptr_t)1, (uintptr_t)pu8Buf, (uintptr_t)cb, (uintptr_t)m); 361 361 ASMAtomicIncU32(&g_pNAT->cUrgPkt); 362 362 RTSemEventSignal(g_pNAT->m_EventUrgSend); … … 368 368 LogFlowFunc(("ENTER: m:%p, pu8Buf:%p, cb:%d\n", m, pu8Buf, cb)); 369 369 AssertRelease(g_pNAT == pvUser); 370 int rc = RTReq CallEx(g_pNAT->m_pSendQueue, NULL /*ppReq*/, 0 /*cMillies*/, RTREQFLAGS_VOID | RTREQFLAGS_NO_WAIT,371 (PFNRT)IntNetSendWorker, 4, (uintptr_t)0, (uintptr_t)pu8Buf, (uintptr_t)cb, (uintptr_t)m);370 int rc = RTReqQueueCallEx(g_pNAT->m_hSendQueue, NULL /*ppReq*/, 0 /*cMillies*/, RTREQFLAGS_VOID | RTREQFLAGS_NO_WAIT, 371 (PFNRT)IntNetSendWorker, 4, (uintptr_t)0, (uintptr_t)pu8Buf, (uintptr_t)cb, (uintptr_t)m); 372 372 ASMAtomicIncU32(&g_pNAT->cPkt); 373 373 RTSemEventSignal(g_pNAT->m_EventSend); … … 524 524 } 525 525 /* process _all_ outstanding requests but don't wait */ 526 RTReq Process(pThis->m_pReqQueue, 0);526 RTReqQueueProcess(pThis->m_hReqQueue, 0); 527 527 RTMemFree(polls); 528 528 … … 551 551 slirp_select_poll(pThis->m_pNATState, /* fTimeout=*/false, /* fIcmp=*/(dwEvent == WSA_WAIT_EVENT_0)); 552 552 /* process _all_ outstanding requests but don't wait */ 553 RTReq Process(pThis->m_pReqQueue, 0);553 RTReqQueueProcess(pThis->m_hReqQueue, 0); 554 554 #endif /* RT_OS_WINDOWS */ 555 555 } … … 561 561 { 562 562 while (g_pNAT->fIsRunning) 563 RTReq Process(g_pNAT->m_pSendQueue, 0);563 RTReqQueueProcess(g_pNAT->m_hSendQueue, 0); 564 564 return VINF_SUCCESS; 565 565 } … … 567 567 { 568 568 while (g_pNAT->fIsRunning) 569 RTReq Process(g_pNAT->m_pUrgSendQueue, 0);569 RTReqQueueProcess(g_pNAT->m_hUrgSendQueue, 0); 570 570 return VINF_SUCCESS; 571 571 } -
trunk/src/VBox/Runtime/common/misc/req.cpp
r39032 r39498 41 41 #include <iprt/mem.h> 42 42 43 #include "internal/req.h" 44 43 45 44 46 /******************************************************************************* … … 49 51 50 52 51 /** 52 * Create a request packet queue 53 * 54 * @returns iprt status code. 55 * @param ppQueue Where to store the request queue pointer. 56 */ 57 RTDECL(int) RTReqCreateQueue(PRTREQQUEUE *ppQueue) 58 { 59 PRTREQQUEUE pQueue = (PRTREQQUEUE)RTMemAllocZ(sizeof(RTREQQUEUE)); 53 RTDECL(int) RTReqQueueCreate(RTREQQUEUE *phQueue) 54 { 55 PRTREQQUEUEINT pQueue = (PRTREQQUEUEINT)RTMemAllocZ(sizeof(RTREQQUEUEINT)); 60 56 if (!pQueue) 61 57 return VERR_NO_MEMORY; … … 63 59 if (RT_SUCCESS(rc)) 64 60 { 65 *p pQueue = pQueue;61 *phQueue = pQueue; 66 62 return VINF_SUCCESS; 67 63 } … … 70 66 return rc; 71 67 } 72 RT_EXPORT_SYMBOL(RTReqCreateQueue); 73 74 75 /** 76 * Destroy a request packet queue 77 * 78 * @returns iprt status code. 79 * @param pQueue The request queue. 80 */ 81 RTDECL(int) RTReqDestroyQueue(PRTREQQUEUE pQueue) 68 RT_EXPORT_SYMBOL(RTReqQueueCreate); 69 70 71 RTDECL(int) RTReqQueueDestroy(RTREQQUEUE hQueue) 82 72 { 83 73 /* 84 74 * Check input. 85 75 */ 86 if ( !pQueue)76 if (hQueue == NIL_RTREQQUEUE) 87 77 return VINF_SUCCESS; 88 AssertPtr(pQueue); 78 PRTREQQUEUEINT pQueue = hQueue; 79 AssertPtrReturn(pQueue, VERR_INVALID_HANDLE); 80 89 81 RTSemEventDestroy(pQueue->EventSem); 90 82 pQueue->EventSem = NIL_RTSEMEVENT; … … 92 84 return VINF_SUCCESS; 93 85 } 94 RT_EXPORT_SYMBOL(RTReqDestroyQueue); 95 96 97 /** 98 * Process one or more request packets 99 * 100 * @returns iprt status code. 101 * @returns VERR_TIMEOUT if cMillies was reached without the packet being added. 102 * 103 * @param pQueue The request queue. 104 * @param cMillies Number of milliseconds to wait for a pending request. 105 * Use RT_INDEFINITE_WAIT to only wait till one is added. 106 */ 107 RTDECL(int) RTReqProcess(PRTREQQUEUE pQueue, RTMSINTERVAL cMillies) 108 { 109 LogFlow(("RTReqProcess %x\n", pQueue)); 86 RT_EXPORT_SYMBOL(RTReqQueueDestroy); 87 88 89 RTDECL(int) RTReqQueueProcess(RTREQQUEUE hQueue, RTMSINTERVAL cMillies) 90 { 91 LogFlow(("RTReqProcess %x\n", hQueue)); 92 110 93 /* 111 94 * Check input. 112 95 */ 113 if (!pQueue) 114 { 115 AssertFailed(); 116 return VERR_INVALID_PARAMETER; 117 } 96 PRTREQQUEUEINT pQueue = hQueue; 97 AssertPtrReturn(pQueue, VERR_INVALID_HANDLE); 118 98 119 99 /* … … 152 132 { 153 133 Assert(pReq->enmState == RTREQSTATE_QUEUED); 154 Assert(pReq-> pQueue == pQueue);134 Assert(pReq->hQueue == pQueue); 155 135 PRTREQ pCur = pReq; 156 136 pReq = pReq->pNext; … … 181 161 return rc; 182 162 } 183 RT_EXPORT_SYMBOL(RTReqProcess); 184 185 /** 186 * Allocate and queue a call request. 187 * 188 * If it's desired to poll on the completion of the request set cMillies 189 * to 0 and use RTReqWait() to check for completion. In the other case 190 * use RT_INDEFINITE_WAIT. 191 * The returned request packet must be freed using RTReqFree(). 192 * 193 * @returns iprt statuscode. 194 * Will not return VERR_INTERRUPTED. 195 * @returns VERR_TIMEOUT if cMillies was reached without the packet being completed. 196 * 197 * @param pQueue The request queue. 198 * @param ppReq Where to store the pointer to the request. 199 * This will be NULL or a valid request pointer not matter what happens. 200 * @param cMillies Number of milliseconds to wait for the request to 201 * be completed. Use RT_INDEFINITE_WAIT to only 202 * wait till it's completed. 203 * @param pfnFunction Pointer to the function to call. 204 * @param cArgs Number of arguments following in the ellipsis. 205 * @param ... Function arguments. 206 * 207 * @remarks See remarks on RTReqCallV. 208 */ 209 RTDECL(int) RTReqCall(PRTREQQUEUE pQueue, PRTREQ *ppReq, RTMSINTERVAL cMillies, PFNRT pfnFunction, unsigned cArgs, ...) 163 RT_EXPORT_SYMBOL(RTReqQueueProcess); 164 165 166 RTDECL(int) RTReqQueueCall(RTREQQUEUE hQueue, PRTREQ *ppReq, RTMSINTERVAL cMillies, PFNRT pfnFunction, unsigned cArgs, ...) 210 167 { 211 168 va_list va; 212 169 va_start(va, cArgs); 213 int rc = RTReq CallV(pQueue, ppReq, cMillies, RTREQFLAGS_IPRT_STATUS, pfnFunction, cArgs, va);170 int rc = RTReqQueueCallV(hQueue, ppReq, cMillies, RTREQFLAGS_IPRT_STATUS, pfnFunction, cArgs, va); 214 171 va_end(va); 215 172 return rc; 216 173 } 217 RT_EXPORT_SYMBOL(RTReqCall); 218 219 220 /** 221 * Allocate and queue a call request to a void function. 222 * 223 * If it's desired to poll on the completion of the request set cMillies 224 * to 0 and use RTReqWait() to check for completion. In the other case 225 * use RT_INDEFINITE_WAIT. 226 * The returned request packet must be freed using RTReqFree(). 227 * 228 * @returns iprt status code. 229 * Will not return VERR_INTERRUPTED. 230 * @returns VERR_TIMEOUT if cMillies was reached without the packet being completed. 231 * 232 * @param pQueue The request queue. 233 * @param ppReq Where to store the pointer to the request. 234 * This will be NULL or a valid request pointer not matter what happens. 235 * @param cMillies Number of milliseconds to wait for the request to 236 * be completed. Use RT_INDEFINITE_WAIT to only 237 * wait till it's completed. 238 * @param pfnFunction Pointer to the function to call. 239 * @param cArgs Number of arguments following in the ellipsis. 240 * @param ... Function arguments. 241 * 242 * @remarks See remarks on RTReqCallV. 243 */ 244 RTDECL(int) RTReqCallVoid(PRTREQQUEUE pQueue, PRTREQ *ppReq, RTMSINTERVAL cMillies, PFNRT pfnFunction, unsigned cArgs, ...) 174 RT_EXPORT_SYMBOL(RTReqQueueCall); 175 176 177 RTDECL(int) RTReqQueueCallVoid(RTREQQUEUE hQueue, PRTREQ *ppReq, RTMSINTERVAL cMillies, PFNRT pfnFunction, unsigned cArgs, ...) 245 178 { 246 179 va_list va; 247 180 va_start(va, cArgs); 248 int rc = RTReq CallV(pQueue, ppReq, cMillies, RTREQFLAGS_VOID, pfnFunction, cArgs, va);181 int rc = RTReqQueueCallV(hQueue, ppReq, cMillies, RTREQFLAGS_VOID, pfnFunction, cArgs, va); 249 182 va_end(va); 250 183 return rc; 251 184 } 252 RT_EXPORT_SYMBOL(RTReqCallVoid); 253 254 255 /** 256 * Allocate and queue a call request to a void function. 257 * 258 * If it's desired to poll on the completion of the request set cMillies 259 * to 0 and use RTReqWait() to check for completion. In the other case 260 * use RT_INDEFINITE_WAIT. 261 * The returned request packet must be freed using RTReqFree(). 262 * 263 * @returns iprt status code. 264 * Will not return VERR_INTERRUPTED. 265 * @returns VERR_TIMEOUT if cMillies was reached without the packet being completed. 266 * 267 * @param pQueue The request queue. 268 * @param ppReq Where to store the pointer to the request. 269 * This will be NULL or a valid request pointer not matter what happens, unless fFlags 270 * contains RTREQFLAGS_NO_WAIT when it will be optional and always NULL. 271 * @param cMillies Number of milliseconds to wait for the request to 272 * be completed. Use RT_INDEFINITE_WAIT to only 273 * wait till it's completed. 274 * @param fFlags A combination of the RTREQFLAGS values. 275 * @param pfnFunction Pointer to the function to call. 276 * @param cArgs Number of arguments following in the ellipsis. 277 * @param ... Function arguments. 278 * 279 * @remarks See remarks on RTReqCallV. 280 */ 281 RTDECL(int) RTReqCallEx(PRTREQQUEUE pQueue, PRTREQ *ppReq, RTMSINTERVAL cMillies, unsigned fFlags, PFNRT pfnFunction, unsigned cArgs, ...) 185 RT_EXPORT_SYMBOL(RTReqQueueCallVoid); 186 187 188 RTDECL(int) RTReqQueueCallEx(RTREQQUEUE hQueue, PRTREQ *ppReq, RTMSINTERVAL cMillies, unsigned fFlags, PFNRT pfnFunction, unsigned cArgs, ...) 282 189 { 283 190 va_list va; 284 191 va_start(va, cArgs); 285 int rc = RTReq CallV(pQueue, ppReq, cMillies, fFlags, pfnFunction, cArgs, va);192 int rc = RTReqQueueCallV(hQueue, ppReq, cMillies, fFlags, pfnFunction, cArgs, va); 286 193 va_end(va); 287 194 return rc; 288 195 } 289 RT_EXPORT_SYMBOL(RTReqCallEx); 290 291 292 /** 293 * Allocate and queue a call request. 294 * 295 * If it's desired to poll on the completion of the request set cMillies 296 * to 0 and use RTReqWait() to check for completion. In the other case 297 * use RT_INDEFINITE_WAIT. 298 * The returned request packet must be freed using RTReqFree(). 299 * 300 * @returns iprt status code. 301 * Will not return VERR_INTERRUPTED. 302 * @returns VERR_TIMEOUT if cMillies was reached without the packet being completed. 303 * 304 * @param pQueue The request queue. 305 * @param ppReq Where to store the pointer to the request. 306 * This will be NULL or a valid request pointer not matter what happens, unless fFlags 307 * contains RTREQFLAGS_NO_WAIT when it will be optional and always NULL. 308 * @param cMillies Number of milliseconds to wait for the request to 309 * be completed. Use RT_INDEFINITE_WAIT to only 310 * wait till it's completed. 311 * @param fFlags A combination of the RTREQFLAGS values. 312 * @param pfnFunction Pointer to the function to call. 313 * @param cArgs Number of arguments following in the ellipsis. 314 * @param Args Variable argument vector. 315 * 316 * @remarks Caveats: 317 * - Do not pass anything which is larger than an uintptr_t. 318 * - 64-bit integers are larger than uintptr_t on 32-bit hosts. 319 * Pass integers > 32-bit by reference (pointers). 320 * - Don't use NULL since it should be the integer 0 in C++ and may 321 * therefore end up with garbage in the bits 63:32 on 64-bit 322 * hosts because 'int' is 32-bit. 323 * Use (void *)NULL or (uintptr_t)0 instead of NULL. 324 */ 325 RTDECL(int) RTReqCallV(PRTREQQUEUE pQueue, PRTREQ *ppReq, RTMSINTERVAL cMillies, unsigned fFlags, PFNRT pfnFunction, unsigned cArgs, va_list Args) 196 RT_EXPORT_SYMBOL(RTReqQueueCallEx); 197 198 199 RTDECL(int) RTReqQueueCallV(RTREQQUEUE hQueue, PRTREQ *ppReq, RTMSINTERVAL cMillies, unsigned fFlags, PFNRT pfnFunction, unsigned cArgs, va_list Args) 326 200 { 327 201 LogFlow(("RTReqCallV: cMillies=%d fFlags=%#x pfnFunction=%p cArgs=%d\n", cMillies, fFlags, pfnFunction, cArgs)); … … 330 204 * Check input. 331 205 */ 332 if (!pfnFunction || !pQueue || (fFlags & ~(RTREQFLAGS_RETURN_MASK | RTREQFLAGS_NO_WAIT)))333 {334 AssertFailed();335 return VERR_INVALID_PARAMETER;336 } 206 PRTREQQUEUEINT pQueue = hQueue; 207 AssertPtrReturn(pQueue, VERR_INVALID_HANDLE); 208 AssertPtrReturn(pfnFunction, VERR_INVALID_POINTER); 209 AssertReturn(!(fFlags & ~(RTREQFLAGS_RETURN_MASK | RTREQFLAGS_NO_WAIT)), VERR_INVALID_PARAMETER); 210 337 211 if (!(fFlags & RTREQFLAGS_NO_WAIT) || ppReq) 338 212 { 339 Assert (ppReq);213 AssertPtrReturn(ppReq, VERR_INVALID_POINTER); 340 214 *ppReq = NULL; 341 215 } 216 342 217 PRTREQ pReq = NULL; 343 if (cArgs * sizeof(uintptr_t) > sizeof(pReq->u.Internal.aArgs)) 344 { 345 AssertMsgFailed(("cArg=%d\n", cArgs)); 346 return VERR_TOO_MUCH_DATA; 347 } 218 AssertMsgReturn(cArgs * sizeof(uintptr_t) <= sizeof(pReq->u.Internal.aArgs), ("cArgs=%u\n", cArgs), VERR_TOO_MUCH_DATA); 348 219 349 220 /* 350 221 * Allocate request 351 222 */ 352 int rc = RTReq Alloc(pQueue, &pReq, RTREQTYPE_INTERNAL);223 int rc = RTReqQueueAlloc(pQueue, &pReq, RTREQTYPE_INTERNAL); 353 224 if (rc != VINF_SUCCESS) 354 225 return rc; … … 366 237 * Queue the request and return. 367 238 */ 368 rc = RTReq Queue(pReq, cMillies);239 rc = RTReqSubmit(pReq, cMillies); 369 240 if ( rc != VINF_SUCCESS 370 241 && rc != VERR_TIMEOUT) … … 383 254 return rc; 384 255 } 385 RT_EXPORT_SYMBOL(RTReqCallV); 256 RT_EXPORT_SYMBOL(RTReqQueueCallV); 257 258 259 RTDECL(bool) RTReqQueueIsBusy(RTREQQUEUE hQueue) 260 { 261 PRTREQQUEUEINT pQueue = hQueue; 262 AssertPtrReturn(pQueue, false); 263 264 if (ASMAtomicReadBool(&pQueue->fBusy)) 265 return true; 266 if (ASMAtomicReadPtrT(&pQueue->pReqs, PRTREQ) != NULL) 267 return true; 268 if (ASMAtomicReadBool(&pQueue->fBusy)) 269 return true; 270 return false; 271 } 272 RT_EXPORT_SYMBOL(RTReqQueueIsBusy); 386 273 387 274 … … 415 302 * Joins the list pList with whatever is linked up at *pHead. 416 303 */ 417 static void vmr3ReqJoinFree(PRTREQQUEUE pQueue, PRTREQ pList)304 static void vmr3ReqJoinFree(PRTREQQUEUEINT pQueue, PRTREQ pList) 418 305 { 419 306 /* … … 439 326 440 327 441 /** 442 * Allocates a request packet. 443 * 444 * The caller allocates a request packet, fills in the request data 445 * union and queues the request. 446 * 447 * @returns iprt status code. 448 * 449 * @param pQueue The request queue. 450 * @param ppReq Where to store the pointer to the allocated packet. 451 * @param enmType Package type. 452 */ 453 RTDECL(int) RTReqAlloc(PRTREQQUEUE pQueue, PRTREQ *ppReq, RTREQTYPE enmType) 328 RTDECL(int) RTReqQueueAlloc(RTREQQUEUE hQueue, PRTREQ *ppReq, RTREQTYPE enmType) 454 329 { 455 330 /* 456 331 * Validate input. 457 332 */ 458 if ( enmType < RTREQTYPE_INVALID 459 || enmType > RTREQTYPE_MAX) 460 { 461 AssertMsgFailed(("Invalid package type %d valid range %d-%d inclusively.\n", 462 enmType, RTREQTYPE_INVALID + 1, RTREQTYPE_MAX - 1)); 463 return VERR_RT_REQUEST_INVALID_TYPE; 464 } 333 PRTREQQUEUEINT pQueue = hQueue; 334 AssertPtrReturn(pQueue, VERR_INVALID_HANDLE); 335 AssertMsgReturn(enmType > RTREQTYPE_INVALID && enmType < RTREQTYPE_MAX, ("%d\n", enmType), VERR_RT_REQUEST_INVALID_TYPE); 465 336 466 337 /* … … 526 397 Assert(pReq->enmType == RTREQTYPE_INVALID); 527 398 Assert(pReq->enmState == RTREQSTATE_FREE); 528 Assert(pReq-> pQueue == pQueue);399 Assert(pReq->hQueue == pQueue); 529 400 ASMAtomicXchgSize(&pReq->pNext, NULL); 530 401 pReq->enmState = RTREQSTATE_ALLOCATED; … … 561 432 */ 562 433 pReq->pNext = NULL; 563 pReq-> pQueue = pQueue;434 pReq->hQueue = pQueue; 564 435 pReq->enmState = RTREQSTATE_ALLOCATED; 565 436 pReq->iStatus = VERR_RT_REQUEST_STATUS_STILL_PENDING; … … 572 443 return VINF_SUCCESS; 573 444 } 574 RT_EXPORT_SYMBOL(RTReqAlloc); 575 576 577 /** 578 * Free a request packet. 579 * 580 * @returns iprt status code. 581 * 582 * @param pReq Package to free. 583 * @remark The request packet must be in allocated or completed state! 584 */ 445 RT_EXPORT_SYMBOL(RTReqQueueAlloc); 446 447 585 448 RTDECL(int) RTReqFree(PRTREQ pReq) 586 449 { … … 612 475 pReq->enmType = RTREQTYPE_INVALID; 613 476 614 PRTREQQUEUE pQueue = pReq->pQueue;477 PRTREQQUEUEINT pQueue = pReq->hQueue; 615 478 if (pQueue->cReqFree < 128) 616 479 { … … 634 497 635 498 636 /** 637 * Queue a request. 638 * 639 * The quest must be allocated using RTReqAlloc() and contain 640 * all the required data. 641 * If it's desired to poll on the completion of the request set cMillies 642 * to 0 and use RTReqWait() to check for completion. In the other case 643 * use RT_INDEFINITE_WAIT. 644 * 645 * @returns iprt status code. 646 * Will not return VERR_INTERRUPTED. 647 * @returns VERR_TIMEOUT if cMillies was reached without the packet being completed. 648 * 649 * @param pReq The request to queue. 650 * @param cMillies Number of milliseconds to wait for the request to 651 * be completed. Use RT_INDEFINITE_WAIT to only 652 * wait till it's completed. 653 */ 654 RTDECL(int) RTReqQueue(PRTREQ pReq, RTMSINTERVAL cMillies) 499 RTDECL(int) RTReqSubmit(PRTREQ pReq, RTMSINTERVAL cMillies) 655 500 { 656 501 LogFlow(("RTReqQueue: pReq=%p cMillies=%d\n", pReq, cMillies)); … … 663 508 return VERR_RT_REQUEST_STATE; 664 509 } 665 if ( !pReq-> pQueue510 if ( !pReq->hQueue 666 511 || pReq->pNext 667 512 || !pReq->EventSem) … … 682 527 * Insert it. 683 528 */ 684 PRTREQQUEUE pQueue = ((RTREQ volatile *)pReq)->pQueue;/* volatile paranoia */529 PRTREQQUEUEINT pQueue = ((RTREQ volatile *)pReq)->hQueue; /* volatile paranoia */ 685 530 unsigned fFlags = ((RTREQ volatile *)pReq)->fFlags; /* volatile paranoia */ 686 531 pReq->enmState = RTREQSTATE_QUEUED; … … 706 551 return rc; 707 552 } 708 RT_EXPORT_SYMBOL(RTReqQueue); 709 710 711 /** 712 * Wait for a request to be completed. 713 * 714 * @returns iprt status code. 715 * Will not return VERR_INTERRUPTED. 716 * @returns VERR_TIMEOUT if cMillies was reached without the packet being completed. 717 * 718 * @param pReq The request to wait for. 719 * @param cMillies Number of milliseconds to wait. 720 * Use RT_INDEFINITE_WAIT to only wait till it's completed. 721 */ 553 RT_EXPORT_SYMBOL(RTReqSubmit); 554 555 722 556 RTDECL(int) RTReqWait(PRTREQ pReq, RTMSINTERVAL cMillies) 723 557 { … … 734 568 return VERR_RT_REQUEST_STATE; 735 569 } 736 if ( !pReq-> pQueue570 if ( !pReq->hQueue 737 571 || !pReq->EventSem) 738 572 { … … 916 750 } 917 751 918 919 /**920 * Checks if the queue is busy or not.921 *922 * The caller is responsible for dealing with any concurrent submitts.923 *924 * @returns true if busy, false if idle.925 * @param pQueue The queue.926 */927 RTDECL(bool) RTReqIsBusy(PRTREQQUEUE pQueue)928 {929 AssertPtrReturn(pQueue, false);930 931 if (ASMAtomicReadBool(&pQueue->fBusy))932 return true;933 if (ASMAtomicReadPtrT(&pQueue->pReqs, PRTREQ) != NULL)934 return true;935 if (ASMAtomicReadBool(&pQueue->fBusy))936 return true;937 return false;938 }939 RT_EXPORT_SYMBOL(RTReqIsBusy);
Note:
See TracChangeset
for help on using the changeset viewer.