Пример #1
0
extern "C" VOID SQL_API TraceDebugOut( unsigned int length, char* szBuffer, char* text, int format)
{
#ifndef DISABLE_TRACE
/*
 *  TraceReturn calls GrabErrors(). GrabErrors() goes in and gets diagnostics - now if there is
 *  any kind of debug tracing going on there TraceDebygOut gets called and 
 *  we could get into a problem with deadlocks.  To avoid that condition we will attempt to lock the mutex
 *  if the calling thread owns the lock, EDEADLK will be returned and we can proceed
 *  otherwise EBUSY is returned and we can call the normal lock and wait
 *
 */

	int status;
	int wasAlreadyLocked = false;

	status = g_csWrite.TryLock();

	if(status == EBUSY)
	   EnterCriticalSection2(&g_csWrite);
	else if(status == EDEADLK)
	  wasAlreadyLocked = true;

	if (g_fNoTrace)
	{
		if(!wasAlreadyLocked) 
		   LeaveCriticalSection2(&g_csWrite);
		return;
	}


	if (!fhTraceFile)
	{
		(void) TraceOpenLogFile((LPWSTR)szGlobalTraceFileName,NULL,0);
		if (!fhTraceFile)
		{
			if(!wasAlreadyLocked) 
		       LeaveCriticalSection2(&g_csWrite);
			return;
	}
	}

	if(FORMAT_TEXT==format)
	{
		text_out(szBuffer,text);
	}
	else if(FORMAT_DUMP==format)
	{
		hex_out(length, szBuffer, text);
	}
	fflush(fhTraceFile);

	if(!wasAlreadyLocked) 
	LeaveCriticalSection2(&g_csWrite);
#endif
}
void WINAPI
SET_WARNING(long signature, char platform, char transport, int api, ERROR_TYPE error_type, char* process, OPERATION operation, FUNCTION function, int error, int errordetail)
{
#ifdef NSK_ODBC_SRVR
	EnterCriticalSection2(&GTransport.m_TransportCSObject);
#else
	EnterCriticalSection (&GTransport.m_TransportCSObject);
#endif

	CError* ierror = GTransport.m_error_list.ins_error(signature);
	;
	if (ierror != NULL)
	{
		ierror->platform = platform;
		ierror->transport = transport;
		ierror->api = api;
		ierror->error_type = error_type;
		strncpy(ierror->process_name,process,MAX_PROCESS_NAME);
		ierror->process_name[MAX_PROCESS_NAME-1] = 0;
		ierror->operation = operation;
		ierror->function = function;
		ierror->error = error;
		ierror->errordetail = errordetail;
		GTransport.log_warning(ierror);
	}

#ifdef NSK_ODBC_SRVR
	LeaveCriticalSection2(&GTransport.m_TransportCSObject);
#else
	LeaveCriticalSection (&GTransport.m_TransportCSObject);
#endif
}
Пример #3
0
bool CTCPIPUnixDrvr_list::del_node(CTCPIPUnixDrvr* p )
{
	EnterCriticalSection2 (&GTransport.m_TransportCSObject);
	bool bret = true;

	CTCPIPUnixDrvr* cnode = list;
	CTCPIPUnixDrvr* pnode = list;
	while( cnode!= NULL )
	{
		if( cnode == p )
			break;
		pnode = cnode;
		cnode = cnode->next;
	}
	if( cnode==NULL )
	{
		bret = false;
		goto out;
	}
	if (pnode == list && cnode == list)
		list = cnode->next;
	else
		pnode->next = cnode->next;
	delete cnode;
out:
	LeaveCriticalSection2 (&GTransport.m_TransportCSObject);
	return bret;
}
Пример #4
0
bool CError_list::del_error(long signature)
{
	EnterCriticalSection2 (&m_ErrorCSObject);
	CError* cnode = list;
	CError* pnode = list;
	bool bret = true;
	while( cnode!= NULL  && cnode->signature != signature )
	{
		pnode = cnode;
		cnode = cnode->next;
	}
	if( cnode==NULL)
	{
		bret = false;
		goto out;
	}
	if (pnode == list && cnode == list)
		list = cnode->next;
	else
		pnode->next = cnode->next;
	delete cnode;
out:
	LeaveCriticalSection2 (&m_ErrorCSObject);
	return bret;
}
Пример #5
0
extern "C" VOID SQL_API TraceTransportIn(int operation, char* reference, void* prheader, char* buffer, long tcount, long timeout)
{
#ifndef DISABLE_TRACE
	EnterCriticalSection2(&g_csWrite);
	if (!fhTraceFile)
	{
		(void) TraceOpenLogFile((LPWSTR)szGlobalTraceFileName,NULL,0);
		if (!fhTraceFile)
		{
			LeaveCriticalSection2(&g_csWrite);
			return;
		}
	}
	traceTransportIn(operation, reference, prheader, buffer, tcount, timeout);
	fflush(fhTraceFile);
	LeaveCriticalSection2(&g_csWrite);
#endif
}
Пример #6
0
extern "C" VOID SQL_API TraceFirstEntry( char* szDriverDLLName )
{
#ifndef DISABLE_TRACE
	EnterCriticalSection2(&g_csWrite);

	if (!fhTraceFile)
	{
		(void) TraceOpenLogFile((LPWSTR)szGlobalTraceFileName,NULL,0);
		if (!fhTraceFile)
		{
		   	LeaveCriticalSection2(&g_csWrite);
			return;
		}
	}

	traceInfo(szDriverDLLName);
	fflush(fhTraceFile);

	LeaveCriticalSection2(&g_csWrite);
#endif
}
Пример #7
0
CError* CError_list::find_last_error()
{
	EnterCriticalSection2 (&m_ErrorCSObject);
	CError* cnode = list;
	CError* pnode = list;
	while( cnode!= NULL )
	{
		pnode = cnode;
		cnode = cnode->next;
	}
	LeaveCriticalSection2 (&m_ErrorCSObject);
	return pnode;
}
Пример #8
0
CError* CError_list::find_error(long signature)
{
	EnterCriticalSection2 (&m_ErrorCSObject);
	CError* cnode = list;
	CError* pnode = list;
	while( cnode!= NULL && cnode->signature != signature )
	{
		pnode = cnode;
		cnode = cnode->next;
	}
	LeaveCriticalSection2 (&m_ErrorCSObject);
	return cnode;
}
Пример #9
0
CTCPIPUnixDrvr* CTCPIPUnixDrvr_list::find_node(char* object_ref )
{
	EnterCriticalSection2 (&GTransport.m_TransportCSObject);
	CTCPIPUnixDrvr* cnode = list;
	while( cnode != NULL )
	{
		if (strcmp(cnode->m_object_ref, object_ref) == 0 ){
			break;
		}
		cnode = cnode->next;
	}
	LeaveCriticalSection2 (&GTransport.m_TransportCSObject);
	return cnode;
}
Пример #10
0
void CError_list::cleanup()
{
	EnterCriticalSection2 (&m_ErrorCSObject);
	CError* cnode = list;
	CError* nnode;
	while( cnode != NULL )
	{
		nnode = cnode->next;
		delete cnode;
		cnode = nnode;
	}
	list=NULL;
	LeaveCriticalSection2 (&m_ErrorCSObject);
}
Пример #11
0
void CTCPIPUnixDrvr_list::cleanup()
{
	EnterCriticalSection2 (&GTransport.m_TransportCSObject);


	CTCPIPUnixDrvr* cnode = list;
	CTCPIPUnixDrvr* nnode;
	while( cnode != NULL ){
		nnode = cnode->next;
		delete cnode;
		cnode = nnode;
	}
	list=NULL;
	LeaveCriticalSection2 (&GTransport.m_TransportCSObject);
}
Пример #12
0
bool CTCPIPUnixDrvr_list::find_node(CTCPIPUnixDrvr* p )
{
	EnterCriticalSection2 (&GTransport.m_TransportCSObject);
	CTCPIPUnixDrvr* cnode = list;
	bool bfound = false;
	while( cnode != NULL )
	{
		if (cnode == p ){
			bfound = true;
			break;
		}
		cnode = cnode->next;
	}
	LeaveCriticalSection2 (&GTransport.m_TransportCSObject);
	return bfound;
}
void WINAPI
RESET_ERRORS(long signature)
{
    if(signature == 0) return;
#ifdef NSK_ODBC_SRVR
	EnterCriticalSection2(&GTransport.m_TransportCSObject);
#else
	EnterCriticalSection (&GTransport.m_TransportCSObject);
#endif
	GTransport.m_error_list.del_error(signature);
#ifdef NSK_ODBC_SRVR
	LeaveCriticalSection2(&GTransport.m_TransportCSObject);
#else
	LeaveCriticalSection (&GTransport.m_TransportCSObject);
#endif
}
//LCOV_EXCL_START
int WINAPI
GET_ERROR_DETAIL(long signature)
{
#ifdef NSK_ODBC_SRVR
	EnterCriticalSection2(&GTransport.m_TransportCSObject);
#else
	EnterCriticalSection (&GTransport.m_TransportCSObject);
#endif
	CError* ierror = GTransport.m_error_list.find_error(signature);
#ifdef NSK_ODBC_SRVR
	LeaveCriticalSection2(&GTransport.m_TransportCSObject);
#else
	LeaveCriticalSection (&GTransport.m_TransportCSObject);
#endif
	if (ierror != NULL)
		return ierror->errordetail;
	else
		return 0;
}
Пример #15
0
CTCPIPUnixDrvr* CTCPIPUnixDrvr_list::ins_node()
{
	EnterCriticalSection2 (&GTransport.m_TransportCSObject);

	CTCPIPUnixDrvr* cnode = list;
	CTCPIPUnixDrvr* pnode = list;
	CTCPIPUnixDrvr* nnode;
	while(cnode!=NULL ){
		pnode=cnode;
		cnode=cnode->next;
	}
	if((nnode = new CTCPIPUnixDrvr())!=NULL){
		nnode->next = cnode;
		if(pnode!=NULL) 
			pnode->next = nnode;
		else
			list = nnode;
	}
	LeaveCriticalSection2 (&GTransport.m_TransportCSObject);
	return nnode ;
}
void WINAPI
SET_ERROR(long signature, char platform, char transport, int api, ERROR_TYPE error_type, char* process, OPERATION operation, FUNCTION function, int error, int errordetail)
{
	CError* ierror;
#ifdef NSK_ODBC_SRVR
	if(signature != 0)
	EnterCriticalSection2(&GTransport.m_TransportCSObject);
#else
	EnterCriticalSection (&GTransport.m_TransportCSObject);
#endif

	if(signature == 0)
		// when signatue is 0, the intent is to log an error - no need to insert into a list
       ierror = new CError;
	else
	   ierror = GTransport.m_error_list.ins_error(signature);

	if (ierror != NULL)
	{
		ierror->platform = platform;
		ierror->transport = transport;
		ierror->api = api;
		ierror->error_type = error_type;
		strncpy(ierror->process_name,process,MAX_PROCESS_NAME);
		ierror->process_name[MAX_PROCESS_NAME-1] = 0;
		ierror->operation = operation;
		ierror->function = function;
		ierror->error = error;
		ierror->errordetail = errordetail;
		GTransport.log_error(ierror);
	}
#ifdef NSK_ODBC_SRVR
	if(signature != 0)
	LeaveCriticalSection2(&GTransport.m_TransportCSObject);
#else
	LeaveCriticalSection (&GTransport.m_TransportCSObject);
#endif
    if(signature == 0)
	   delete ierror;
}
Пример #17
0
CError* CError_list::ins_error(long signature)
{
	EnterCriticalSection2 (&m_ErrorCSObject);
	CError* cnode = list;
	CError* pnode = list;
	CError* nnode;

	while(cnode!=NULL )
	{
		pnode=cnode;
		cnode=cnode->next;
	}

	if((nnode = new CError())!=NULL)
	{
		nnode->signature = signature;
		if(pnode!=NULL) 
			pnode->next = nnode;
		else
			list = nnode;
	}
	LeaveCriticalSection2 (&m_ErrorCSObject);
	return nnode;
}