Changeset 22722 in vbox for trunk/src/VBox/Frontends/VBoxManage
- Timestamp:
- Sep 2, 2009 3:05:57 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VBoxManage/VBoxManageGuestProp.cpp
r22693 r22722 419 419 420 420 /** 421 * Callback for processThreadEventQueue. 422 * 423 * @param pvUser Pointer to the callback object. 424 * 425 * @returns true if it should return or false if it should continue waiting for 426 * events. 427 */ 428 static bool eventExitCheck(void *pvUser) 429 { 430 GuestPropertyCallback const *pCallbacks = (GuestPropertyCallback const *)pvUser; 431 return pCallbacks->Signalled(); 432 } 433 434 /** 421 435 * Enumerates the properties in the guest property store. 422 436 * … … 469 483 * Set up the callback and wait. 470 484 * 485 * 471 486 * The waiting is done is 1 sec at the time since there there are races 472 487 * between the callback and us going to sleep. This also guards against … … 485 500 a->virtualBox->RegisterCallback(callback); 486 501 487 #ifdef USE_XPCOM_QUEUE 488 int const fdQueue = a->eventQ->GetEventQueueSelectFD(); 489 #endif 490 uint64_t const StartMsTS = RTTimeMilliTS(); 491 for (;;) 492 { 493 #ifdef VBOX_WITH_XPCOM 494 /* Process pending XPCOM events. */ 495 a->eventQ->ProcessPendingEvents(); 496 #endif 497 498 /* Signalled? */ 499 if (cbImpl->Signalled()) 500 break; 501 502 /* Figure out how much we have left to wait and if we've timed out already. */ 503 uint32_t cMsLeft; 504 if (cMsTimeout == RT_INDEFINITE_WAIT) 505 cMsLeft = RT_INDEFINITE_WAIT; 506 else 507 { 508 uint64_t cMsElapsed = RTTimeMilliTS() - StartMsTS; 509 if (cMsElapsed >= cMsTimeout) 510 break; /* timeout */ 511 cMsLeft = cMsTimeout - (uint32_t)cMsElapsed; 512 } 513 514 /* Wait in a platform specific manner. */ 515 #define POLL_MS_INTERVAL 1000 516 #ifdef USE_XPCOM_QUEUE 517 fd_set fdset; 518 FD_ZERO(&fdset); 519 FD_SET(fdQueue, &fdset); 520 struct timeval tv; 521 if ( cMsLeft == RT_INDEFINITE_WAIT 522 || cMsLeft >= POLL_MS_INTERVAL) 523 { 524 tv.tv_sec = POLL_MS_INTERVAL / 1000; 525 tv.tv_usec = 0; 526 } 527 else 528 { 529 tv.tv_sec = 0; 530 tv.tv_usec = cMsLeft * 1000; 531 } 532 int prc = select(fdQueue + 1, &fdset, NULL, NULL, &tv); 533 if (prc == -1) 534 { 535 RTPrintf("Error waiting for event: %s (%d)\n", strerror(errno), errno); 536 break; 537 } 538 539 #elif defined(RT_OS_DARWIN) 540 CFTimeInterval rdTimeout = (double)RT_MIN(cMsLeft, POLL_MS_INTERVAL) / 1000; 541 OSStatus orc = CFRunLoopRunInMode(kCFRunLoopDefaultMode, rdTimeout, true /*returnAfterSourceHandled*/); 542 if (orc == kCFRunLoopRunHandledSource) 543 orc = CFRunLoopRunInMode(kCFRunLoopDefaultMode, 0.0, false /*returnAfterSourceHandled*/); 544 if ( orc != 0 545 && orc != kCFRunLoopRunHandledSource 546 && orc != kCFRunLoopRunTimedOut) 547 { 548 RTPrintf("Error waiting for event: %d\n", orc); 549 break; 550 } 551 552 #else /* !USE_XPCOM_QUEUE */ 553 int vrc = cbImpl->wait(RT_MIN(cMsLeft, POLL_MS_INTERVAL)); 554 if ( vrc != VERR_TIMEOUT 555 && RT_FAILURE(vrc)) 556 { 557 RTPrintf("Error waiting for event: %Rrc\n", vrc); 558 break; 559 } 560 #endif /* !USE_XPCOM_QUEUE */ 561 } /* for (;;) */ 562 563 /* 564 * Clean up the callback and report timeout. 565 */ 502 int vrc = com::EventQueue::processThreadEventQueue(cMsTimeout, eventExitCheck, (void *)cbImpl, 503 1000 /*cMsPollInterval*/, false /*fReturnOnEvent*/); 504 if ( RT_FAILURE(vrc) 505 && vrc != VERR_CALLBACK_RETURN 506 && vrc != VERR_TIMEOUT) 507 { 508 RTPrintf("Error waiting for event: %Rrc\n", vrc); 509 return 1; 510 } 511 566 512 a->virtualBox->UnregisterCallback(callback); 567 513
Note:
See TracChangeset
for help on using the changeset viewer.