Renamed and improved the synchronous log flushing function.

This commit is contained in:
Markus Makela
2014-11-25 16:04:23 +02:00
parent 5eaf963ad4
commit b07df3b296
2 changed files with 20 additions and 16 deletions

View File

@ -3077,27 +3077,31 @@ static int find_last_seqno(
/** /**
* Flush all log files synchronously * Flush all log files synchronously
*/ */
void skygw_log_force_flush_all(void) void skygw_log_sync_all(void)
{ {
int rval = 0, i; int i;
bool nflushed = true;
logfile_t* lf; logfile_t* lf;
for (i = LOGFILE_FIRST; i <= LOGFILE_LAST; i <<= 1) for (i = LOGFILE_FIRST; i <= LOGFILE_LAST; i <<= 1)
{ {
bool nflushed = true;
lf = &lm->lm_logfile[(logfile_id_t)i]; lf = &lm->lm_logfile[(logfile_id_t)i];
acquire_lock(&lf->lf_spinlock); acquire_lock(&lf->lf_spinlock);
lf->lf_flushflag = true; lf->lf_flushflag = true;
release_lock(&lf->lf_spinlock); release_lock(&lf->lf_spinlock);
skygw_message_send(lf->lf_logmes);
while(nflushed){
acquire_lock(&lf->lf_spinlock);
nflushed = lf->lf_flushflag;
release_lock(&lf->lf_spinlock);
}
} }
skygw_message_send(lf->lf_logmes);
for (i = LOGFILE_FIRST; i <= LOGFILE_LAST; i <<= 1)
{
while(nflushed)
{
acquire_lock(&lf->lf_spinlock);
nflushed = lf->lf_flushflag;
release_lock(&lf->lf_spinlock);
}
}
} }

View File

@ -113,7 +113,7 @@ void skygw_logmanager_exit(void);
void skygw_log_done(void); void skygw_log_done(void);
int skygw_log_write(logfile_id_t id, const char* format, ...); int skygw_log_write(logfile_id_t id, const char* format, ...);
int skygw_log_flush(logfile_id_t id); int skygw_log_flush(logfile_id_t id);
void skygw_log_force_flush_all(void); void skygw_log_sync_all(void);
int skygw_log_rotate(logfile_id_t id); int skygw_log_rotate(logfile_id_t id);
int skygw_log_write_flush(logfile_id_t id, const char* format, ...); int skygw_log_write_flush(logfile_id_t id, const char* format, ...);
int skygw_log_enable(logfile_id_t id); int skygw_log_enable(logfile_id_t id);