static void flush_logqueue (void) { int empty; do { pthread_mutex_lock(&logq_lock); empty = log_dequeue(la->buff); pthread_mutex_unlock(&logq_lock); if (!empty) log_syslog(la->buff); } while (empty == 0); }
static void log_flush(void) { while (!la->empty) { la->ops[0].sem_op = -1; if (semop(la->semid, la->ops, 1) < 0) { syslog(LOG_ERR, "semop up failed"); exit(1); } log_dequeue(la->buff); la->ops[0].sem_op = 1; if (semop(la->semid, la->ops, 1) < 0) { syslog(LOG_ERR, "semop down failed"); exit(1); } log_syslog(la->buff); } }
static void log_flush(void) { int msglen; while (!la->empty) { la->ops[0].sem_op = -1; if (semop(la->semid, la->ops, 1) < 0) { syslog(LOG_ERR, "semop up failed %d", errno); exit(1); } msglen = log_dequeue(la->buff); la->ops[0].sem_op = 1; if (semop(la->semid, la->ops, 1) < 0) { syslog(LOG_ERR, "semop down failed"); exit(1); } if (msglen) log_syslog(la->buff); } }