Skip to content

Commit

Permalink
Merge pull request #502 from sshedi/pthread-usage-removal
Browse files Browse the repository at this point in the history
Remove pthread_mutex API usage from TDNF.
  • Loading branch information
oliverkurth authored Oct 11, 2024
2 parents a4aee1a + 0d54ae3 commit 74529aa
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 31 deletions.
31 changes: 7 additions & 24 deletions client/api.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

uid_t gEuid;

static TDNF_ENV gEnv = {0};
static int gInitialized;

static tdnflock instance_lock;

Expand Down Expand Up @@ -44,44 +44,27 @@ static void IsTdnfAlreadyRunning(void)

uint32_t TDNFInit(void)
{
int nLocked = 0;
uint32_t dwError = 0;

pthread_mutex_lock(&gEnv.mutexInitialize);
nLocked = 1;
if(!gEnv.nInitialized)
if (!gInitialized)
{
dwError = rpmReadConfigFiles(NULL, NULL);
BAIL_ON_TDNF_ERROR(dwError);

gEnv.nInitialized = 1;
gInitialized = 1;
}

cleanup:
if(nLocked)
{
pthread_mutex_unlock(&gEnv.mutexInitialize);
}
return dwError;

error:
goto cleanup;
return dwError;
}

void
TDNFUninit(
void
)
void TDNFUninit(void)
{
pthread_mutex_lock (&gEnv.mutexInitialize);

if(gEnv.nInitialized)
if (gInitialized)
{
rpmFreeRpmrc();
gInitialized = 0;
}
gEnv.nInitialized = 0;

pthread_mutex_unlock(&gEnv.mutexInitialize);
}

//Check all available packages
Expand Down
1 change: 0 additions & 1 deletion client/includes.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
#include <sys/types.h>

#include <dirent.h>
#include <pthread.h>

#include "../solv/includes.h"

Expand Down
6 changes: 0 additions & 6 deletions client/structs.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,6 @@ typedef struct _TDNF_RPM_TS_
PTDNF_CACHED_RPM_LIST pCachedRpmsArray;
} TDNFRPMTS, *PTDNFRPMTS;

typedef struct _TDNF_ENV_
{
pthread_mutex_t mutexInitialize;
int nInitialized;
} TDNF_ENV, *PTDNF_ENV;

typedef struct _TDNF_REPO_METADATA
{
char *pszRepoCacheDir;
Expand Down

0 comments on commit 74529aa

Please sign in to comment.