Changeset 85566 in vbox for trunk/src/VBox/Additions
- Timestamp:
- Jul 30, 2020 4:44:19 PM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/x11/VBoxClient/draganddrop.cpp
r85498 r85566 642 642 , m_hEventSem(NIL_RTSEMEVENT) 643 643 , m_pCurDnD(NULL) 644 , m_fSrvStopping(false) 645 {} 644 , m_fStop(false) 645 { 646 RT_ZERO(m_dndCtx); 647 } 646 648 647 649 int init(void); … … 665 667 RTTHREAD m_hHGCMThread; 666 668 RTTHREAD m_hX11Thread; 669 /** This service' DnD command context. */ 670 VBGLR3GUESTDNDCMDCTX m_dndCtx; 667 671 RTSEMEVENT m_hEventSem; 668 672 DragInstance *m_pCurDnD; 669 bool m_fSrvStopping; 673 /** Stop indicator flag to signal the thread that it should shut down. */ 674 bool m_fStop; 670 675 671 676 friend class DragInstance; … … 3045 3050 { 3046 3051 rc = RTSemEventCreate(&m_hEventSem); 3047 if (RT_FAILURE(rc)) 3048 break; 3052 AssertRCBreak(rc); 3049 3053 3050 3054 rc = RTCritSectInit(&m_eventQueueCS); 3051 if (RT_FAILURE(rc)) 3052 break; 3055 AssertRCBreak(rc); 3056 3057 rc = VbglR3DnDConnect(&m_dndCtx); 3058 AssertRCBreak(rc); 3053 3059 3054 3060 /* Event thread for events coming from the HGCM device. */ 3055 3061 rc = RTThreadCreate(&m_hHGCMThread, hgcmEventThread, this, 3056 3062 0, RTTHREADTYPE_MSG_PUMP, RTTHREADFLAGS_WAITABLE, "dndHGCM"); 3057 if (RT_FAILURE(rc)) 3058 break; 3063 AssertRCBreak(rc); 3059 3064 3060 3065 rc = RTThreadUserWait(m_hHGCMThread, 10 * 1000 /* 10s timeout */); 3061 if (RT_FAILURE(rc)) 3062 break; 3063 3064 if (ASMAtomicReadBool(&m_fSrvStopping)) 3066 AssertRCBreak(rc); 3067 3068 if (ASMAtomicReadBool(&m_fStop)) 3065 3069 break; 3066 3070 … … 3068 3072 rc = RTThreadCreate(&m_hX11Thread, x11EventThread, this, 3069 3073 0, RTTHREADTYPE_MSG_PUMP, RTTHREADFLAGS_WAITABLE, "dndX11"); 3070 if (RT_FAILURE(rc)) 3071 break; 3074 AssertRCBreak(rc); 3072 3075 3073 3076 rc = RTThreadUserWait(m_hX11Thread, 10 * 1000 /* 10s timeout */); 3074 if (RT_FAILURE(rc)) 3075 break; 3076 3077 if (ASMAtomicReadBool(&m_fSrvStopping)) 3077 AssertRCBreak(rc); 3078 3079 if (ASMAtomicReadBool(&m_fStop)) 3078 3080 break; 3079 3081 3080 3082 } while (0); 3081 3083 3082 if (m_fS rvStopping)3084 if (m_fStop) 3083 3085 rc = VERR_GENERAL_FAILURE; /** @todo Fudge! */ 3084 3086 … … 3272 3274 XFlush(m_pDisplay); 3273 3275 3274 } while (!ASMAtomicReadBool(&m_fS rvStopping));3276 } while (!ASMAtomicReadBool(&m_fStop)); 3275 3277 3276 3278 VBClLogInfo("Stopped with rc=%Rrc\n", rc); … … 3292 3294 LogFlowFuncEnter(); 3293 3295 3294 VBClLogInfo("Terminating threads ...\n"); 3295 3296 ASMAtomicXchgBool(&m_fSrvStopping, true); 3296 VBClLogInfo("Terminating ...\n"); 3297 3298 /* Set stop flag first. */ 3299 ASMAtomicXchgBool(&m_fStop, true); 3300 3301 /* Disconnect from the HGCM host service, which in turn will make the HGCM thread stop. */ 3302 VbglR3DnDDisconnect(&m_dndCtx); 3297 3303 3298 3304 /* … … 3302 3308 if (m_hHGCMThread != NIL_RTTHREAD) 3303 3309 { 3304 #if 0 /** @todo Does not work because we don't cancel the HGCM call! */ 3310 VBClLogInfo("Terminating HGCM thread ...\n"); 3311 3305 3312 rc2 = RTThreadWait(m_hHGCMThread, 30 * 1000 /* 30s timeout */, &rcThread); 3306 #else3307 rc2 = RTThreadWait(m_hHGCMThread, 200 /* 200ms timeout */, &rcThread);3308 #endif3309 3313 if (RT_SUCCESS(rc2)) 3310 3314 rc2 = rcThread; … … 3316 3320 if (m_hX11Thread != NIL_RTTHREAD) 3317 3321 { 3318 #if 0 3319 rc2 = RTThreadWait(m_hX11Thread, 30 * 1000 /* 30s timeout */, &rcThread); 3320 #else 3322 VBClLogInfo("Terminating X11 thread ...\n"); 3323 3321 3324 rc2 = RTThreadWait(m_hX11Thread, 200 /* 200ms timeout */, &rcThread); 3322 #endif3323 3325 if (RT_SUCCESS(rc2)) 3324 3326 rc2 = rcThread; … … 3349 3351 AssertPtrReturn(pvUser, VERR_INVALID_PARAMETER); 3350 3352 DragAndDropService *pThis = static_cast<DragAndDropService*>(pvUser); 3351 AssertPtr(pThis);3352 3353 /* This thread has an own DnD context, e.g. an own client ID. */3354 VBGLR3GUESTDNDCMDCTX dndCtx;3355 3356 /*3357 * Initialize thread.3358 */3359 int rc = VbglR3DnDConnect(&dndCtx);3360 3361 /* Set stop indicator on failure. */3362 if (RT_FAILURE(rc))3363 ASMAtomicXchgBool(&pThis->m_fSrvStopping, true);3364 3353 3365 3354 /* Let the service instance know in any case. */ 3366 int rc2 = RTThreadUserSignal(hThread); 3367 AssertRC(rc2); 3368 3369 if (RT_FAILURE(rc)) 3370 return rc; 3355 int rc = RTThreadUserSignal(hThread); 3356 AssertRCReturn(rc, rc); 3371 3357 3372 3358 /* Number of invalid messages skipped in a row. */ … … 3380 3366 3381 3367 /* Wait for new events. */ 3382 rc = VbglR3DnDEventGetNext(& dndCtx, &e.hgcm);3368 rc = VbglR3DnDEventGetNext(&pThis->m_dndCtx, &e.hgcm); 3383 3369 if (RT_SUCCESS(rc)) 3384 3370 { … … 3392 3378 else 3393 3379 { 3394 VBClLogError("Processing next message failed with rc=%Rrc\n", rc); 3395 3396 /* Old(er) hosts either are broken regarding DnD support or otherwise 3397 * don't support the stuff we do on the guest side, so make sure we 3398 * don't process invalid messages forever. */ 3399 if (cMsgSkippedInvalid++ > 32) 3380 if (rc == VERR_INTERRUPTED) /* Can happen due to disconnect, for instance. */ 3381 rc = VINF_SUCCESS; 3382 3383 if (RT_FAILURE(rc)) 3400 3384 { 3401 VBClLogError("Too many invalid/skipped messages from host, exiting ...\n"); 3402 break; 3385 VBClLogError("Processing next message failed with rc=%Rrc\n", rc); 3386 3387 /* Old(er) hosts either are broken regarding DnD support or otherwise 3388 * don't support the stuff we do on the guest side, so make sure we 3389 * don't process invalid messages forever. */ 3390 3391 if (cMsgSkippedInvalid++ > 32) 3392 { 3393 VBClLogError("Too many invalid/skipped messages from host, exiting ...\n"); 3394 break; 3395 } 3403 3396 } 3404 3397 } 3405 3398 3406 } while (!ASMAtomicReadBool(&pThis->m_fSrvStopping)); 3407 3408 VbglR3DnDDisconnect(&dndCtx); 3399 } while (!ASMAtomicReadBool(&pThis->m_fStop)); 3409 3400 3410 3401 LogFlowFuncLeaveRC(rc); … … 3433 3424 /* Set stop indicator on failure. */ 3434 3425 if (RT_FAILURE(rc)) 3435 ASMAtomicXchgBool(&pThis->m_fS rvStopping, true);3426 ASMAtomicXchgBool(&pThis->m_fStop, true); 3436 3427 3437 3428 /* Let the service instance know in any case. */ … … 3485 3476 RTThreadSleep(25 /* ms */); 3486 3477 3487 } while (!ASMAtomicReadBool(&pThis->m_fS rvStopping));3478 } while (!ASMAtomicReadBool(&pThis->m_fStop)); 3488 3479 3489 3480 LogFlowFuncLeaveRC(rc);
Note:
See TracChangeset
for help on using the changeset viewer.