Esempio n. 1
0
void logUnInit()
{
#if !defined ENABLE_DMLOG
	return;
#else
    g_logInited = 0;
    if(g_logType == LOG_DRIVER_FILE){
	    if(g_hLogFile != NULL)
	    {
		    fclose(g_hLogFile);
		    g_hLogFile = NULL;
	    }
    }
    
    if(g_logType == LOG_DRIVER_SYSLOG)
    {
      #ifdef LINUX
        closelog();
      #endif
    }
    if(g_logType == LOG_DRIVER_MMAP)
    {
        eventFree(g_mmap_log.event);
        mutexFree(g_mmap_log.mutex);
        mmapClose(g_mmap_log.handle);
    }
    UnInitLock(&g_LockLog);
#endif
}
Esempio n. 2
0
static int thread_open( UThread* ut, const UPortDevice* pdev,
                        const UCell* from, int opt, UCell* res )
{
    UBuffer* port;
    ThreadExt* ext;
    (void) from;
    (void) opt;

    ext = (ThreadExt*) memAlloc( sizeof(ThreadExt) );
    if( ! ext )
        return ur_error( ut, UR_ERR_INTERNAL, "Could not alloc thread port" );

    if( ! _initThreadQueue( &ext->A ) )
    {
fail:
        memFree( ext );
        return ur_error( ut, UR_ERR_INTERNAL, "Could not create thread queue" );
    }

    if( ! _initThreadQueue( &ext->B ) )
    {
        mutexFree( ext->A.mutex );
        goto fail;
    }

    ext->A.END_OPEN = 0;
    ext->B.END_OPEN = 1;

    port = boron_makePort( ut, pdev, ext, res );
    port->SIDE = SIDE_A;
    return UR_OK;
}
Esempio n. 3
0
/**
 * userdataMutex() \n
 * Function which save the mutex \n
 * @param CHANGE switching \n
 *			 	newMutex for create a new mutex \n
 *			 	freeMutex for delete the mutex \n
 *			 	getMutex to return a pointer to the Mutex \n
 * @return NULL on error or a pointer to Mutex \n
 */
void* userdataMutex(CHANGE switching)
{
	static MUTEX userMutex;

	// Create a new Mutex
	if(switching == newMutex)
	{
		if (mutexInit( &userMutex, "userMutex") == false)
		{
			syslogWriteDebug(lerror,"Error: Can't create mutex");
		}
	}
	// Free the mutex
	if(switching == freeMutex)
	{
		if (mutexFree(&userMutex) == false);
			syslogWriteDebug(lerror,"Error: Can't free mutex");
		return NULL;
	}
	// Return mutex
	if(switching == getMutex)
	{
		return (void *) &userMutex;
	}
	// No correct parameter
	syslogFormatWriteDebug(lerror,"Error: False parameter %i",switching);
}
Esempio n. 4
0
static void _freeThreadQueue( ThreadQueue* queue )
{
    // TODO: Free buffers in queue.

    mutexFree( queue->mutex );
    condFree( queue->cond );
    ur_blkFree( &queue->buf );
#ifdef USE_EVENTFD
    if( queue->eventFD > -1 )
        close( queue->eventFD );
#elif defined(_WIN32)
    if( queue->eventH != NULL )
        CloseHandle( queue->eventH );
#else
    if( queue->socketFD[0] > -1 )
    {
        close( queue->socketFD[0] );
        close( queue->socketFD[1] );
    }
#endif
}
Esempio n. 5
0
/**
 * UnInitializes ressources of the client thread
 * @return 					- none
 */
void ressourcesFree()
{
	mutexFree(&clientMutex);
}