only unlink if zmc is being destroyed

This commit is contained in:
Andy Bauer 2016-11-14 19:01:00 -06:00
parent 6c7d71361a
commit d3a7fca079
1 changed files with 6 additions and 4 deletions

View File

@ -675,12 +675,14 @@ Monitor::~Monitor()
Fatal( "Can't munmap: %s", strerror(errno) ); Fatal( "Can't munmap: %s", strerror(errno) );
close( map_fd ); close( map_fd );
if ( purpose == CAPTURE ) {
char mmap_path[PATH_MAX] = ""; char mmap_path[PATH_MAX] = "";
snprintf( mmap_path, sizeof(mmap_path), "%s/zm.mmap.%d", config.path_map, id ); snprintf( mmap_path, sizeof(mmap_path), "%s/zm.mmap.%d", config.path_map, id );
if ( unlink( mmap_path ) < 0 ) { if ( unlink( mmap_path ) < 0 ) {
Warning( "Can't unlink '%s': %s", mmap_path, strerror(errno) ); Warning( "Can't unlink '%s': %s", mmap_path, strerror(errno) );
} }
}
#else // ZM_MEM_MAPPED #else // ZM_MEM_MAPPED
struct shmid_ds shm_data; struct shmid_ds shm_data;
if ( shmctl( shm_id, IPC_STAT, &shm_data ) < 0 ) { if ( shmctl( shm_id, IPC_STAT, &shm_data ) < 0 ) {