Add a prelimary fix in SM_Heap_Lock() about new segments mapping in System Heap,

Warning: This is broken and needs debugging...
This commit is contained in:
agibert 2005-06-26 23:40:14 +00:00
parent 7fb191ce32
commit 998062740e

View File

@ -1,9 +1,9 @@
/*---------------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------------*/
/* $RCSfile: libshmem.c,v $ */ /* $RCSfile: libshmem.c,v $ */
/*---------------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------------*/
/* $Revision: 2.3 $ */ /* $Revision: 2.4 $ */
/* $Name: $ */ /* $Name: $ */
/* $Date: 2005/06/26 22:50:49 $ */ /* $Date: 2005/06/26 23:40:14 $ */
/* $Author: agibert $ */ /* $Author: agibert $ */
/*---------------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------------*/
@ -36,7 +36,7 @@
#include <libshmem.h> #include <libshmem.h>
#ifdef _LIBVER_SUPPORT #ifdef _LIBVER_SUPPORT
VER_INFO_EXPORT(libshmem,"$Revision: 2.3 $", "$Name: $",__FILE__,"$Author: agibert $") VER_INFO_EXPORT(libshmem,"$Revision: 2.4 $", "$Name: $",__FILE__,"$Author: agibert $")
#endif #endif
/*------------------------------------------------------------------------------*/ /*------------------------------------------------------------------------------*/
@ -647,10 +647,10 @@ SMT_Status SM_Heap_Open_I( const char *Heap_Name, SMT_Heap **Heap, size_t Se
} }
/*Alloc du MHH qui fait l'alloccation du premier segment de donnees*/ /*Alloc du MHH qui fait l'alloccation du premier segment de donnees*/
rc = ND_Value_Alloc(SM_Base->MHR,(void**)&MHH,Prefixed_Name,Seg_Size); rc = ND_Value_Alloc( SM_Base->MHR, (void **)&MHH, Prefixed_Name, Seg_Size);
if (rc != NDS_OK) if( rc != NDS_OK)
{ {
sprintf( SM_Error_Msg, "SM_Heap_Open : unable to to create the MHR structure"); sprintf( SM_Error_Msg, "SM_Heap_Open : unable to alloc a new MHH structure");
SM_Error_Print(); SM_Error_Print();
return(SMS_ERRAPI); return(SMS_ERRAPI);
} }
@ -930,13 +930,16 @@ SMT_Status SM_Heap_Lock_I ( SMT_Heap * Heap, SMT_Flags Lock_Mode, int * Locked )
int Nb_Detected, Nb_Corrected; int Nb_Detected, Nb_Corrected;
if (Lock_Mode == Heap->Lock_Mode) if( Lock_Mode == Heap->Lock_Mode)
{ {
/* Rien à faire : le heap est déjà verrouillé dans ce mode */ /* Rien à faire : le heap est déjà verrouillé dans ce mode */
fprintf( stderr, "Already locked !!!\n");
fflush( stderr);
*Locked = FALSE; *Locked = FALSE;
} }
else if (Heap->Lock_Mode == SMD_NO_LOCK) else if( Heap->Lock_Mode == SMD_NO_LOCK)
{ {
/* /*
Verrouillage d'un heap qui ne l'était pas : le heap ayant pu être modifié Verrouillage d'un heap qui ne l'était pas : le heap ayant pu être modifié
@ -946,7 +949,7 @@ SMT_Status SM_Heap_Lock_I ( SMT_Heap * Heap, SMT_Flags Lock_Mode, int * Locked )
/* Vérification de l'état du heap */ /* Vérification de l'état du heap */
if (Heap->MHH->State == SMD_STATE_CORRUPTED) if( Heap->MHH->State == SMD_STATE_CORRUPTED)
{ {
sprintf (SM_Error_Msg, "SM_Heap_Lock : heap \"%s\" is flagged as being corrupted", Heap->Name); sprintf (SM_Error_Msg, "SM_Heap_Lock : heap \"%s\" is flagged as being corrupted", Heap->Name);
SM_Error_Print (); SM_Error_Print ();
@ -957,7 +960,7 @@ SMT_Status SM_Heap_Lock_I ( SMT_Heap * Heap, SMT_Flags Lock_Mode, int * Locked )
/* Verrouillage du heap dans le mode demandé */ /* Verrouillage du heap dans le mode demandé */
rc = SM_Heap_Lock_Set (Heap->MHH, Lock_Mode); rc = SM_Heap_Lock_Set (Heap->MHH, Lock_Mode);
if (rc != SMS_OK) if( rc != SMS_OK)
{ {
sprintf (SM_Error_Msg, "SM_Heap_Lock : unable to lock heap \"%s\" for %s", Heap->Name, Lock_Mode & SMD_READ ? "reading" : "writing"); sprintf (SM_Error_Msg, "SM_Heap_Lock : unable to lock heap \"%s\" for %s", Heap->Name, Lock_Mode & SMD_READ ? "reading" : "writing");
SM_Error_Print (); SM_Error_Print ();
@ -967,7 +970,7 @@ SMT_Status SM_Heap_Lock_I ( SMT_Heap * Heap, SMT_Flags Lock_Mode, int * Locked )
/* Vérification de l'état du heap */ /* Vérification de l'état du heap */
if (Heap->MHH->State == SMD_STATE_UNVALIDATED) if( Heap->MHH->State == SMD_STATE_UNVALIDATED)
{ {
/* Verrouillage du heap en écriture pour le vérifier */ /* Verrouillage du heap en écriture pour le vérifier */
@ -999,7 +1002,7 @@ SMT_Status SM_Heap_Lock_I ( SMT_Heap * Heap, SMT_Flags Lock_Mode, int * Locked )
/* On reverrouille éventuellement le heap dans le mode demandé */ /* On reverrouille éventuellement le heap dans le mode demandé */
if (Lock_Mode == SMD_READ) if( Lock_Mode == SMD_READ)
{ {
rc = SM_Heap_Lock_Change (Heap->MHH, SMD_READ); rc = SM_Heap_Lock_Change (Heap->MHH, SMD_READ);
if (rc != SMS_OK) if (rc != SMS_OK)
@ -1013,6 +1016,52 @@ SMT_Status SM_Heap_Lock_I ( SMT_Heap * Heap, SMT_Flags Lock_Mode, int * Locked )
} }
} }
/* TEST !!!! */
{
NDT_Node *node_ptr = NULL;
SMT_Heap *heap_ptr;
if( SM_Heap_IsOpen_I( "system", &heap_ptr) != SMS_OK)
{
sprintf (SM_Error_Msg, "SM_Heap_Lock : Internal Error 1 !");
SM_Error_Print ();
}
else
{
if( Heap->Nb_Seg != Heap->MHH->DSR->Index_Tab[NDD_INDEX_PRIMARY].Node_Number)
{
ND_Index_Node_First_Get( &node_ptr, Heap->MHH->DSR, NDD_INDEX_PRIMARY);
if( node_ptr == NULL)
{
sprintf (SM_Error_Msg, "SM_Heap_Lock : Internal Error 2 !");
SM_Error_Print ();
}
else
{
while( node_ptr)
{
if( ( rc = SM_DataSegment_Open( node_ptr->Value)) != SMS_OK)
{
sprintf (SM_Error_Msg, "SM_Heap_Lock : unable to open one of the data segments of heap \"%s\"",
( (SMT_MHH *)(node_ptr->Value))->Name);
SM_Error_Print ();
}
else
{
// sprintf (SM_Error_Msg, "SM_Heap_Lock : Opening Segment (%x)", node_ptr->Value);
// SM_Error_Print ();
}
ND_Index_Node_Next_Get( &node_ptr, node_ptr);
}
}
}
}
}
/* On vérifie qu'aucun nouveau segment n'a été ajouté depuis la dernière ouverture */ /* On vérifie qu'aucun nouveau segment n'a été ajouté depuis la dernière ouverture */
if (Heap->Nb_Seg != Heap->MHH->DSR->Index_Tab[NDD_INDEX_PRIMARY].Node_Number) if (Heap->Nb_Seg != Heap->MHH->DSR->Index_Tab[NDD_INDEX_PRIMARY].Node_Number)
@ -1048,7 +1097,7 @@ SMT_Status SM_Heap_Lock_I ( SMT_Heap * Heap, SMT_Flags Lock_Mode, int * Locked )
/* Verrouillage du heap qui est déjà verrouillé dans un autre mode */ /* Verrouillage du heap qui est déjà verrouillé dans un autre mode */
rc = SM_Heap_Lock_Change (Heap->MHH, Lock_Mode); rc = SM_Heap_Lock_Change (Heap->MHH, Lock_Mode);
if (rc != SMS_OK) if( rc != SMS_OK)
{ {
sprintf (SM_Error_Msg, "SM_Heap_Lock : unable to change lock of heap \"%s\" for %s", Heap->Name, Lock_Mode & SMD_READ ? "reading" : "writing"); sprintf (SM_Error_Msg, "SM_Heap_Lock : unable to change lock of heap \"%s\" for %s", Heap->Name, Lock_Mode & SMD_READ ? "reading" : "writing");
SM_Error_Print (); SM_Error_Print ();
@ -3086,7 +3135,7 @@ NDT_Status SM_Opened_Heap_List_Manager( NDT_Root *Root_Ptr, NDT_Index_Id Inde
Command_Name = "NDD_CMD_MANAGER_VERSION"; Command_Name = "NDD_CMD_MANAGER_VERSION";
*Version_Name_Ptr = "$Revision: 2.3 $ $Name: $ $Date: 2005/06/26 22:50:49 $ $Author: agibert $"; *Version_Name_Ptr = "$Revision: 2.4 $ $Name: $ $Date: 2005/06/26 23:40:14 $ $Author: agibert $";
return( NDS_OK); return( NDS_OK);
} }
@ -3313,7 +3362,7 @@ NDT_Status MHR_Manager( NDT_Root *Root_Ptr, NDT_Index_Id Index_Id, NDT_Node
Command_Name = "NDD_CMD_MANAGER_VERSION"; Command_Name = "NDD_CMD_MANAGER_VERSION";
*Version_Name_Ptr = "$Revision: 2.3 $ $Name: $ $Date: 2005/06/26 22:50:49 $ $Author: agibert $"; *Version_Name_Ptr = "$Revision: 2.4 $ $Name: $ $Date: 2005/06/26 23:40:14 $ $Author: agibert $";
return( NDS_OK); return( NDS_OK);
} }
@ -3818,6 +3867,15 @@ NDT_Status MHR_Manager( NDT_Root *Root_Ptr, NDT_Index_Id Index_Id, NDT_Node
return( status); return( status);
} }
/* TEST !!! */
if( locked != TRUE)
{
sprintf( SM_Error_Msg, "Error MHR_Manager : unable to lock Heap_Name: [%s] for reading", MHH_Ptr->Name);
SM_Error_Print();
return( SMS_KO);
}
segment_nb = MHH_Ptr->DSR->Index_Tab[NDD_INDEX_PRIMARY].Node_Number; segment_nb = MHH_Ptr->DSR->Index_Tab[NDD_INDEX_PRIMARY].Node_Number;
ND_DataStruct_Traverse( MHH_Ptr->DSR, NDD_CMD_VALUE_SUM, (void *)&segment_size); ND_DataStruct_Traverse( MHH_Ptr->DSR, NDD_CMD_VALUE_SUM, (void *)&segment_size);
@ -4058,7 +4116,7 @@ NDT_Status SM_DSR_Manager( NDT_Root *Root_Ptr, NDT_Index_Id Index_Id, NDT_Node
Command_Name = "NDD_CMD_MANAGER_VERSION"; Command_Name = "NDD_CMD_MANAGER_VERSION";
*Version_Name_Ptr = "$Revision: 2.3 $ $Name: $ $Date: 2005/06/26 22:50:49 $ $Author: agibert $"; *Version_Name_Ptr = "$Revision: 2.4 $ $Name: $ $Date: 2005/06/26 23:40:14 $ $Author: agibert $";
return( NDS_OK); return( NDS_OK);
} }
@ -4590,7 +4648,7 @@ NDT_Status SM_ACR_Manager( NDT_Root *Root_Ptr, NDT_Index_Id Index_Id, NDT_Node
Command_Name = "NDD_CMD_MANAGER_VERSION"; Command_Name = "NDD_CMD_MANAGER_VERSION";
*Version_Name_Ptr = "$Revision: 2.3 $ $Name: $ $Date: 2005/06/26 22:50:49 $ $Author: agibert $"; *Version_Name_Ptr = "$Revision: 2.4 $ $Name: $ $Date: 2005/06/26 23:40:14 $ $Author: agibert $";
return( NDS_OK); return( NDS_OK);
} }
@ -4846,7 +4904,7 @@ NDT_Status SM_FCR_Manager( NDT_Root *Root_Ptr, NDT_Index_Id Index_Id, NDT_Node
Command_Name = "NDD_CMD_MANAGER_VERSION"; Command_Name = "NDD_CMD_MANAGER_VERSION";
*Version_Name_Ptr = "$Revision: 2.3 $ $Name: $ $Date: 2005/06/26 22:50:49 $ $Author: agibert $"; *Version_Name_Ptr = "$Revision: 2.4 $ $Name: $ $Date: 2005/06/26 23:40:14 $ $Author: agibert $";
return( NDS_OK); return( NDS_OK);
} }