Commit a988bc05f363060ad9e9049219d37f44371dc36f

Authored by Benjamin Renard
1 parent ed267e8d

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 530 Cache_UnlockVI(D->InstrName);
531 531 if(Verbose)
532 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 547 //Retry
534 548 //sleep(2);
535 549 return Cache_RequestDataFileAccess(D, dataFileName);
... ...
src/SERVER/DD_Server.c
... ... @@ -421,6 +421,13 @@ void Serv(int SocketID)
421 421 /* Get request from client */
422 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 431 err = 0;
425 432  
426 433 /* Decode Request */
... ... @@ -434,6 +441,11 @@ void Serv(int SocketID)
434 441  
435 442 xdrmem_create(&xdrs, ReqBuf,REQUESTLENGTH , XDR_FREE);
436 443 while((cc = recv(SocketID,ReqBuf,REQUESTLENGTH,0)) < 0); /* Receive identification packet */
  444 + if (cc == 0)
  445 + {
  446 + err = REQSENDERR;
  447 + break;
  448 + }
437 449 xdrmem_create(&xdrs, ReqBuf,REQUESTLENGTH, XDR_DECODE);
438 450 xdr_int(&xdrs,&uid);
439 451 xdr_string(&xdrs,&ReqHost,MAXHOSTLENGTH);
... ... @@ -485,6 +497,11 @@ void Serv(int SocketID)
485 497 if(VarBuffer != NULL) free(VarBuffer);
486 498 VarBuffer = (char *)malloc(sizeof(char)*PacketSize);
487 499 while((cc = recv(SocketID,VarBuffer,PacketSize,0)) < 0);
  500 + if (cc == 0)
  501 + {
  502 + err = REQSENDERR;
  503 + break;
  504 + }
488 505 xdrmem_create(&xdrs, VarBuffer,PacketSize, XDR_DECODE);
489 506 xdr_int(&xdrs,&VarSize);
490 507 VarNames = (char **)malloc(sizeof(char *) * VarSize);
... ... @@ -506,6 +523,11 @@ void Serv(int SocketID)
506 523 case GETTICKETREQ:
507 524 xdrmem_create(&xdrs, ReqBuf,REQUESTLENGTH , XDR_FREE);
508 525 while((cc = recv(SocketID,ReqBuf,REQUESTLENGTH,0)) < 0);
  526 + if (cc == 0)
  527 + {
  528 + err = REQSENDERR;
  529 + break;
  530 + }
509 531 xdrmem_create(&xdrs, ReqBuf, REQUESTLENGTH, XDR_DECODE);
510 532  
511 533 xdr_int(&xdrs,&uid);
... ...