Skip to content
This repository was archived by the owner on Oct 26, 2021. It is now read-only.

Partial revert of 3b28999fa9a1f7f8cd9b55ba6f8165e2447038fc #7

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 15 additions & 21 deletions src/key-value-store/pers_low_level_db_access.c
Original file line number Diff line number Diff line change
Expand Up @@ -145,27 +145,6 @@ static int openCache(KISSDB* db);
//static int addCache(KISSDB* db);
static int closeCache(KISSDB* db);


__attribute__((constructor))
static void pco_library_init()
{
pid_t pid = getpid();
str_t dltContextID[16]; /* should be at most 4 characters string, but colissions occure */

/* init DLT */
(void) snprintf(dltContextID, sizeof(dltContextID), "Pers_%04d", pid);
DLT_REGISTER_CONTEXT(persComLldbDLTCtx, dltContextID, "PersCommonLLDB");
//DLT_SET_APPLICATION_LL_TS_LIMIT(DLT_LOG_INFO, DLT_TRACE_STATUS_OFF);
DLT_LOG(persComLldbDLTCtx, DLT_LOG_INFO, DLT_STRING(LT_HDR); DLT_STRING(__FUNCTION__); DLT_STRING(":"); DLT_STRING("register context PersCommonLLDB ContextID="); DLT_STRING(dltContextID));
}

__attribute__((destructor))
static void pco_library_destroy()
{
DLT_UNREGISTER_CONTEXT(persComLldbDLTCtx);
}


/**
* \open or create a key-value database
* \note : DB type is identified from dbPathname (based on extension)
Expand All @@ -189,9 +168,24 @@ sint_t pers_lldb_open(str_t const* dbPathname, pers_lldb_purpose_e ePurpose, boo
int incRefCounter = 1; // default increment counter
lldb_handler_s* pLldbHandler = NIL;
sint_t returnValue = PERS_COM_FAILURE;
static bool_t bFirstCall = true;

path = dbPathname;

if (bFirstCall)
{
pid_t pid = getpid();
str_t dltContextID[16]; /* should be at most 4 characters string, but colissions occure */

bFirstCall = false;

/* init DLT */
(void) snprintf(dltContextID, sizeof(dltContextID), "Pers_%04d", pid);
DLT_REGISTER_CONTEXT(persComLldbDLTCtx, dltContextID, "PersCommonLLDB");
//DLT_SET_APPLICATION_LL_TS_LIMIT(DLT_LOG_INFO, DLT_TRACE_STATUS_OFF);
DLT_LOG(persComLldbDLTCtx, DLT_LOG_INFO, DLT_STRING(LT_HDR); DLT_STRING(__FUNCTION__); DLT_STRING(":"); DLT_STRING("register context PersCommonLLDB ContextID="); DLT_STRING(dltContextID));
}

DLT_LOG(persComLldbDLTCtx, DLT_LOG_INFO,
DLT_STRING(LT_HDR); DLT_STRING(__FUNCTION__); DLT_STRING("Begin opening:"); DLT_STRING("<"); DLT_STRING(dbPathname); DLT_STRING(">, ");
((PersLldbPurpose_RCT == ePurpose) ? DLT_STRING("RCT, ") : DLT_STRING("DB, ")); ((true == bForceCreationIfNotPresent) ? DLT_STRING("forced, ") : DLT_STRING("unforced, ")));
Expand Down
37 changes: 15 additions & 22 deletions src/sqlite/pers_low_level_db_access.c
Original file line number Diff line number Diff line change
Expand Up @@ -130,28 +130,6 @@ static const char *gSqlPragSynchroOff = "PRAGMA synchronous = OFF";
#endif



/* ---------------------- local functions --------------------------------- */
__attribute__((constructor))
static void pco_library_init()
{
pid_t pid = getpid();
str_t dltContextID[16]; /* should be at most 4 characters string, but colissions occure */

/* init DLT */
(void) snprintf(dltContextID, sizeof(dltContextID), "Pers_%04d", pid);
DLT_REGISTER_CONTEXT(persComLldbDLTCtx, dltContextID, "PersCommonLLDB");
//DLT_SET_APPLICATION_LL_TS_LIMIT(DLT_LOG_DEBUG, DLT_TRACE_STATUS_OFF);
DLT_LOG(persComLldbDLTCtx, DLT_LOG_DEBUG, DLT_STRING(LT_HDR); DLT_STRING(__FUNCTION__); DLT_STRING(":"); DLT_STRING("register context PersCommonLLDB ContextID="); DLT_STRING(dltContextID));
}

__attribute__((destructor))
static void pco_library_destroy()
{
DLT_UNREGISTER_CONTEXT(persComLldbDLTCtx);
}


/* access to resources shared by the threads within a process */
static void lldb_handles_InitHandle(lldb_handler_s* psHandle_inout, pers_lldb_purpose_e ePurpose, str_t const* dbPathname);
static bool_t lldb_handles_DeinitHandle(sint_t dbHandler);
Expand Down Expand Up @@ -185,6 +163,21 @@ sint_t pers_lldb_open(str_t const * dbPathname, pers_lldb_purpose_e ePurpose, bo
int openMode = SQLITE_OPEN_READWRITE; // default mode
sint_t rval = PERS_COM_SUCCESS;
lldb_handler_s* pLldbHandler = NIL;
static bool_t bFirstCall = true ;

if (bFirstCall)
{
pid_t pid = getpid();
str_t dltContextID[16]; /* should be at most 4 characters string, but colissions occure */

bFirstCall = false;

/* init DLT */
(void) snprintf(dltContextID, sizeof(dltContextID), "Pers_%04d", pid);
DLT_REGISTER_CONTEXT(persComLldbDLTCtx, dltContextID, "PersCommonLLDB");
//DLT_SET_APPLICATION_LL_TS_LIMIT(DLT_LOG_DEBUG, DLT_TRACE_STATUS_OFF);
DLT_LOG(persComLldbDLTCtx, DLT_LOG_DEBUG, DLT_STRING(LT_HDR); DLT_STRING(__FUNCTION__); DLT_STRING(":"); DLT_STRING("register context PersCommonLLDB ContextID="); DLT_STRING(dltContextID));
}

#ifdef DB_DEBUG
DLT_LOG(persComLldbDLTCtx, DLT_LOG_INFO, DLT_STRING("pers_lldb_open -> dbPathname:" ), DLT_STRING(dbPathname), DLT_STRING("Mode:"), DLT_INT(bForceCreationIfNotPresent));
Expand Down