Commit 877c27dc authored by Uwe Schulzweida's avatar Uwe Schulzweida
Browse files

lock CDI internal vlist objects

parent 1a4c42ae
......@@ -3,6 +3,10 @@
* Version 1.6.5 released
* using CGRIBEX library version 1.6.5
2014-10-21 Uwe Schulzweida
* lock CDI internal vlist objects
2014-10-13 Uwe Schulzweida
* added support for grib_api key typeOfSecondFixedSurface
......
......@@ -1031,6 +1031,7 @@ void streamClose(int streamID)
taxisDestroy(vlistInqTaxis(vlistID));
}
vlist_unlock(vlistID);
vlistDestroy(vlistID);
}
......@@ -2164,16 +2165,16 @@ int cdiInqAccesstype(int streamID)
return (streamptr->accesstype);
}
static int
streamTxCode(void)
static
int streamTxCode(void)
{
return STREAM;
}
void
cdiStreamSetupVlist(stream_t *streamptr, int vlistID, int vlistIDorig)
void cdiStreamSetupVlist(stream_t *streamptr, int vlistID, int vlistIDorig)
{
vlist_lock(vlistID);
int nvars = vlistNvars(vlistID);
streamptr->vlistID = vlistID;
streamptr->vlistIDorig = vlistIDorig;
......
......@@ -95,6 +95,7 @@ vlist_t *vlist_to_pointer(int code)
static
void vlist_init_entry(vlist_t *vlistptr)
{
vlistptr->locked = 0;
vlistptr->self = CDI_UNDEFID;
vlistptr->nvars = 0;
vlistptr->vars = NULL;
......@@ -168,6 +169,34 @@ void vlist_check_ptr(const char *caller, vlist_t *vlistptr)
Errorc("vlist undefined!");
}
void vlist_lock(int vlistID)
{
vlist_t *vlistptr = vlist_to_pointer(vlistID);
vlist_check_ptr(__func__, vlistptr);
if ( !vlistptr->locked )
{
vlistptr->locked = 1;
reshSetStatus(vlistID, &vlist_ops, RESH_DESYNC_IN_USE);
}
}
void vlist_unlock(int vlistID)
{
vlist_t *vlistptr = vlist_to_pointer(vlistID);
vlist_check_ptr(__func__, vlistptr);
if ( vlistptr->locked )
{
vlistptr->locked = 0;
reshSetStatus(vlistID, &vlist_ops, RESH_DESYNC_IN_USE);
}
}
/*
@Function vlistCreate
@Title Create a variable list
......@@ -258,7 +287,10 @@ void vlistDestroy(int vlistID)
{
vlist_t *vlistptr = vlist_to_pointer(vlistID);
vlist_delete(vlistptr);
if ( vlistptr->locked )
Warning("Destroying of a locked object (vlistID=%d) failed!", vlistID);
else
vlist_delete(vlistptr);
}
/*
......
......@@ -128,6 +128,7 @@ var_t;
typedef struct
{
int locked;
int self;
int nvars; /* number of variables */
int ngrids;
......@@ -170,8 +171,10 @@ void vlistDefVarValidrange(int vlistID, int varID, const double *validrange);
/* vlistInqVarValidrange: Get the valid range of a Variable */
int vlistInqVarValidrange(int vlistID, int varID, double *validrange);
int vlist_att_compare(vlist_t *a, int varIDA, vlist_t *b, int varIDB,
int attnum);
int vlist_att_compare(vlist_t *a, int varIDA, vlist_t *b, int varIDB, int attnum);
void vlist_lock(int vlistID);
void vlist_unlock(int vlistID);
static inline void
vlistAdd2GridIDs(vlist_t *vlistptr, int gridID)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment