Exemple #1
0
PostImageProcess::PostImageProcess(PostProcesser id, 
				   SharedImageProcesser imageProcesser,
				   const QString &processName)
{
	setPostProcesser(id, imageProcesser);
	setProcessName(processName);
}
static inline int createFile(void) {

#ifdef _DEBUGFLAGS_H_
    {
        static unsigned int registered = 0;
        if (unlikely(0 == registered)) {
            registered = 1; /* dirty work around to avoid deadlock: syslogex->register->syslogex */
            registered = (registerLibraryDebugFlags(&debugFlags) == EXIT_SUCCESS);
        }
    }
#endif /*_DEBUGFLAGS_H_*/

    int error = pthread_mutex_lock(&fileLock);

    if (likely(EXIT_SUCCESS == error)) {
        int internalError = EXIT_SUCCESS;

        if (log_fd[current_log_fd] != -1) {
            WARNING_MSG("fd was NOT NULL");
            if (close(log_fd[current_log_fd]) != 0) {
                internalError = errno;
                ERROR_MSG("close %d error %d (%m)", log_fd[current_log_fd], internalError);
            }
            log_fd[current_log_fd] = -1;
        }

        if (unlikely(NULL == processName)) {
            setProcessName();
        }
        setFullFileName();

        log_fd[current_log_fd] = open(fullFileName, O_WRONLY | O_CREAT | O_TRUNC | O_SYNC, S_IRUSR | S_IWUSR | S_IRGRP);
        if (likely(log_fd[current_log_fd] != -1)) {
            fileSize = 0;
        } else {
            error = errno;
            ERROR_MSG("open %s for creation error %d (%m)", fullFileName, error);
        }

        internalError = pthread_mutex_unlock(&fileLock);
        if (internalError != EXIT_SUCCESS) {
            ERROR_MSG("pthread_mutex_lock fileLock error %d (%s)", internalError, strerror(internalError));
            if (EXIT_SUCCESS == error) {
                error = internalError;
            }
        }

    } else {
        ERROR_MSG("pthread_mutex_lock fileLock error %d (%m)", error);
    }

    return error;
}
Exemple #3
0
static inline int createFile(void) {

#ifdef _DEBUGFLAGS_H_
	{
		static unsigned int registered = 0;
		if (unlikely(0 == registered)) {
			registered = 1; /* dirty work around to avoid deadlock: syslogex->register->syslogex */
			registered = (registerLibraryDebugFlags(&debugFlags) == EXIT_SUCCESS);
		}
	}
#endif /*_DEBUGFLAGS_H_*/

	int error = pthread_mutex_lock(&fileLock);

	if (likely(EXIT_SUCCESS == error)) {
		int internalError = EXIT_SUCCESS;
		int flags = O_WRONLY|O_CREAT|O_TRUNC;

		if (likely((!(LogStat & LOG_FILE_WITHOUT_SYNC)) && (!(LogStat & LOG_FILE_SYNC_ON_ERRORS_ONLY)))) {
			flags |= O_SYNC; /* enable synchronous I/O to avoid data lost in case of crash */
		}

		if (logFile != -1) {
			WARNING_MSG("logFile was NOT NULL");
			if (close(logFile) != 0) {
				internalError = errno;
				ERROR_MSG("close %d error %d (%m)", logFile, internalError);
			}
			logFile = -1;
		}

		if (unlikely(NULL == processName)) {
			setProcessName();
		}
		setFullFileName();

		logFile = open(fullFileName,flags,S_IRUSR|S_IWUSR|S_IRGRP);
		if (likely(logFile != -1)) {
			fileSize = 0;
			if (LOG_FILE_DURATION & LogStat) {
				startTime = time(NULL);
			}
		} else {
			error = errno;
			ERROR_MSG("open %s for creation error %d (%m)", fullFileName, error);
		}

		internalError = pthread_mutex_unlock(&fileLock);
		if (internalError != EXIT_SUCCESS) {
			ERROR_MSG("pthread_mutex_lock fileLock error %d (%s)", internalError, strerror(internalError));
			if (EXIT_SUCCESS == error) {
				error = internalError;
			}
		}

	} else {
		ERROR_MSG("pthread_mutex_lock fileLock error %d (%m)", error);
	}

	return error;
}
Exemple #4
0
ImageFamilyProcess::ImageFamilyProcess(const QString &processName)
{
	setProcessName(processName);
}
Exemple #5
0
DynamicImageProcess::DynamicImageProcess(SharedImageProcesser imageProcesser,
					 const QString &processName)
{
	m_image_processer = imageProcesser;
	setProcessName(processName);
}
Exemple #6
0
void renameCurrentProcess(const char* str) {
	setProcessName(getCurrentProcess(), str);
}