Commit a988bc05f363060ad9e9049219d37f44371dc36f
1 parent
ed267e8d
Exists in
master
and in
10 other branches
Fix a bug in the cache manager + Detect when the socket is died and exit the child properly
Showing
2 changed files
with
36 additions
and
0 deletions
Show diff stats
src/SERVER/DD_Cache.c
@@ -530,6 +530,20 @@ int Cache_RequestDataFileAccess(DD_Var_t *D, char* dataFileName) | @@ -530,6 +530,20 @@ int Cache_RequestDataFileAccess(DD_Var_t *D, char* dataFileName) | ||
530 | Cache_UnlockVI(D->InstrName); | 530 | Cache_UnlockVI(D->InstrName); |
531 | if(Verbose) | 531 | if(Verbose) |
532 | fprintf(stderr,"Cache_RequestDataFileAccess. Not available slot to open data file %s.\n", dataFileName); | 532 | fprintf(stderr,"Cache_RequestDataFileAccess. Not available slot to open data file %s.\n", dataFileName); |
533 | + //Update process lists for all slots | ||
534 | + for (i = 0; i < CASHLEN; ++i) | ||
535 | + { | ||
536 | + cache_data->VIFiles[cacheVIIndex].dataFiles[i].state = CACHE_NOTUSED; | ||
537 | + for (j = 0; j < CACHE_MAXCLIENT; ++j) | ||
538 | + { | ||
539 | + if (cache_data->VIFiles[cacheVIIndex].dataFiles[i].clientPIDS[j] == 0) | ||
540 | + continue; | ||
541 | + if (Cache_PIDIsRunning(cache_data->VIFiles[cacheVIIndex].dataFiles[i].clientPIDS[j]) == 0) | ||
542 | + cache_data->VIFiles[cacheVIIndex].dataFiles[i].clientPIDS[j] = 0; | ||
543 | + else | ||
544 | + cache_data->VIFiles[cacheVIIndex].dataFiles[i].state = CACHE_USED; | ||
545 | + } | ||
546 | + } | ||
533 | //Retry | 547 | //Retry |
534 | //sleep(2); | 548 | //sleep(2); |
535 | return Cache_RequestDataFileAccess(D, dataFileName); | 549 | return Cache_RequestDataFileAccess(D, dataFileName); |
src/SERVER/DD_Server.c
@@ -421,6 +421,13 @@ void Serv(int SocketID) | @@ -421,6 +421,13 @@ void Serv(int SocketID) | ||
421 | /* Get request from client */ | 421 | /* Get request from client */ |
422 | while((cc = recv(SocketID,ReqBuf,REQUESTLENGTH,0)) < 0); | 422 | while((cc = recv(SocketID,ReqBuf,REQUESTLENGTH,0)) < 0); |
423 | 423 | ||
424 | + if (cc == 0) | ||
425 | + { | ||
426 | + err = REQSENDERR; | ||
427 | + GoOut = 1; | ||
428 | + break; | ||
429 | + } | ||
430 | + | ||
424 | err = 0; | 431 | err = 0; |
425 | 432 | ||
426 | /* Decode Request */ | 433 | /* Decode Request */ |
@@ -434,6 +441,11 @@ void Serv(int SocketID) | @@ -434,6 +441,11 @@ void Serv(int SocketID) | ||
434 | 441 | ||
435 | xdrmem_create(&xdrs, ReqBuf,REQUESTLENGTH , XDR_FREE); | 442 | xdrmem_create(&xdrs, ReqBuf,REQUESTLENGTH , XDR_FREE); |
436 | while((cc = recv(SocketID,ReqBuf,REQUESTLENGTH,0)) < 0); /* Receive identification packet */ | 443 | while((cc = recv(SocketID,ReqBuf,REQUESTLENGTH,0)) < 0); /* Receive identification packet */ |
444 | + if (cc == 0) | ||
445 | + { | ||
446 | + err = REQSENDERR; | ||
447 | + break; | ||
448 | + } | ||
437 | xdrmem_create(&xdrs, ReqBuf,REQUESTLENGTH, XDR_DECODE); | 449 | xdrmem_create(&xdrs, ReqBuf,REQUESTLENGTH, XDR_DECODE); |
438 | xdr_int(&xdrs,&uid); | 450 | xdr_int(&xdrs,&uid); |
439 | xdr_string(&xdrs,&ReqHost,MAXHOSTLENGTH); | 451 | xdr_string(&xdrs,&ReqHost,MAXHOSTLENGTH); |
@@ -485,6 +497,11 @@ void Serv(int SocketID) | @@ -485,6 +497,11 @@ void Serv(int SocketID) | ||
485 | if(VarBuffer != NULL) free(VarBuffer); | 497 | if(VarBuffer != NULL) free(VarBuffer); |
486 | VarBuffer = (char *)malloc(sizeof(char)*PacketSize); | 498 | VarBuffer = (char *)malloc(sizeof(char)*PacketSize); |
487 | while((cc = recv(SocketID,VarBuffer,PacketSize,0)) < 0); | 499 | while((cc = recv(SocketID,VarBuffer,PacketSize,0)) < 0); |
500 | + if (cc == 0) | ||
501 | + { | ||
502 | + err = REQSENDERR; | ||
503 | + break; | ||
504 | + } | ||
488 | xdrmem_create(&xdrs, VarBuffer,PacketSize, XDR_DECODE); | 505 | xdrmem_create(&xdrs, VarBuffer,PacketSize, XDR_DECODE); |
489 | xdr_int(&xdrs,&VarSize); | 506 | xdr_int(&xdrs,&VarSize); |
490 | VarNames = (char **)malloc(sizeof(char *) * VarSize); | 507 | VarNames = (char **)malloc(sizeof(char *) * VarSize); |
@@ -506,6 +523,11 @@ void Serv(int SocketID) | @@ -506,6 +523,11 @@ void Serv(int SocketID) | ||
506 | case GETTICKETREQ: | 523 | case GETTICKETREQ: |
507 | xdrmem_create(&xdrs, ReqBuf,REQUESTLENGTH , XDR_FREE); | 524 | xdrmem_create(&xdrs, ReqBuf,REQUESTLENGTH , XDR_FREE); |
508 | while((cc = recv(SocketID,ReqBuf,REQUESTLENGTH,0)) < 0); | 525 | while((cc = recv(SocketID,ReqBuf,REQUESTLENGTH,0)) < 0); |
526 | + if (cc == 0) | ||
527 | + { | ||
528 | + err = REQSENDERR; | ||
529 | + break; | ||
530 | + } | ||
509 | xdrmem_create(&xdrs, ReqBuf, REQUESTLENGTH, XDR_DECODE); | 531 | xdrmem_create(&xdrs, ReqBuf, REQUESTLENGTH, XDR_DECODE); |
510 | 532 | ||
511 | xdr_int(&xdrs,&uid); | 533 | xdr_int(&xdrs,&uid); |