Example #1
0
void aOpenLogFile(const char *ident, int logstat, int logfac) {
    int i;
    struct sigaction sa;

    for (i = 0; i < NB_BUFFERS; i++) {
        buffersList[i].state = BUFFER_FREE;
    }
    
    for (i = 0; i < NB_FD; i++) {
        files[i].fd = -1;
        files[i].nb_running_aiocb = 0;
        files[i].size = 0;
    }

    currentBuffer = find_free_buf();
    currentFile = NULL;

    if (ident != NULL) {
        LogTag = ident;
    }

    LogStat = logstat;
    
    if (logfac != 0 && (logfac &~LOG_FACMASK) == 0) {
        LogFacility = logfac;
    }   
}
Example #2
0
/* log some data */
static inline int log_data(char *logdata, int nbytes) {
    int nlogged = 0;
    int num_to_copy = 0;

    int error = pthread_mutex_lock(&alogger_lock);
    if (0 == error) {
        while (nlogged < nbytes) {
            num_to_copy = MIN(BUFFER_SIZE - currentBuffer->used_size, nbytes - nlogged);
            memcpy(&currentBuffer->buffer[currentBuffer->used_size], logdata + nlogged, num_to_copy);
            currentBuffer->used_size += num_to_copy;
            nlogged += num_to_copy;
            DEBUG_MSG("curbuf->fillpt = %d", currentBuffer->used_size);
            if (BUFFER_SIZE == currentBuffer->used_size) {
                /* buffer full, flush and get a new one */
                DEBUG_MSG("buffer 0x%X full, flush and get a new one", currentBuffer);
                flush_filled_buf(currentBuffer);
                DEBUG_MSG("buffer flushed");
                currentBuffer = find_free_buf();
                DEBUG_MSG("new buffer 0x%X", currentBuffer);
            }
        }
        error = pthread_mutex_unlock(&alogger_lock);
        if (error != 0) {
            ERROR_MSG("pthread_mutex_unlock alogger_lock error %d", error);
        }
    } else {
        ERROR_MSG("pthread_mutex_lock alogger_lock error %d", error);
    }
    return error;
}
Example #3
0
void	pmt_cache_put(UINT32 const pmt_idx)
{
	ASSERT(pmt_idx < PMT_SUB_PAGES);
	ASSERT(get_page(pmt_idx) == NULL_PAGE_IDX);
	ASSERT(num_free_sub_pages > 0);

	UINT32 free_page_idx = find_free_buf();
	cached_pmt_idxes[free_page_idx] = pmt_idx;
	cached_pmt_timestamps[free_page_idx] = LOADING_TIMESTAMP;

	last_pmt_idx = pmt_idx;
	last_page_idx = free_page_idx;

	num_free_sub_pages--;
}