int sbuf_close(struct buffer_entity *be, void *stats) { (void)stats; struct simplebuf *sbuf = (struct simplebuf *)be->opt; D("Closing simplebuf for id %d ", sbuf->bufnum); LOCK_DESTROY(be->headlock); LOCK_FREE(be->headlock); free(be->iosignal); //int ret = 0; /* if(be->recer->close != NULL) be->recer->close(be->recer, stats); */ if (!(sbuf->optbits & USE_RX_RING)) { #if(HAVE_HUGEPAGES) if (sbuf->optbits & USE_HUGEPAGE) { //munmap(sbuf->buffer, sbuf->opt->packet_size*sbuf->opt->buf_num_elems); #ifdef MMAP_NOT_SHMGET munmap(be->buffer, sbuf->opt->filesize); #else char shmstring[FILENAME_MAX]; sprintf(shmstring, "%s%03d", SHMIDENT, sbuf->bufnum); shm_unlink(shmstring); close(sbuf->shmid); #endif } else #endif /* HAVE_HUGEPAGES */ free(be->buffer); } else D("Not freeing mem. Done in main"); if (pthread_mutex_destroy(&(be->self->waitlock)) != 0) E("Error in waitlock destroy"); if (pthread_cond_destroy(&(be->self->waitsig)) != 0) E("Error in waitsig destroy"); D("Freeing structs"); free(sbuf); //free(be); //free(be->recer); D("Simplebuf closed"); return 0; }
void (_exit)(int ex_code) { track_list *list; LOGTRACE(); if (track_hook__exit == NULL) T(init)(); /* We need to hook _exit() so that we can report leaks after * all the atexit() functions, which might release dynamic * memory. We cannot simply use atexit() for reporting since * there is no way to garantee we are executed last. * * NOTE sys/track.c and sys/malloc.c both hook _exit(), so * cannot be used together (yet). */ list = (track_list *)pthread_getspecific(thread_key); T(report)(list); (void) pthread_key_delete(thread_key); (void) LOCK_FREE(&lock); (*track_hook__exit)(ex_code); }