Changeset 50817 in vbox for trunk/src/VBox/HostServices/SharedOpenGL/crserverlib
- Timestamp:
- Mar 19, 2014 10:29:48 AM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_main.c
r50815 r50817 62 62 static DECLCALLBACK(int) crVBoxCrCmdCmd(HVBOXCRCMDSVR hSvr, PVBOXCMDVBVA_HDR pCmd, uint32_t cbCmd); 63 63 64 DECLINLINE(CRClient*) crVBoxServerClientById(uint32_t u32ClientID) 65 { 66 int32_t i; 67 68 if (cr_server.fCrCmdEnabled) 69 return CrHTableGet(&cr_server.clientTable, u32ClientID); 70 71 for (i = 0; i < cr_server.numClients; i++) 72 { 73 if (cr_server.clients[i] && cr_server.clients[i]->conn 74 && cr_server.clients[i]->conn->u32ClientID==u32ClientID) 75 { 76 return cr_server.clients[i]; 77 } 78 } 79 80 return NULL; 81 } 82 64 83 DECLINLINE(int32_t) crVBoxServerClientGet(uint32_t u32ClientID, CRClient **ppClient) 65 84 { … … 67 86 int32_t i; 68 87 69 *ppClient = NULL; 70 71 for (i = 0; i < cr_server.numClients; i++) 72 { 73 if (cr_server.clients[i] && cr_server.clients[i]->conn 74 && cr_server.clients[i]->conn->u32ClientID==u32ClientID) 75 { 76 pClient = cr_server.clients[i]; 77 break; 78 } 79 } 88 pClient = crVBoxServerClientById(u32ClientID); 89 80 90 if (!pClient) 81 91 { 82 crWarning("client not found!"); 92 WARN(("client not found!")); 93 *ppClient = NULL; 83 94 return VERR_INVALID_PARAMETER; 84 95 } … … 86 97 if (!pClient->conn->vMajor) 87 98 { 88 crWarning("no major version specified for client!"); 99 WARN(("no major version specified for client!")); 100 *ppClient = NULL; 89 101 return VERR_NOT_SUPPORTED; 90 102 } … … 337 349 #endif 338 350 351 cr_server.fCrCmdEnabled = GL_FALSE; 352 CrHTableCreate(&cr_server.clientTable, CR_MAX_CLIENTS); 353 339 354 cr_server.bUseMultipleContexts = (crGetenv( "CR_SERVER_ENABLE_MULTIPLE_CONTEXTS" ) != NULL); 340 355 … … 441 456 #endif 442 457 458 cr_server.fCrCmdEnabled = GL_FALSE; 459 CrHTableCreate(&cr_server.clientTable, CR_MAX_CLIENTS); 460 443 461 cr_server.bUseMultipleContexts = (crGetenv( "CR_SERVER_ENABLE_MULTIPLE_CONTEXTS" ) != NULL); 444 462 … … 591 609 } 592 610 593 void crVBoxServerRemoveClient(uint32_t u32ClientID) 594 { 595 CRClient *pClient=NULL; 596 int32_t i; 597 598 crDebug("crServer: RemoveClient u32ClientID=%d", u32ClientID); 599 600 for (i = 0; i < cr_server.numClients; i++) 601 { 602 if (cr_server.clients[i] && cr_server.clients[i]->conn 603 && cr_server.clients[i]->conn->u32ClientID==u32ClientID) 604 { 605 pClient = cr_server.clients[i]; 606 break; 607 } 608 } 609 //if (!pClient) return VERR_INVALID_PARAMETER; 610 if (!pClient) 611 { 612 crWarning("Invalid client id %u passed to crVBoxServerRemoveClient", u32ClientID); 613 return; 614 } 615 611 static void crVBoxServerRemoveClientObj(CRClient *pClient) 612 { 616 613 #ifdef VBOX_WITH_CRHGSMI 617 614 CRVBOXHGSMI_CMDDATA_ASSERT_CLEANED(&pClient->conn->CmdData); … … 623 620 /* Let server clear client from the queue */ 624 621 crServerDeleteClient(pClient); 622 } 623 624 static void crVBoxServerRemoveAllClients() 625 { 626 int32_t i; 627 for (i = cr_server.numClients - 1; i >= 0; --i) 628 { 629 Assert(cr_server.clients[i]); 630 crVBoxServerRemoveClientObj(cr_server.clients[i]); 631 } 632 } 633 634 void crVBoxServerRemoveClient(uint32_t u32ClientID) 635 { 636 CRClient *pClient=NULL; 637 int32_t i; 638 639 crDebug("crServer: RemoveClient u32ClientID=%d", u32ClientID); 640 641 for (i = 0; i < cr_server.numClients; i++) 642 { 643 if (cr_server.clients[i] && cr_server.clients[i]->conn 644 && cr_server.clients[i]->conn->u32ClientID==u32ClientID) 645 { 646 pClient = cr_server.clients[i]; 647 break; 648 } 649 } 650 //if (!pClient) return VERR_INVALID_PARAMETER; 651 if (!pClient) 652 { 653 WARN(("Invalid client id %u passed to crVBoxServerRemoveClient", u32ClientID)); 654 return; 655 } 656 657 crVBoxServerRemoveClientObj(pClient); 625 658 } 626 659 … … 3263 3296 static DECLCALLBACK(int) crVBoxCrCmdEnable(HVBOXCRCMDSVR hSvr, VBOXCRCMD_SVRENABLE_INFO *pInfo) 3264 3297 { 3298 Assert(!cr_server.fCrCmdEnabled); 3299 Assert(!cr_server.numClients); 3300 3265 3301 cr_server.CrCmdClientInfo = *pInfo; 3266 3302 3267 3303 crVBoxServerDefaultContextSet(); 3268 3304 3305 cr_server.fCrCmdEnabled = GL_TRUE; 3306 3269 3307 return VINF_SUCCESS; 3270 3308 } … … 3272 3310 static DECLCALLBACK(int) crVBoxCrCmdDisable(HVBOXCRCMDSVR hSvr) 3273 3311 { 3312 Assert(cr_server.fCrCmdEnabled); 3313 3314 crVBoxServerRemoveAllClients(); 3315 3316 CrHTableEmpty(&cr_server.clientTable); 3317 3274 3318 cr_server.head_spu->dispatch_table.MakeCurrent(0, 0, 0); 3275 3319 3276 3320 memset(&cr_server.CrCmdClientInfo, 0, sizeof (cr_server.CrCmdClientInfo)); 3277 3321 3322 cr_server.fCrCmdEnabled = GL_FALSE; 3323 3278 3324 return VINF_SUCCESS; 3279 3325 } … … 3282 3328 { 3283 3329 return crVBoxServerHostCtl((VBOXCRCMDCTL*)pCmd, cbCmd); 3330 } 3331 3332 static int crVBoxCrDisconnect(uint32_t u32Client) 3333 { 3334 CRClient *pClient = (CRClient*)CrHTableRemove(&cr_server.clientTable, u32Client); 3335 if (!pClient) 3336 { 3337 WARN(("invalid client id")); 3338 return VERR_INVALID_PARAMETER; 3339 } 3340 3341 crVBoxServerRemoveClientObj(pClient); 3342 3343 return VINF_SUCCESS; 3344 } 3345 3346 static int crVBoxCrConnect(VBOXCMDVBVA_3DCTL_CONNECT *pConnect) 3347 { 3348 CRClient *pClient; 3349 int rc; 3350 /* allocate client id */ 3351 uint32_t u32ClientId = CrHTablePut(&cr_server.clientTable, (void*)1); 3352 if (u32ClientId != CRHTABLE_HANDLE_INVALID) 3353 { 3354 rc = crVBoxServerAddClientObj(u32ClientId, &pClient); 3355 if (RT_SUCCESS(rc)) 3356 { 3357 rc = CrHTablePutToSlot(&cr_server.clientTable, u32ClientId, pClient); 3358 if (RT_SUCCESS(rc)) 3359 return VINF_SUCCESS; 3360 else 3361 WARN(("CrHTablePutToSlot failed %d", rc)); 3362 3363 crVBoxServerRemoveClientObj(pClient); 3364 } 3365 else 3366 WARN(("crVBoxServerAddClientObj failed %d", rc)); 3367 3368 CrHTableRemove(&cr_server.clientTable, u32ClientId); 3369 } 3370 else 3371 { 3372 WARN(("CrHTablePut failed")); 3373 rc = VERR_NO_MEMORY; 3374 } 3375 3376 return rc; 3284 3377 } 3285 3378 … … 3297 3390 case VBOXCMDVBVA3DCTL_TYPE_CONNECT: 3298 3391 { 3299 VBOXCMDVBVA_3DCTL_CONNECT *pConnect = (VBOXCMDVBVA_3DCTL_CONNECT*)pCtl; 3300 3301 return VERR_NOT_SUPPORTED; 3392 if (cbCmd != sizeof (VBOXCMDVBVA_3DCTL_CONNECT)) 3393 { 3394 WARN(("invalid command size")); 3395 return VERR_INVALID_PARAMETER; 3396 } 3397 3398 return crVBoxCrConnect((VBOXCMDVBVA_3DCTL_CONNECT*)pCtl); 3302 3399 } 3303 3400 case VBOXCMDVBVA3DCTL_TYPE_DISCONNECT: 3304 3401 { 3305 return VERR_NOT_SUPPORTED; 3402 if (cbCmd != sizeof (VBOXCMDVBVA_3DCTL)) 3403 { 3404 WARN(("invalid command size")); 3405 return VERR_INVALID_PARAMETER; 3406 } 3407 3408 return crVBoxCrDisconnect(pCtl->u32CmdClientId); 3306 3409 } 3307 3410 case VBOXCMDVBVA3DCTL_TYPE_CMD: … … 3778 3881 uint32_t cbCtl; 3779 3882 3883 Assert(!cr_server.fCrCmdEnabled); 3884 3780 3885 if (cr_server.numClients) 3781 3886 { … … 3796 3901 int32_t crVBoxServerHgcmDisable() 3797 3902 { 3903 Assert(!cr_server.fCrCmdEnabled); 3904 3798 3905 if (cr_server.numClients) 3799 3906 {
Note:
See TracChangeset
for help on using the changeset viewer.