Changeset 89947 in vbox for trunk/src/VBox/HostServices/SharedClipboard
- Timestamp:
- Jun 29, 2021 10:42:28 AM (4 years ago)
- Location:
- trunk/src/VBox/HostServices/SharedClipboard
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
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.