Changeset 92735 in vbox for trunk/src/VBox/HostServices
- Timestamp:
- Dec 3, 2021 4:03:24 PM (3 years ago)
- Location:
- trunk/src/VBox/HostServices/SharedClipboard
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/HostServices/SharedClipboard/VBoxSharedClipboardSvc-internal.h
r91749 r92735 5 5 6 6 /* 7 * Copyright (C) 2006-202 0Oracle Corporation7 * Copyright (C) 2006-2021 Oracle Corporation 8 8 * 9 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 293 293 * @{ 294 294 */ 295 int ShClSvcGuestDataRequest(PSHCLCLIENT pClient, SHCLFORMATS fFormats, PSHCLEVENT ID pidEvent);295 int ShClSvcGuestDataRequest(PSHCLCLIENT pClient, SHCLFORMATS fFormats, PSHCLEVENT *ppEvent); 296 296 int ShClSvcGuestDataSignal(PSHCLCLIENT pClient, PSHCLCLIENTCMDCTX pCmdCtx, SHCLFORMAT uFormat, void *pvData, uint32_t cbData); 297 297 int ShClSvcHostReportFormats(PSHCLCLIENT pClient, SHCLFORMATS fFormats); -
trunk/src/VBox/HostServices/SharedClipboard/VBoxSharedClipboardSvc-transfers.cpp
r87658 r92735 5 5 6 6 /* 7 * Copyright (C) 2019-202 0Oracle Corporation7 * Copyright (C) 2019-2021 Oracle Corporation 8 8 * 9 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 100 100 if (pMsgHdr) 101 101 { 102 SHCLEVENTID idEvent = ShClEventIdGenerateAndRegister(&pCtx->pTransfer->Events); 103 if (idEvent != NIL_SHCLEVENTID) 102 PSHCLEVENT pEvent; 103 rc = ShClEventSourceGenerateAndRegisterEvent(&pClient->EventSrc, &pEvent); 104 if (RT_SUCCESS(rc)) 104 105 { 105 106 HGCMSvcSetU64(&pMsgHdr->aParms[0], VBOX_SHCL_CONTEXTID_MAKE(pClient->State.uSessionID, 106 pCtx->pTransfer->State.uID, idEvent));107 pCtx->pTransfer->State.uID, pEvent->idEvent)); 107 108 HGCMSvcSetU32(&pMsgHdr->aParms[1], 0 /* fRoots */); 108 109 … … 117 118 { 118 119 PSHCLEVENTPAYLOAD pPayloadHdr; 119 rc = ShClEventWait(&pCtx->pTransfer->Events, idEvent, 120 pCtx->pTransfer->uTimeoutMs, &pPayloadHdr); 120 rc = ShClEventWait(pEvent, pCtx->pTransfer->uTimeoutMs, &pPayloadHdr); 121 121 if (RT_SUCCESS(rc)) 122 122 { … … 141 141 VBOX_SHCL_CPARMS_ROOT_LIST_ENTRY_READ_REQ); 142 142 143 idEvent = ShClEventIdGenerateAndRegister(&pCtx->pTransfer->Events); 144 if (idEvent != NIL_SHCLEVENTID) 143 PSHCLEVENT pEvRoot; 144 rc = ShClEventSourceGenerateAndRegisterEvent(&pClient->EventSrc, &pEvRoot); 145 if (RT_SUCCESS(rc)) 145 146 { 146 147 HGCMSvcSetU64(&pMsgEntry->aParms[0], 147 148 VBOX_SHCL_CONTEXTID_MAKE(pClient->State.uClientID, 148 pCtx->pTransfer->State.uID, idEvent));149 pCtx->pTransfer->State.uID, pEvRoot->idEvent)); 149 150 HGCMSvcSetU32(&pMsgEntry->aParms[1], 0 /* fRoots */); 150 151 HGCMSvcSetU32(&pMsgEntry->aParms[2], i /* uIndex */); … … 155 156 156 157 PSHCLEVENTPAYLOAD pPayloadEntry; 157 rc = ShClEventWait(&pCtx->pTransfer->Events, idEvent, 158 pCtx->pTransfer->uTimeoutMs, &pPayloadEntry); 158 rc = ShClEventWait(pEvent, pCtx->pTransfer->uTimeoutMs, &pPayloadEntry); 159 159 if (RT_FAILURE(rc)) 160 160 break; … … 167 167 ShClPayloadFree(pPayloadEntry); 168 168 169 ShClEventUnregister(&pCtx->pTransfer->Events, idEvent); 169 ShClEventRelease(pEvRoot); 170 pEvRoot = NULL; 170 171 } 171 172 else … … 197 198 } 198 199 199 ShClEvent Unregister(&pCtx->pTransfer->Events, idEvent);200 ShClEventRelease(pEvent); 200 201 } 201 202 else … … 223 224 if (pMsg) 224 225 { 225 const SHCLEVENTID idEvent = ShClEventIdGenerateAndRegister(&pCtx->pTransfer->Events); 226 if (idEvent != NIL_SHCLEVENTID) 226 PSHCLEVENT pEvent; 227 rc = ShClEventSourceGenerateAndRegisterEvent(&pClient->EventSrc, &pEvent); 228 if (RT_SUCCESS(rc)) 227 229 { 228 230 pMsg->idCtx = VBOX_SHCL_CONTEXTID_MAKE(pClient->State.uSessionID, pCtx->pTransfer->State.uID, 229 idEvent);231 pEvent->idEvent); 230 232 231 233 rc = shClSvcTransferSetListOpen(pMsg->cParms, pMsg->aParms, pMsg->idCtx, pOpenParms); … … 238 240 { 239 241 PSHCLEVENTPAYLOAD pPayload; 240 rc = ShClEventWait( &pCtx->pTransfer->Events, idEvent, pCtx->pTransfer->uTimeoutMs, &pPayload);242 rc = ShClEventWait(pEvent, pCtx->pTransfer->uTimeoutMs, &pPayload); 241 243 if (RT_SUCCESS(rc)) 242 244 { … … 257 259 } 258 260 259 ShClEvent Unregister(&pCtx->pTransfer->Events, idEvent);261 ShClEventRelease(pEvent); 260 262 } 261 263 else … … 282 284 if (pMsg) 283 285 { 284 const SHCLEVENTID idEvent = ShClEventIdGenerateAndRegister(&pCtx->pTransfer->Events); 285 if (idEvent != NIL_SHCLEVENTID) 286 PSHCLEVENT pEvent; 287 rc = ShClEventSourceGenerateAndRegisterEvent(&pClient->EventSrc, &pEvent); 288 if (RT_SUCCESS(rc)) 286 289 { 287 290 pMsg->idCtx = VBOX_SHCL_CONTEXTID_MAKE(pClient->State.uSessionID, pCtx->pTransfer->State.uID, 288 idEvent);291 pEvent->idEvent); 289 292 290 293 rc = shClSvcTransferSetListClose(pMsg->cParms, pMsg->aParms, pMsg->idCtx, hList); … … 297 300 { 298 301 PSHCLEVENTPAYLOAD pPayload; 299 rc = ShClEventWait( &pCtx->pTransfer->Events, idEvent, pCtx->pTransfer->uTimeoutMs, &pPayload);302 rc = ShClEventWait(pEvent, pCtx->pTransfer->uTimeoutMs, &pPayload); 300 303 if (RT_SUCCESS(rc)) 301 304 ShClPayloadFree(pPayload); … … 303 306 } 304 307 305 ShClEvent Unregister(&pCtx->pTransfer->Events, idEvent);308 ShClEventRelease(pEvent); 306 309 } 307 310 else … … 329 332 if (pMsg) 330 333 { 331 const SHCLEVENTID idEvent = ShClEventIdGenerateAndRegister(&pCtx->pTransfer->Events); 332 if (idEvent != NIL_SHCLEVENTID) 334 PSHCLEVENT pEvent; 335 rc = ShClEventSourceGenerateAndRegisterEvent(&pClient->EventSrc, &pEvent); 336 if (RT_SUCCESS(rc)) 333 337 { 334 338 HGCMSvcSetU64(&pMsg->aParms[0], VBOX_SHCL_CONTEXTID_MAKE(pClient->State.uSessionID, 335 pCtx->pTransfer->State.uID, idEvent));339 pCtx->pTransfer->State.uID, pEvent->idEvent)); 336 340 HGCMSvcSetU64(&pMsg->aParms[1], hList); 337 341 HGCMSvcSetU32(&pMsg->aParms[2], 0 /* fFlags */); … … 343 347 { 344 348 PSHCLEVENTPAYLOAD pPayload; 345 rc = ShClEventWait(&pCtx->pTransfer->Events, idEvent, 346 pCtx->pTransfer->uTimeoutMs, &pPayload); 349 rc = ShClEventWait(pEvent, pCtx->pTransfer->uTimeoutMs, &pPayload); 347 350 if (RT_SUCCESS(rc)) 348 351 { … … 355 358 } 356 359 357 ShClEvent Unregister(&pCtx->pTransfer->Events, idEvent);360 ShClEventRelease(pEvent); 358 361 } 359 362 else … … 391 394 if (pMsg) 392 395 { 393 const SHCLEVENTID idEvent = ShClEventIdGenerateAndRegister(&pCtx->pTransfer->Events); 394 if (idEvent != NIL_SHCLEVENTID) 396 PSHCLEVENT pEvent; 397 rc = ShClEventSourceGenerateAndRegisterEvent(&pClient->EventSrc, &pEvent); 398 if (RT_SUCCESS(rc)) 395 399 { 396 400 HGCMSvcSetU64(&pMsg->aParms[0], VBOX_SHCL_CONTEXTID_MAKE(pClient->State.uSessionID, 397 pCtx->pTransfer->State.uID, idEvent));401 pCtx->pTransfer->State.uID, pEvent->idEvent)); 398 402 HGCMSvcSetU64(&pMsg->aParms[1], hList); 399 403 HGCMSvcSetU32(&pMsg->aParms[2], 0 /* fInfo */); … … 405 409 { 406 410 PSHCLEVENTPAYLOAD pPayload; 407 rc = ShClEventWait( &pCtx->pTransfer->Events, idEvent, pCtx->pTransfer->uTimeoutMs, &pPayload);411 rc = ShClEventWait(pEvent, pCtx->pTransfer->uTimeoutMs, &pPayload); 408 412 if (RT_SUCCESS(rc)) 409 413 { … … 416 420 } 417 421 418 ShClEvent Unregister(&pCtx->pTransfer->Events, idEvent);422 ShClEventRelease(pEvent); 419 423 } 420 424 else … … 452 456 if (pMsg) 453 457 { 454 const SHCLEVENTID idEvent = ShClEventIdGenerateAndRegister(&pCtx->pTransfer->Events); 455 if (idEvent != NIL_SHCLEVENTID) 458 PSHCLEVENT pEvent; 459 rc = ShClEventSourceGenerateAndRegisterEvent(&pClient->EventSrc, &pEvent); 460 if (RT_SUCCESS(rc)) 456 461 { 457 462 LogFlowFunc(("pszPath=%s, fCreate=0x%x\n", pCreateParms->pszPath, pCreateParms->fCreate)); … … 460 465 461 466 HGCMSvcSetU64(&pMsg->aParms[0], VBOX_SHCL_CONTEXTID_MAKE(pClient->State.uSessionID, 462 pCtx->pTransfer->State.uID, idEvent));467 pCtx->pTransfer->State.uID, pEvent->idEvent)); 463 468 HGCMSvcSetU64(&pMsg->aParms[1], 0); /* uHandle */ 464 469 HGCMSvcSetU32(&pMsg->aParms[2], cbPath); … … 472 477 { 473 478 PSHCLEVENTPAYLOAD pPayload; 474 rc = ShClEventWait( &pCtx->pTransfer->Events, idEvent, pCtx->pTransfer->uTimeoutMs, &pPayload);479 rc = ShClEventWait(pEvent, pCtx->pTransfer->uTimeoutMs, &pPayload); 475 480 if (RT_SUCCESS(rc)) 476 481 { … … 490 495 } 491 496 492 ShClEvent Unregister(&pCtx->pTransfer->Events, idEvent);497 ShClEventRelease(pEvent); 493 498 } 494 499 else … … 515 520 if (pMsg) 516 521 { 517 const SHCLEVENTID idEvent = ShClEventIdGenerateAndRegister(&pCtx->pTransfer->Events); 518 if (idEvent != NIL_SHCLEVENTID) 522 PSHCLEVENT pEvent; 523 rc = ShClEventSourceGenerateAndRegisterEvent(&pClient->EventSrc, &pEvent); 524 if (RT_SUCCESS(rc)) 519 525 { 520 526 HGCMSvcSetU64(&pMsg->aParms[0], VBOX_SHCL_CONTEXTID_MAKE(pClient->State.uSessionID, 521 pCtx->pTransfer->State.uID, idEvent));527 pCtx->pTransfer->State.uID, pEvent->idEvent)); 522 528 HGCMSvcSetU64(&pMsg->aParms[1], hObj); 523 529 … … 528 534 { 529 535 PSHCLEVENTPAYLOAD pPayload; 530 rc = ShClEventWait( &pCtx->pTransfer->Events, idEvent, pCtx->pTransfer->uTimeoutMs, &pPayload);536 rc = ShClEventWait(pEvent, pCtx->pTransfer->uTimeoutMs, &pPayload); 531 537 if (RT_SUCCESS(rc)) 532 538 { … … 544 550 } 545 551 546 ShClEvent Unregister(&pCtx->pTransfer->Events, idEvent);552 ShClEventRelease(pEvent); 547 553 } 548 554 else … … 570 576 if (pMsg) 571 577 { 572 const SHCLEVENTID idEvent = ShClEventIdGenerateAndRegister(&pCtx->pTransfer->Events); 573 if (idEvent != NIL_SHCLEVENTID) 578 PSHCLEVENT pEvent; 579 rc = ShClEventSourceGenerateAndRegisterEvent(&pClient->EventSrc, &pEvent); 580 if (RT_SUCCESS(rc)) 574 581 { 575 582 HGCMSvcSetU64(&pMsg->aParms[0], VBOX_SHCL_CONTEXTID_MAKE(pClient->State.uSessionID, 576 pCtx->pTransfer->State.uID, idEvent));583 pCtx->pTransfer->State.uID, pEvent->idEvent)); 577 584 HGCMSvcSetU64(&pMsg->aParms[1], hObj); 578 585 HGCMSvcSetU32(&pMsg->aParms[2], cbData); … … 585 592 { 586 593 PSHCLEVENTPAYLOAD pPayload; 587 rc = ShClEventWait( &pCtx->pTransfer->Events, idEvent, pCtx->pTransfer->uTimeoutMs, &pPayload);594 rc = ShClEventWait(pEvent, pCtx->pTransfer->uTimeoutMs, &pPayload); 588 595 if (RT_SUCCESS(rc)) 589 596 { … … 604 611 } 605 612 606 ShClEvent Unregister(&pCtx->pTransfer->Events, idEvent);613 ShClEventRelease(pEvent); 607 614 } 608 615 else … … 630 637 if (pMsg) 631 638 { 632 const SHCLEVENTID idEvent = ShClEventIdGenerateAndRegister(&pCtx->pTransfer->Events); 633 if (idEvent != NIL_SHCLEVENTID) 639 PSHCLEVENT pEvent; 640 rc = ShClEventSourceGenerateAndRegisterEvent(&pClient->EventSrc, &pEvent); 641 if (RT_SUCCESS(rc)) 634 642 { 635 643 HGCMSvcSetU64(&pMsg->aParms[0], VBOX_SHCL_CONTEXTID_MAKE(pClient->State.uSessionID, 636 pCtx->pTransfer->State.uID, idEvent));644 pCtx->pTransfer->State.uID, pEvent->idEvent)); 637 645 HGCMSvcSetU64(&pMsg->aParms[1], hObj); 638 646 HGCMSvcSetU64(&pMsg->aParms[2], cbData); … … 645 653 { 646 654 PSHCLEVENTPAYLOAD pPayload; 647 rc = ShClEventWait( &pCtx->pTransfer->Events, idEvent, pCtx->pTransfer->uTimeoutMs, &pPayload);655 rc = ShClEventWait(pEvent, pCtx->pTransfer->uTimeoutMs, &pPayload); 648 656 if (RT_SUCCESS(rc)) 649 657 { … … 659 667 } 660 668 661 ShClEvent Unregister(&pCtx->pTransfer->Events, idEvent);669 ShClEventRelease(pEvent); 662 670 } 663 671 else … … 1191 1199 uint32_t cParms, VBOXHGCMSVCPARM aParms[]) 1192 1200 { 1193 RT_NOREF(pClient );1201 RT_NOREF(pClient, pTransfer); 1194 1202 1195 1203 int rc; … … 1225 1233 if (RT_SUCCESS(rc)) 1226 1234 { 1227 const SHCLEVENTID idEvent = VBOX_SHCL_CONTEXTID_GET_EVENT(uCID); 1228 1229 LogFlowFunc(("uCID=%RU64 -> idEvent=%RU32\n", uCID, idEvent)); 1230 1231 rc = ShClEventSignal(&pTransfer->Events, idEvent, pPayload); 1235 const PSHCLEVENT pEvent 1236 = ShClEventSourceGetFromId(&pClient->EventSrc, VBOX_SHCL_CONTEXTID_GET_EVENT(uCID)); 1237 if (pEvent) 1238 { 1239 LogFlowFunc(("uCID=%RU64 -> idEvent=%RU32\n", uCID, pEvent->idEvent)); 1240 1241 rc = ShClEventSignal(pEvent, pPayload); 1242 } 1243 /** @todo Silently skip? */ 1232 1244 } 1233 1245 break; … … 1382 1394 uint32_t cbData = sizeof(SHCLROOTLISTHDR); 1383 1395 1384 const SHCLEVENTID idEvent = VBOX_SHCL_CONTEXTID_GET_EVENT(uCID); 1385 1386 PSHCLEVENTPAYLOAD pPayload; 1387 rc = ShClPayloadAlloc(idEvent, pvData, cbData, &pPayload); 1388 if (RT_SUCCESS(rc)) 1389 { 1390 rc = ShClEventSignal(&pTransfer->Events, idEvent, pPayload); 1391 if (RT_FAILURE(rc)) 1392 ShClPayloadFree(pPayload); 1393 } 1396 const PSHCLEVENT pEvent = ShClEventSourceGetFromId(&pClient->EventSrc, VBOX_SHCL_CONTEXTID_GET_EVENT(uCID)); 1397 if (pEvent) 1398 { 1399 PSHCLEVENTPAYLOAD pPayload; 1400 rc = ShClPayloadAlloc(pEvent->idEvent, pvData, cbData, &pPayload); 1401 if (RT_SUCCESS(rc)) 1402 { 1403 rc = ShClEventSignal(pEvent, pPayload); 1404 if (RT_FAILURE(rc)) 1405 ShClPayloadFree(pPayload); 1406 } 1407 } 1408 else 1409 rc = VERR_SHCLPB_EVENT_ID_NOT_FOUND; 1394 1410 } 1395 1411 break; … … 1427 1443 uint32_t cbData = sizeof(SHCLROOTLISTENTRY); 1428 1444 1429 const SHCLEVENTID idEvent = VBOX_SHCL_CONTEXTID_GET_EVENT(uCID); 1430 1431 PSHCLEVENTPAYLOAD pPayload; 1432 rc = ShClPayloadAlloc(idEvent, pvData, cbData, &pPayload); 1433 if (RT_SUCCESS(rc)) 1434 { 1435 rc = ShClEventSignal(&pTransfer->Events, idEvent, pPayload); 1436 if (RT_FAILURE(rc)) 1437 ShClPayloadFree(pPayload); 1438 } 1445 const PSHCLEVENT pEvent = ShClEventSourceGetFromId(&pClient->EventSrc, VBOX_SHCL_CONTEXTID_GET_EVENT(uCID)); 1446 if (pEvent) 1447 { 1448 PSHCLEVENTPAYLOAD pPayload; 1449 rc = ShClPayloadAlloc(pEvent->idEvent, pvData, cbData, &pPayload); 1450 if (RT_SUCCESS(rc)) 1451 { 1452 rc = ShClEventSignal(pEvent, pPayload); 1453 if (RT_FAILURE(rc)) 1454 ShClPayloadFree(pPayload); 1455 } 1456 } 1457 else 1458 rc = VERR_SHCLPB_EVENT_ID_NOT_FOUND; 1439 1459 } 1440 1460 break; … … 1502 1522 uint32_t cbData = sizeof(SHCLLISTHDR); 1503 1523 1504 const SHCLEVENTID idEvent = VBOX_SHCL_CONTEXTID_GET_EVENT(uCID); 1505 1506 PSHCLEVENTPAYLOAD pPayload; 1507 rc = ShClPayloadAlloc(idEvent, pvData, cbData, &pPayload); 1508 if (RT_SUCCESS(rc)) 1524 const PSHCLEVENT pEvent = ShClEventSourceGetFromId(&pClient->EventSrc, VBOX_SHCL_CONTEXTID_GET_EVENT(uCID)); 1525 if (pEvent) 1509 1526 { 1510 rc = ShClEventSignal(&pTransfer->Events, idEvent, pPayload); 1511 if (RT_FAILURE(rc)) 1512 ShClPayloadFree(pPayload); 1527 PSHCLEVENTPAYLOAD pPayload; 1528 rc = ShClPayloadAlloc(pEvent->idEvent, pvData, cbData, &pPayload); 1529 if (RT_SUCCESS(rc)) 1530 { 1531 rc = ShClEventSignal(pEvent, pPayload); 1532 if (RT_FAILURE(rc)) 1533 ShClPayloadFree(pPayload); 1534 } 1513 1535 } 1536 else 1537 rc = VERR_SHCLPB_EVENT_ID_NOT_FOUND; 1514 1538 } 1515 1539 } … … 1551 1575 uint32_t cbData = sizeof(SHCLLISTENTRY); 1552 1576 1553 const SHCLEVENTID idEvent = VBOX_SHCL_CONTEXTID_GET_EVENT(uCID); 1554 1555 PSHCLEVENTPAYLOAD pPayload; 1556 rc = ShClPayloadAlloc(idEvent, pvData, cbData, &pPayload); 1557 if (RT_SUCCESS(rc)) 1577 const PSHCLEVENT pEvent = ShClEventSourceGetFromId(&pClient->EventSrc, VBOX_SHCL_CONTEXTID_GET_EVENT(uCID)); 1578 if (pEvent) 1558 1579 { 1559 rc = ShClEventSignal(&pTransfer->Events, idEvent, pPayload); 1560 if (RT_FAILURE(rc)) 1561 ShClPayloadFree(pPayload); 1580 PSHCLEVENTPAYLOAD pPayload; 1581 rc = ShClPayloadAlloc(pEvent->idEvent, pvData, cbData, &pPayload); 1582 if (RT_SUCCESS(rc)) 1583 { 1584 rc = ShClEventSignal(pEvent, pPayload); 1585 if (RT_FAILURE(rc)) 1586 ShClPayloadFree(pPayload); 1587 } 1562 1588 } 1589 else 1590 rc = VERR_SHCLPB_EVENT_ID_NOT_FOUND; 1563 1591 } 1564 1592 } … … 1656 1684 uint32_t cbData = sizeof(SHCLOBJDATACHUNK); 1657 1685 1658 const SHCLEVENTID idEvent = VBOX_SHCL_CONTEXTID_GET_EVENT(uCID); 1659 1660 PSHCLEVENTPAYLOAD pPayload; 1661 rc = ShClPayloadAlloc(idEvent, pvData, cbData, &pPayload); 1662 if (RT_SUCCESS(rc)) 1663 { 1664 rc = ShClEventSignal(&pTransfer->Events, idEvent, pPayload); 1665 if (RT_FAILURE(rc)) 1666 ShClPayloadFree(pPayload); 1667 } 1686 const PSHCLEVENT pEvent = ShClEventSourceGetFromId(&pClient->EventSrc, VBOX_SHCL_CONTEXTID_GET_EVENT(uCID)); 1687 if (pEvent) 1688 { 1689 PSHCLEVENTPAYLOAD pPayload; 1690 rc = ShClPayloadAlloc(pEvent->idEvent, pvData, cbData, &pPayload); 1691 if (RT_SUCCESS(rc)) 1692 { 1693 rc = ShClEventSignal(pEvent, pPayload); 1694 if (RT_FAILURE(rc)) 1695 ShClPayloadFree(pPayload); 1696 } 1697 } 1698 else 1699 rc = VERR_SHCLPB_EVENT_ID_NOT_FOUND; 1668 1700 } 1669 1701 … … 1738 1770 * @param uStatus Status to report. 1739 1771 * @param rcTransfer Result code to report. Optional and depending on status. 1740 * @param pidEvent Where to store the created wait event. Optional. 1772 * @param ppEvent Where to return the wait event on success. Optional. 1773 * Must be released by the caller with ShClEventRelease(). 1741 1774 */ 1742 1775 int shClSvcTransferSendStatus(PSHCLCLIENT pClient, PSHCLTRANSFER pTransfer, SHCLTRANSFERSTATUS uStatus, 1743 int rcTransfer, PSHCLEVENT ID pidEvent)1776 int rcTransfer, PSHCLEVENT *ppEvent) 1744 1777 { 1745 1778 AssertPtrReturn(pClient, VERR_INVALID_POINTER); 1746 1779 AssertPtrReturn(pTransfer, VERR_INVALID_POINTER); 1747 /* p idEvent is optional. */1780 /* ppEvent is optional. */ 1748 1781 1749 1782 PSHCLCLIENTMSG pMsgReadData = shClSvcMsgAlloc(pClient, VBOX_SHCL_HOST_MSG_TRANSFER_STATUS, … … 1752 1785 return VERR_NO_MEMORY; 1753 1786 1754 int rc; 1755 1756 const SHCLEVENTID idEvent = ShClEventIdGenerateAndRegister(&pTransfer->Events); 1757 if (idEvent != NIL_SHCLEVENTID) 1787 PSHCLEVENT pEvent; 1788 int rc = ShClEventSourceGenerateAndRegisterEvent(&pClient->EventSrc, &pEvent); 1789 if (RT_SUCCESS(rc)) 1758 1790 { 1759 1791 HGCMSvcSetU64(&pMsgReadData->aParms[0], VBOX_SHCL_CONTEXTID_MAKE(pClient->State.uSessionID, 1760 pTransfer->State.uID, idEvent));1792 pTransfer->State.uID, pEvent->idEvent)); 1761 1793 HGCMSvcSetU32(&pMsgReadData->aParms[1], pTransfer->State.enmDir); 1762 1794 HGCMSvcSetU32(&pMsgReadData->aParms[2], uStatus); … … 1772 1804 ShClTransferStatusToStr(uStatus), rcTransfer, pTransfer->State.uID)); 1773 1805 1774 if (p idEvent)1775 { 1776 *p idEvent = idEvent;1777 } 1778 else /* If event is not consumed by the caller, unregisterevent again. */1779 ShClEvent Unregister(&pTransfer->Events, idEvent);1806 if (ppEvent) 1807 { 1808 *ppEvent = pEvent; /* Takes ownership. */ 1809 } 1810 else /* If event is not consumed by the caller, release the event again. */ 1811 ShClEventRelease(pEvent); 1780 1812 } 1781 1813 else 1782 ShClEvent Unregister(&pTransfer->Events, idEvent);1814 ShClEventRelease(pEvent); 1783 1815 } 1784 1816 else … … 1869 1901 if (RT_SUCCESS(rc)) 1870 1902 { 1871 SHCLEVENTID idEvent;1903 PSHCLEVENT pEvent; 1872 1904 rc = shClSvcTransferSendStatus(pClient, pTransfer, 1873 SHCLTRANSFERSTATUS_INITIALIZED, VINF_SUCCESS, 1874 &idEvent); 1905 SHCLTRANSFERSTATUS_INITIALIZED, VINF_SUCCESS, &pEvent); 1875 1906 if (RT_SUCCESS(rc)) 1876 1907 { … … 1882 1913 1883 1914 PSHCLEVENTPAYLOAD pPayload = NULL; 1884 rc = ShClEventWait( &pTransfer->Events, idEvent, pTransfer->uTimeoutMs, &pPayload);1915 rc = ShClEventWait(pEvent, pTransfer->uTimeoutMs, &pPayload); 1885 1916 if (RT_SUCCESS(rc)) 1886 1917 { … … 1907 1938 1908 1939 ShClPayloadFree(pPayload); 1940 ShClEventRelease(pEvent); 1909 1941 1910 1942 /* Re-enter the client's critical section again. */ … … 1954 1986 int shClSvcTransferStop(PSHCLCLIENT pClient, PSHCLTRANSFER pTransfer) 1955 1987 { 1956 SHCLEVENTID idEvent;1988 PSHCLEVENT pEvent; 1957 1989 int rc = shClSvcTransferSendStatus(pClient, pTransfer, 1958 SHCLTRANSFERSTATUS_STOPPED, VINF_SUCCESS, 1959 &idEvent); 1990 SHCLTRANSFERSTATUS_STOPPED, VINF_SUCCESS, &pEvent); 1960 1991 if (RT_SUCCESS(rc)) 1961 1992 { 1962 1993 LogRel2(("Shared Clipboard: Waiting for stop of transfer %RU32 on guest ...\n", pTransfer->State.uID)); 1963 1994 1964 rc = ShClEventWait( &pTransfer->Events, idEvent, pTransfer->uTimeoutMs, NULL);1995 rc = ShClEventWait(pEvent, pTransfer->uTimeoutMs, NULL /* ppPayload */); 1965 1996 if (RT_SUCCESS(rc)) 1966 1997 LogRel2(("Shared Clipboard: Stopped transfer %RU32 on guest\n", pTransfer->State.uID)); 1998 1999 ShClEventRelease(pEvent); 1967 2000 } 1968 2001 -
trunk/src/VBox/HostServices/SharedClipboard/VBoxSharedClipboardSvc-win.cpp
r91749 r92735 5 5 6 6 /* 7 * Copyright (C) 2006-202 0Oracle Corporation7 * Copyright (C) 2006-2021 Oracle Corporation 8 8 * 9 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 207 207 208 208 ShClEventRelease(&pCtx->pClient->EventSrc, idEvent); 209 ShClEventUnregister(&pCtx->pClient->EventSrc, idEvent);210 209 } 211 210 -
trunk/src/VBox/HostServices/SharedClipboard/VBoxSharedClipboardSvc-x11.cpp
r91749 r92735 5 5 6 6 /* 7 * Copyright (C) 2006-202 0Oracle Corporation7 * Copyright (C) 2006-2021 Oracle Corporation 8 8 * 9 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 218 218 pClient, uFormat, pvData, cbData, pcbActual)); 219 219 220 int rc = VINF_SUCCESS;220 int rc; 221 221 222 222 CLIPREADCBREQ *pReq = (CLIPREADCBREQ *)RTMemAllocZ(sizeof(CLIPREADCBREQ)); 223 223 if (pReq) 224 224 { 225 pReq->pv = pvData; 226 pReq->cb = cbData; 227 pReq->pcbActual = pcbActual; 228 const SHCLEVENTID idEvent = ShClEventIdGenerateAndRegister(&pClient->EventSrc); 229 pReq->idEvent = idEvent; 230 if (idEvent != NIL_SHCLEVENTID) 231 { 225 PSHCLEVENT pEvent; 226 rc = ShClEventSourceGenerateAndRegisterEvent(&pClient->EventSrc, &pEvent); 227 if (RT_SUCCESS(rc)) 228 { 229 pReq->pv = pvData; 230 pReq->cb = cbData; 231 pReq->pcbActual = pcbActual; 232 pReq->idEvent = pEvent->idEvent; 233 232 234 /* Note: ShClX11ReadDataFromX11() will consume pReq on success. */ 233 235 rc = ShClX11ReadDataFromX11(&pClient->State.pCtx->X11, uFormat, pReq); … … 235 237 { 236 238 PSHCLEVENTPAYLOAD pPayload; 237 rc = ShClEventWait( &pClient->EventSrc, idEvent, 30 * 1000, &pPayload);239 rc = ShClEventWait(pEvent, 30 * 1000, &pPayload); 238 240 if (RT_SUCCESS(rc)) 239 241 { … … 251 253 } 252 254 253 ShClEventUnregister(&pClient->EventSrc, idEvent); 254 } 255 else 256 rc = VERR_SHCLPB_MAX_EVENTS_REACHED; 255 ShClEventRelease(pEvent); 256 } 257 257 258 258 if (RT_FAILURE(rc)) … … 331 331 if (RT_SUCCESS(rc2)) 332 332 { 333 rc2 = ShClEventSignal(&pCtx->pClient->EventSrc, pReq->idEvent, pPayload); 333 const PSHCLEVENT pEvent = ShClEventSourceGetFromId(&pCtx->pClient->EventSrc, pReq->idEvent); 334 if (pEvent) 335 rc2 = ShClEventSignal(pEvent, pPayload); 336 334 337 RTCritSectLeave(&pCtx->pClient->CritSect); 338 335 339 if (RT_SUCCESS(rc2)) 336 340 pPayload = NULL; … … 394 398 { 395 399 /* Request data from the guest. */ 396 SHCLEVENTID idEvent;397 rc = ShClSvcGuestDataRequest(pCtx->pClient, uFmt, & idEvent);400 PSHCLEVENT pEvent; 401 rc = ShClSvcGuestDataRequest(pCtx->pClient, uFmt, &pEvent); 398 402 if (RT_SUCCESS(rc)) 399 403 { … … 401 405 402 406 PSHCLEVENTPAYLOAD pPayload; 403 rc = ShClEventWait( &pCtx->pClient->EventSrc, idEvent, 30 * 1000, &pPayload);407 rc = ShClEventWait(pEvent, 30 * 1000, &pPayload); 404 408 if (RT_SUCCESS(rc)) 405 409 { … … 418 422 RTCritSectEnter(&pClient->CritSect); 419 423 420 ShClEventRelease(&pCtx->pClient->EventSrc, idEvent); 421 ShClEventUnregister(&pCtx->pClient->EventSrc, idEvent); 424 ShClEventRelease(pEvent); 422 425 } 423 426 } … … 459 462 LogFlowFuncEnter(); 460 463 461 int rc; 462 463 SHCLEVENTID idEvent = ShClEventIdGenerateAndRegister(&pClient->EventSrc); 464 if (idEvent != NIL_SHCLEVENTID) 464 PSHCLEVENT pEvent; 465 int rc = ShClEventSourceGenerateAndRegisterEvent(&pClient->EventSrc, &pEvent); 466 if (RT_SUCCESS(rc)) 465 467 { 466 468 CLIPREADCBREQ *pReq = (CLIPREADCBREQ *)RTMemAllocZ(sizeof(CLIPREADCBREQ)); 467 469 if (pReq) 468 470 { 469 pReq->idEvent = idEvent;471 pReq->idEvent = pEvent->idEvent; 470 472 471 473 rc = ShClX11ReadDataFromX11(&pClient->State.pCtx->X11, VBOX_SHCL_FMT_URI_LIST, pReq); … … 474 476 /* X supplies the data asynchronously, so we need to wait for data to arrive first. */ 475 477 PSHCLEVENTPAYLOAD pPayload; 476 rc = ShClEventWait( &pClient->EventSrc, idEvent, 30 * 1000, &pPayload);478 rc = ShClEventWait(pEvent, 30 * 1000, &pPayload); 477 479 if (RT_SUCCESS(rc)) 478 480 { … … 485 487 rc = VERR_NO_MEMORY; 486 488 487 ShClEvent Unregister(&pClient->EventSrc, idEvent);489 ShClEventRelease(pEvent); 488 490 } 489 491 else -
trunk/src/VBox/HostServices/SharedClipboard/VBoxSharedClipboardSvc.cpp
r92240 r92735 5 5 6 6 /* 7 * Copyright (C) 2006-202 0Oracle Corporation7 * Copyright (C) 2006-2021 Oracle Corporation 8 8 * 9 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 1201 1201 * @param pClient Client to request to read data form. 1202 1202 * @param fFormats The formats being requested, OR'ed together (VBOX_SHCL_FMT_XXX). 1203 * @param pidEvent Event ID for waiting for new data. Optional. 1204 * Must be released by the caller with ShClEventRelease() before unregistering then. 1205 */ 1206 int ShClSvcGuestDataRequest(PSHCLCLIENT pClient, SHCLFORMATS fFormats, PSHCLEVENTID pidEvent) 1207 { 1208 LogFlowFuncEnter(); 1209 if (pidEvent) 1210 *pidEvent = NIL_SHCLEVENTID; 1211 AssertPtrReturn(pClient, VERR_INVALID_POINTER); 1203 * @param ppEvent Where to return the event for waiting for new data on success. Optional. 1204 * Must be released by the caller with ShClEventRelease(). 1205 */ 1206 int ShClSvcGuestDataRequest(PSHCLCLIENT pClient, SHCLFORMATS fFormats, PSHCLEVENT *ppEvent) 1207 { 1208 AssertPtrReturn(pClient, VERR_INVALID_POINTER); 1212 1209 1213 1210 LogFlowFunc(("fFormats=%#x\n", fFormats)); 1214 1211 1215 1212 int rc = VERR_NOT_SUPPORTED; 1216 1217 SHCLEVENTID idEvent = NIL_SHCLEVENTID;1218 1213 1219 1214 /* Generate a separate message for every (valid) format we support. */ … … 1255 1250 RTCritSectEnter(&pClient->CritSect); 1256 1251 1257 idEvent = ShClEventIdGenerateAndRegister(&pClient->EventSrc); 1258 if (idEvent != NIL_SHCLEVENTID) 1252 PSHCLEVENT pEvent; 1253 rc = ShClEventSourceGenerateAndRegisterEvent(&pClient->EventSrc, &pEvent); 1254 if (RT_SUCCESS(rc)) 1259 1255 { 1260 LogFlowFunc(("fFormats=%#x -> fFormat=%#x, idEvent=%#x\n", fFormats, fFormat, idEvent));1261 1262 const uint64_t uCID = VBOX_SHCL_CONTEXTID_MAKE(pClient->State.uSessionID, pClient->EventSrc.uID, idEvent);1256 LogFlowFunc(("fFormats=%#x -> fFormat=%#x, idEvent=%#x\n", fFormats, fFormat, pEvent->idEvent)); 1257 1258 const uint64_t uCID = VBOX_SHCL_CONTEXTID_MAKE(pClient->State.uSessionID, pClient->EventSrc.uID, pEvent->idEvent); 1263 1259 1264 1260 rc = VINF_SUCCESS; … … 1296 1292 1297 1293 shClSvcMsgAdd(pClient, pMsg, true /* fAppend */); 1294 1295 /* Retain the last event generated (in case there were multiple clipboard formats) 1296 * if we need to return the event to the caller. */ 1297 if (ppEvent) 1298 { 1299 ShClEventRetain(pEvent); 1300 *ppEvent = pEvent; 1301 } 1302 1303 shClSvcClientWakeup(pClient); 1298 1304 } 1299 1305 } … … 1311 1317 if (RT_FAILURE(rc)) 1312 1318 break; 1313 }1314 1315 if (RT_SUCCESS(rc))1316 {1317 RTCritSectEnter(&pClient->CritSect);1318 1319 /* Retain the last event generated (in case there were multiple clipboard formats)1320 * if we need to return the event ID to the caller. */1321 if (pidEvent)1322 {1323 ShClEventRetain(&pClient->EventSrc, idEvent);1324 *pidEvent = idEvent;1325 }1326 1327 shClSvcClientWakeup(pClient);1328 1329 RTCritSectLeave(&pClient->CritSect);1330 1319 } 1331 1320 … … 1355 1344 1356 1345 /* 1357 * Validate in tput.1346 * Validate input. 1358 1347 */ 1359 1348 AssertPtrReturn(pClient, VERR_INVALID_POINTER); … … 1364 1353 const SHCLEVENTID idEvent = VBOX_SHCL_CONTEXTID_GET_EVENT(pCmdCtx->uContextID); 1365 1354 AssertMsgReturn(idEvent != NIL_SHCLEVENTID, ("NIL event in context ID %#RX64\n", pCmdCtx->uContextID), VERR_WRONG_ORDER); 1366 AssertMsg(ShClEventGet(&pClient->EventSrc, idEvent) != NULL, ("Event %#x not found\n", idEvent)); 1355 1356 PSHCLEVENT pEvent = ShClEventSourceGetFromId(&pClient->EventSrc, idEvent); 1357 AssertMsg(pEvent != NULL, ("Event %#x not found\n", idEvent)); 1367 1358 1368 1359 /* … … 1380 1371 * Signal the event. 1381 1372 */ 1382 RTCritSectEnter(&pClient->CritSect); 1383 int rc2 = ShClEventSignal(&pClient->EventSrc, idEvent, pPayload); 1384 RTCritSectLeave(&pClient->CritSect); 1373 int rc2 = ShClEventSignal(pEvent, pPayload); 1385 1374 if (RT_FAILURE(rc2)) 1386 1375 { … … 1391 1380 1392 1381 /* 1393 * No one holding a reference to the event anymore? Unregister it. 1394 */ 1395 /** @todo r=bird: This isn't how reference counting is supposed to be 1396 * implemented, is it now? */ 1397 if (ShClEventGetRefs(&pClient->EventSrc, idEvent) == 0) 1398 { 1399 rc2 = ShClEventUnregister(&pClient->EventSrc, idEvent); 1400 if (RT_SUCCESS(rc)) 1401 rc = rc2; 1402 } 1382 * Release reference (and free it if not used anymore). 1383 */ 1384 ShClEventRelease(pEvent); 1403 1385 1404 1386 LogFlowFuncLeaveRC(rc);
Note:
See TracChangeset
for help on using the changeset viewer.