- Timestamp:
- Jan 28, 2025 9:28:51 AM (3 months ago)
- svn:sync-xref-src-repo-rev:
- 167206
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/WINNT/VBoxTray/VBoxIPC.cpp
r106466 r107958 45 45 46 46 #include "VBoxTray.h" 47 #include "VBoxTrayInternal.h" 47 48 #include "VBoxTrayMsg.h" 48 49 #include "VBoxHelpers.h" … … 282 283 AssertPtrReturnVoid(pvInstance); 283 284 284 LogFlowFunc(("Stopping pvInstance=%p\n", pvInstance));285 VBoxTrayInfo("IPC: Stopping worker thread ...\n"); 285 286 286 287 /* Shut down local IPC server. */ … … 331 332 rc = RTLocalIpcServerDestroy(pCtx->hServer); 332 333 if (RT_FAILURE(rc)) 333 LogFlowFunc(("Unable to destroy IPC server, rc=%Rrc\n", rc));334 VBoxTrayError("IPC: Unable to destroy IPC server, rc=%Rrc\n", rc); 334 335 335 336 int rc2 = RTCritSectLeave(&pCtx->CritSect); … … 338 339 } 339 340 340 LogFlowFunc(("Waiting for remaining IPC sessions to shut down ...\n"));341 VBoxTrayInfo("IPC: Waiting for remaining IPC sessions to shut down ...\n"); 341 342 342 343 /* Wait for all IPC session threads to shut down. */ … … 359 360 } while (!fListIsEmpty); 360 361 361 AssertMsg(fListIsEmpty, 362 ("Session thread list is not empty when it should\n")); 363 364 LogFlowFunc(("All remaining IPC sessions shut down\n")); 362 AssertMsg(fListIsEmpty, ("Session thread list is not empty when it should\n")); 363 VBoxTrayInfo("IPC: All remaining IPC sessions shut down\n"); 365 364 366 365 int rc2 = RTCritSectDelete(&pCtx->CritSect); … … 368 367 rc = rc2; 369 368 370 LogFlowFunc(("Destroyed pvInstance=%p, rc=%Rrc\n", 371 pvInstance, rc)); 369 LogFlowFunc(("Destroyed pvInstance=%p, rc=%Rrc\n", pvInstance, rc)); 372 370 } 373 371 … … 387 385 AssertReturn(hSession != NIL_RTLOCALIPCSESSION, VERR_INVALID_PARAMETER); 388 386 389 LogFlowFunc(("pThis=%p\n", pThis));387 VBoxTrayVerbose(1, "IPC: Session thread %#x started\n", hSession); 390 388 391 389 int rc = VINF_SUCCESS; … … 419 417 || Hdr.uVersion != VBOXTRAY_IPC_HDR_VERSION) 420 418 { 421 LogRelFunc(("Session %p: Invalid header magic/version: %#x, %#x, %#x, %#x\n",422 pThis, Hdr.uMagic, Hdr.uVersion, Hdr.enmMsgType, Hdr.cbPayload));419 VBoxTrayVerbose(1, "IPC: Session %#x: Invalid header magic/version: %#x, %#x, %#x, %#x\n", 420 hSession, Hdr.uMagic, Hdr.uVersion, Hdr.enmMsgType, Hdr.cbPayload); 423 421 rc = VERR_INVALID_MAGIC; 424 422 break; … … 426 424 if (Hdr.cbPayload > VBOXTRAY_IPC_MAX_PAYLOAD) 427 425 { 428 LogRelFunc(("Session %p: Payload to big: %#x, %#x, %#x, %#x - max %#x\n",429 pThis, Hdr.uMagic, Hdr.uVersion, Hdr.enmMsgType, Hdr.cbPayload, VBOXTRAY_IPC_MAX_PAYLOAD));426 VBoxTrayVerbose(1, "IPC: Session %#x: Payload too big: %#x, %#x, %#x, %#x - max %#x\n", 427 hSession, Hdr.uMagic, Hdr.uVersion, Hdr.enmMsgType, Hdr.cbPayload, VBOXTRAY_IPC_MAX_PAYLOAD); 430 428 rc = VERR_TOO_MUCH_DATA; 431 429 break; … … 434 432 || Hdr.enmMsgType >= VBOXTRAYIPCMSGTYPE_END) 435 433 { 436 LogRelFunc(("Session %p: Unknown message: %#x, %#x, %#x, %#x\n",437 pThis, Hdr.uMagic, Hdr.uVersion, Hdr.enmMsgType, Hdr.cbPayload));434 VBoxTrayVerbose(1, "IPC: Session %#x: Unknown message: %#x, %#x, %#x, %#x\n", 435 hSession, Hdr.uMagic, Hdr.uVersion, Hdr.enmMsgType, Hdr.cbPayload); 438 436 rc = VERR_INVALID_FUNCTION; 439 437 break; … … 461 459 } 462 460 if (RT_FAILURE(rc)) 463 LogFlowFunc(("Session %p: Handling command %RU32 failed with rc=%Rrc\n", pThis, Hdr.enmMsgType, rc)); 461 VBoxTrayVerbose(1, "IPC: Session %#x: Handling command %RU32 failed with rc=%Rrc\n", 462 hSession, Hdr.enmMsgType, rc); 464 463 } 465 464 else if (rc == VERR_CANCELLED) 466 465 { 467 LogFlowFunc(("Session %p: Waiting for data cancelled\n", pThis));466 VBoxTrayVerbose(1, "IPC: Session %#x: Waiting for data cancelled\n", hSession); 468 467 rc = VINF_SUCCESS; 469 468 break; 470 469 } 471 470 else 472 LogFlowFunc(("Session %p: Waiting for session data failed with rc=%Rrc\n", pThis, rc));473 } 474 475 LogFlowFunc(("Session %p: Handler ended with rc=%Rrc\n", pThis, rc));471 VBoxTrayError("IPC: Session %#x: Waiting for session data failed with rc=%Rrc\n", hSession, rc); 472 } 473 474 VBoxTrayVerbose(1, "IPC: Session thread %#x ended with rc=%Rrc\n", hSession, rc); 476 475 477 476 /* … … 480 479 int rc2 = RTLocalIpcSessionClose(hSession); 481 480 if (RT_FAILURE(rc2)) 482 LogFlowFunc(("Session %p: Failed closing session %p, rc=%Rrc\n", pThis, rc2));481 VBoxTrayError("IPC: Failed closing session %#x, rc=%Rrc\n", hSession, rc); 483 482 484 483 /* … … 486 485 */ 487 486 PVBOXIPCCONTEXT pCtx = ASMAtomicReadPtrT(&pThis->pCtx, PVBOXIPCCONTEXT); 488 AssertMsg(pCtx, ("Session % p: No context found\n", pThis));487 AssertMsg(pCtx, ("Session %#x: No context found\n", hSession)); 489 488 rc2 = RTCritSectEnter(&pCtx->CritSect); 490 489 if (RT_SUCCESS(rc2)) … … 498 497 } 499 498 500 LogFlowFunc(("Session %p: Terminated with rc=%Rrc, freeing ...\n", pThis, rc));499 VBoxTrayVerbose(1, "IPC: Session thread %#x terminated with rc=%Rrc\n", hSession, rc); 501 500 502 501 RTMemFree(pThis); … … 517 516 if (pSession) 518 517 { 519 pSession->pCtx = pCtx;518 pSession->pCtx = pCtx; 520 519 pSession->hSession = hSession; 521 520 pSession->fTerminate = false; … … 536 535 int rc2 = RTLocalIpcSessionClose(hSession); 537 536 if (RT_FAILURE(rc2)) 538 LogFlowFunc(("Failed closing session %p, rc=%Rrc\n", pSession, rc2)); 539 540 LogFlowFunc(("Failed to create thread for session %p, rc=%Rrc\n", pSession, rc)); 537 VBoxTrayError("IPC: Failed closing client session %#x with rc=%Rrc\n", hSession, rc2); 541 538 RTMemFree(pSession); 542 539 } … … 557 554 558 555 ASMAtomicWriteBool(&pSession->fTerminate, true); 556 557 VBoxTrayInfo("IPC: Stopping worker thread ...\n"); 559 558 560 559 RTLOCALIPCSESSION hSession; … … 567 566 568 567 /** 569 * Thread function to wait for and process seamless mode change 570 * requests 568 * Thread worker for the IPC handling code. 571 569 */ 572 570 DECLCALLBACK(int) vbtrIPCWorker(void *pvInstance, bool volatile *pfShutdown) 573 571 { 574 AssertPtr(pvInstance); 575 LogFlowFunc(("pvInstance=%p\n", pvInstance)); 576 577 LogFlowFuncEnter(); 572 AssertPtrReturn(pvInstance, VERR_INVALID_PARAMETER); 573 LogFunc(("pvInstance=%p\n", pvInstance)); 578 574 579 575 /* … … 583 579 RTThreadUserSignal(RTThreadSelf()); 584 580 581 VBoxTrayInfo("IPC: Worker thread started\n"); 582 585 583 PVBOXIPCCONTEXT pCtx = (PVBOXIPCCONTEXT)pvInstance; 586 584 AssertPtr(pCtx); … … 588 586 int rc; 589 587 590 bool fShutdown = false;591 588 for (;;) 592 589 { … … 597 594 if (rc == VERR_CANCELLED) 598 595 { 599 LogFlow(("Cancelled\n")); 600 fShutdown = true; 596 VBoxTrayInfo("IPC: Worker thread cancelled\n"); 597 rc = VINF_SUCCESS; 598 break; 601 599 } 602 600 else 603 LogRelFunc(("Listening failed with rc=%Rrc\n", rc)); 604 } 605 606 if (fShutdown) 607 break; 608 rc = vboxIPCSessionCreate(pCtx, hClientSession); 609 if (RT_FAILURE(rc)) 610 { 611 LogRelFunc(("Creating new IPC server session failed with rc=%Rrc\n", rc)); 612 /* Keep going. */ 601 VBoxTrayError("IPC: Listening failed with rc=%Rrc\n", rc); 602 } 603 else 604 { 605 VBoxTrayVerbose(1, "IPC: New client connected with session %#x\n", hClientSession); 606 607 rc = vboxIPCSessionCreate(pCtx, hClientSession); 608 if (RT_FAILURE(rc)) 609 { 610 VBoxTrayError("IPC: Creating session %#x failed with rc=%Rrc\n", hClientSession, rc); 611 /* Keep going. */ 612 } 613 613 } 614 614 615 615 if (*pfShutdown) 616 616 break; 617 } 618 619 LogFlowFuncLeaveRC(rc); 617 618 /* Back off a little to not hog the CPU too much. */ 619 RTThreadSleep(100 /* ms */); 620 } 621 622 VBoxTrayInfo("IPC: Worker thread stopped with %Rrc\n", rc); 620 623 return rc; 621 624 }
Note:
See TracChangeset
for help on using the changeset viewer.