Skip to content
Snippets Groups Projects
Commit 75af7a5a authored by Uwe Schulzweida's avatar Uwe Schulzweida
Browse files

listInitialize: set mutex type to PTHREAD_MUTEX_RECURSIVE

parent 90d481eb
No related branches found
No related tags found
No related merge requests found
......@@ -3,6 +3,10 @@
* Version 1.5.8 released
* using CGRIBEX library version 1.5.5
2012-09-20 Uwe Schulzweida <Uwe.Schulzweida@zmaw.de>
* listInitialize: set mutex type to PTHREAD_MUTEX_RECURSIVE
2012-09-11 Uwe Schulzweida <Uwe.Schulzweida@zmaw.de>
* cdfInqContents: make ncid local to varid
......
#include <stdio.h>
#include "cdi.h"
#define nrun 30 // Number of runs
#define nrun 100 // Number of runs
#define nlon 12 // Number of longitudes
#define nlat 6 // Number of latitudes
#define nlev 5 // Number of levels
......@@ -85,14 +85,13 @@ int run(int irun)
// Close the output stream
streamClose(streamID);
// Destroy the object
/*
// Destroy the objects
vlistDestroy(vlistID);
taxisDestroy(taxisID);
zaxisDestroy(zaxisID1);
zaxisDestroy(zaxisID2);
gridDestroy(gridID);
*/
return 0;
}
......@@ -103,7 +102,7 @@ int main(void)
for ( irun = 0; irun < nrun; ++irun )
{
run(irun);
// cdiReset();
cdiReset();
}
return 0;
......
......@@ -2,6 +2,8 @@
# include "config.h"
#endif
#define _XOPEN_SOURCE 600 /* PTHREAD_MUTEX_RECURSIVE */
#include <stdlib.h>
#include <stdio.h>
......@@ -134,7 +136,7 @@ void listDestroy ( void )
for ( j = 0; j < listSizeAllocated[i]; j++ )
{
listElem = listResources[i] + j;
if ( listElem->val )
if ( listElem->val )
listElem->ops->valDestroy ( listElem->val );
}
free ( listResources[i] );
......@@ -163,8 +165,12 @@ static
void listInitialize ( void )
{
#if defined (HAVE_LIBPTHREAD)
pthread_mutexattr_t ma;
pthread_mutexattr_init(&ma);
pthread_mutexattr_settype(&ma, PTHREAD_MUTEX_RECURSIVE);
/* initialize global API mutex lock */
pthread_mutex_init ( &listMutex, NULL);
pthread_mutex_init ( &listMutex, &ma);
pthread_mutexattr_destroy(&ma);
#endif
listNew ();
......@@ -203,8 +209,8 @@ void listSizeExtend()
for ( i = listSizeAllocated[nsp]; i < newListSize; ++i )
{
listResources[nsp][i].resH = namespaceIdxEncode2 ( nsp, i );
listResources[nsp][i].next = listResources[nsp] + i + 1;
listResources[nsp][i].resH = namespaceIdxEncode2 ( nsp, i );
listResources[nsp][i].next = listResources[nsp] + i + 1;
}
listResources[nsp][newListSize-1].next = freeListHead[nsp];
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment