fix shutdown bug in filePool log

This commit is contained in:
Sears Russell 2011-04-21 00:27:15 +00:00
parent 1b71865b7d
commit f64a3c2aba
2 changed files with 12 additions and 6 deletions

View file

@ -483,11 +483,8 @@ int stasis_log_file_pool_close(stasis_log_t * log) {
pthread_join(fp->write_thread, 0);
// pthread_join(fp->write_thread2, 0);
// XXX need to force log to disk here.
for(int i = 0; i < fp->live_count; i++) {
if(fp->ro_fd[i] != -1) {
close(fp->ro_fd[i]);
}
free(fp->live_filenames[i]);
}
for(int i = 0; i < fp->dead_count; i++) {
@ -712,7 +709,7 @@ stasis_log_t* stasis_log_file_pool_open(const char* dirname, int filemode, int f
free(namelist[i]);
}
assert(fp->live_count);
free(namelist);
printf("Current log segment appears to be %s. Scanning for next available LSN\n", fp->live_filenames[fp->live_count-1]);

View file

@ -137,7 +137,16 @@ lsn_t stasis_ringbuffer_consume_bytes(stasis_ringbuffer_t * ring, lsn_t* sz, lsn
while(RING_VOLATILE == (ret = stasis_ringbuffer_nb_consume_bytes(ring, RING_NEXT, sz))) {
pthread_cond_wait(&ring->write_done, &ring->mut);
*sz = (ring->flush > ring->rf) ? RING_NEXT : orig_sz;
if(ring->shutdown) { *sz = RING_NEXT; }
if(ring->shutdown) {
if(ring->rt == ring->wf) {
fprintf(stderr, "Shutting down, and there are no more bytes. Signaling shutdown thread.\n");
pthread_cond_signal(&ring->read_done);
pthread_mutex_unlock(&ring->mut);
return RING_CLOSED;
} else {
*sz = RING_NEXT;
}
}
}
if(handle) {
*handle = ret;