Changeset 89947 in vbox
- Timestamp:
- Jun 29, 2021 10:42:28 AM (4 years ago)
- svn:sync-xref-src-repo-rev:
- 145405
- Location:
- trunk
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/VBox/GuestHost/SharedClipboard-x11.h
r87566 r89947 38 38 # include <VBox/GuestHost/SharedClipboard-transfers.h> 39 39 #endif 40 41 /** 42 * The maximum number of simultaneous connections to shared clipboard service. 43 * This constant limits amount of GUEST -> HOST connections to shared clipboard host service 44 * for X11 host only. Once amount of connections reaches this number, all the 45 * further attempts to CONNECT will be dropped on an early stage. Possibility to connect 46 * is available again after one of existing connections is closed by DISCONNECT call. 47 */ 48 #define VBOX_SHARED_CLIPBOARD_X11_CONNECTIONS_MAX (20) 40 49 41 50 /** Enables the Xt busy / update handling. */ -
trunk/src/VBox/GuestHost/SharedClipboard/clipboard-x11.cpp
r87566 r89947 279 279 280 280 /** 281 * The number of simultaneous instances we support. For all normal purposes282 * we should never need more than one. For the testcase it is convenient to283 * have a second instance that the first can interact with in order to have284 * a more controlled environment.285 */286 enum { CLIP_MAX_CONTEXTS = 20 };287 288 /**289 281 * Array of structures for mapping Xt widgets to context pointers. We 290 282 * need this because the widget clipboard callbacks do not pass user data. … … 296 288 /** Pointer to X11 context associated with the widget. */ 297 289 PSHCLX11CTX pCtx; 298 } g_aContexts[ CLIP_MAX_CONTEXTS];290 } g_aContexts[VBOX_SHARED_CLIPBOARD_X11_CONNECTIONS_MAX]; 299 291 300 292 /** … … 407 399 408 400 #ifndef TESTCASE 401 AssertReturn(pCtx, VERR_INVALID_POINTER); 402 AssertReturn(pCtx->pAppContext, VERR_INVALID_POINTER); 403 409 404 XtAppAddTimeOut(pCtx->pAppContext, 0, (XtTimerCallbackProc)proc, 410 405 (XtPointer)client_data); … … 884 879 } 885 880 881 LogRel(("Shared Clipboard: X11 event thread exiting\n")); 882 886 883 clipUnregisterContext(pCtx); 884 } 885 else 886 { 887 LogRel(("Shared Clipboard: unable to register clip context: %Rrc\n", rc)); 887 888 } 888 889 … … 1293 1294 int ShClX11ThreadStop(PSHCLX11CTX pCtx) 1294 1295 { 1296 int rc; 1295 1297 /* 1296 1298 * Immediately return if we are not connected to the X server. … … 1302 1304 1303 1305 /* Write to the "stop" pipe. */ 1304 clipThreadScheduleCall(pCtx, clipThreadSignalStop, (XtPointer)pCtx); 1306 rc = clipThreadScheduleCall(pCtx, clipThreadSignalStop, (XtPointer)pCtx); 1307 if (RT_FAILURE(rc)) 1308 { 1309 LogRel(("Shared Clipboard: cannot notify X11 event thread on shutdown with %Rrc\n", rc)); 1310 return rc; 1311 } 1305 1312 1306 1313 LogRel2(("Shared Clipboard: Waiting for X11 event thread to stop ...\n")); 1307 1314 1308 1315 int rcThread; 1309 intrc = RTThreadWait(pCtx->Thread, RT_MS_30SEC /* msTimeout */, &rcThread);1316 rc = RTThreadWait(pCtx->Thread, RT_MS_30SEC /* msTimeout */, &rcThread); 1310 1317 if (RT_SUCCESS(rc)) 1311 1318 rc = rcThread; … … 1870 1877 rc = clipThreadScheduleCall(pCtx, ShClX11ReportFormatsToX11Worker, 1871 1878 (XtPointer)pFormats); 1879 if (RT_FAILURE(rc)) 1880 RTMemFree(pFormats); 1872 1881 } 1873 1882 else … … 2274 2283 /* We use this to schedule a worker function on the event thread. */ 2275 2284 rc = clipThreadScheduleCall(pCtx, ShClX11ReadDataFromX11Worker, (XtPointer)pX11Req); 2285 if (RT_FAILURE(rc)) 2286 RTMemFree(pX11Req); 2276 2287 } 2277 2288 else -
trunk/src/VBox/HostServices/SharedClipboard/VBoxSharedClipboardSvc-x11.cpp
r87686 r89947 27 27 #include <iprt/semaphore.h> 28 28 #include <iprt/string.h> 29 #include <iprt/asm.h> 29 30 30 31 #include <VBox/GuestHost/SharedClipboard.h> … … 35 36 #include "VBoxSharedClipboardSvc-internal.h" 36 37 38 /* Number of currently extablished connections. */ 39 static volatile uint32_t g_cShClConnections; 37 40 38 41 /********************************************************************************************************************************* … … 76 79 int rc; 77 80 81 /* Check if maximum allowed connections count has reached. */ 82 if (ASMAtomicIncU32(&g_cShClConnections) > VBOX_SHARED_CLIPBOARD_X11_CONNECTIONS_MAX) 83 { 84 ASMAtomicDecU32(&g_cShClConnections); 85 LogRel(("Shared Clipboard: maximum amount for client connections reached\n")); 86 return VERR_OUT_OF_RESOURCES; 87 } 88 78 89 PSHCLCONTEXT pCtx = (PSHCLCONTEXT)RTMemAllocZ(sizeof(SHCLCONTEXT)); 79 90 if (pCtx) … … 96 107 RTCritSectDelete(&pCtx->CritSect); 97 108 } 98 else 109 110 if (RT_FAILURE(rc)) 111 { 112 pClient->State.pCtx = NULL; 99 113 RTMemFree(pCtx); 114 } 100 115 } 101 116 else 102 117 rc = VERR_NO_MEMORY; 118 119 if (RT_FAILURE(rc)) 120 { 121 /* Restore active connections count. */ 122 ASMAtomicDecU32(&g_cShClConnections); 123 } 103 124 104 125 LogFlowFuncLeaveRC(rc); … … 141 162 142 163 RTMemFree(pCtx); 164 165 /* Decrease active connections count. */ 166 ASMAtomicDecU32(&g_cShClConnections); 143 167 144 168 LogFlowFuncLeaveRC(rc); … … 253 277 LogFlowFunc(("pCtx=%p, fFormats=%#x\n", pCtx, fFormats)); 254 278 279 int rc = VINF_SUCCESS; 255 280 PSHCLCLIENT pClient = pCtx->pClient; 256 281 AssertPtr(pClient); 257 282 258 RTCritSectEnter(&pClient->CritSect); 259 260 /** @todo r=bird: BUGBUG: Revisit this */ 261 if (fFormats == VBOX_SHCL_FMT_NONE) /* No formats to report? Bail out early. */ 262 return; 263 264 int rc = ShClSvcHostReportFormats(pCtx->pClient, fFormats); 265 RT_NOREF(rc); 266 267 RTCritSectLeave(&pClient->CritSect); 283 rc = RTCritSectEnter(&pClient->CritSect); 284 if (RT_SUCCESS(rc)) 285 { 286 /** @todo r=bird: BUGBUG: Revisit this */ 287 if (fFormats != VBOX_SHCL_FMT_NONE) /* No formats to report? */ 288 { 289 rc = ShClSvcHostReportFormats(pCtx->pClient, fFormats); 290 } 291 292 RTCritSectLeave(&pClient->CritSect); 293 } 268 294 269 295 LogFlowFuncLeaveRC(rc); -
trunk/src/VBox/HostServices/SharedClipboard/VBoxSharedClipboardSvc.cpp
r89555 r89947 1995 1995 if (RT_SUCCESS(rc)) 1996 1996 { 1997 /* Assign weak pointer to client map .*/ 1998 g_mapClients[u32ClientID] = pClient; /** @todo Handle OOM / collisions? */ 1999 1997 2000 rc = ShClBackendConnect(pClient, ShClSvcGetHeadless()); 1998 2001 if (RT_SUCCESS(rc)) … … 2014 2017 if (RT_SUCCESS(rc)) 2015 2018 { 2016 /* Assign weak pointer to client map .*/2017 g_mapClients[u32ClientID] = pClient; /** @todo Handle OOM / collisions? */2018 2019 2019 /* For now we ASSUME that the first client ever connected is in charge for 2020 2020 * communicating withe the service extension. … … 2025 2025 } 2026 2026 } 2027 2028 if (RT_FAILURE(rc)) 2029 { 2030 shClSvcClientDestroy(pClient); 2031 } 2032 2027 2033 } 2028 2034
Note:
See TracChangeset
for help on using the changeset viewer.