static void l2tp_dmalloc_dump(void) { #ifdef L2TP_DMALLOC dmalloc_log_changed(l2tp_dmalloc_mark, 1, 0, 1); l2tp_dmalloc_mark = dmalloc_mark(); dmalloc_message("DMALLOC MARK set to %lu\n", l2tp_dmalloc_mark); #endif }
static void msg_req_dmalloc_log_changed(struct messaging_context *msg, void *private_data, uint32_t msg_type, struct server_id server_id, DATA_BLOB *data) { #ifdef ENABLE_DMALLOC dmalloc_log_changed(our_dm_mark, True, True, True); DEBUG(2,("Got MSG_REQ_DMALLOC_LOG_CHANGED: done\n")); #else DEBUG(2,("Got MSG_REQ_DMALLOC_LOG_CHANGED but dmalloc not in this process\n")); #endif }
static void l2tp_cleanup(void) { pid_t pid; pid = getpid(); if (pid != l2tp_my_pid) { L2TP_DEBUG(L2TP_FUNC, "%s: not main pid so returning now", __FUNCTION__); return; } l2tp_log(LOG_INFO, "Cleaning up before exiting"); usl_signal_notifier_remove(l2tp_signal_handler, NULL); /* Cleanup all resources */ l2tp_api_cleanup(); l2tp_net_cleanup(); l2tp_avp_cleanup(); l2tp_ppp_cleanup(); l2tp_session_cleanup(); l2tp_xprt_cleanup(); l2tp_tunnel_cleanup(); l2tp_peer_cleanup(); usl_timer_cleanup(); usl_fd_cleanup(); usl_signal_cleanup(); usl_pid_cleanup(); if (l2tp_rand_fd != 0) { close(l2tp_rand_fd); } L2TP_DEBUG(L2TP_FUNC, "%s: done", __FUNCTION__); #ifdef L2TP_DMALLOC dmalloc_log_changed(l2tp_dmalloc_mark, 1, 0, 1); // dmalloc_log_unfreed(); // dmalloc_log_stats(); // dmalloc_log_heap_map(); #endif /* Remove pid file */ unlink(L2TP_PID_FILENAME); }
int main( int argc, char **argv, char **envp ) { #ifdef DMALLOC unsigned long mark; #endif nbu_log_info("******************************************************"); nbu_log_info("* API - Build-Date: " __DATE__ " " __TIME__ " - User: "******" *"); nbu_log_info("******************************************************"); nbu_log_info(" \"Babes, bullets, bombs - Damn I love this job!\""); cgiwrap_init_std(argc, argv, envp); cgiwrap_init_emu( NULL, &ewf_fastcgi_read_cb, &ewf_fastcgi_writef_cb, &ewf_fastcgi_write_cb, NULL, NULL, NULL ); while ( ewf_fastcgi_accept( ) == EWF_SUCCESS ) { #ifdef DMALLOC /* get the current dmalloc position */ mark = dmalloc_mark( ); #endif nbu_log_debug("------------------------------------------"); api_begin( ); api_dispatch( ); api_end( ); #ifdef DMALLOC /* * log unfreed pointers that have been added to * the heap since mark */ dmalloc_log_changed( mark, 1 /* log unfreed pointers */ , 0 /* do not log freed pointers */ , 1 /* log each pnt otherwise summary */ ); #endif } return 0; }
int handle_command(char *buffer) { int rc = 1; char *op; int cmdtype; static unsigned long mark; if (ExtractArg(buffer, &op, &buffer) < 0) { return -1; } cmdtype = type_command(op); switch (cmdtype) { case COMMAND_GET: handle_get_command(buffer); break; case COMMAND_SET: handle_set_command(buffer); break; case COMMAND_RESET: handle_reset_command(buffer); break; case COMMAND_BYE: handle_bye_command(buffer); rc = 0; break; case COMMAND_CLI: handle_cli_command(buffer); break; case COMMAND_MEMSTART: #ifdef _DMALLOC_ dmalloc_message("starting new log"); mark = dmalloc_mark(); #elif _DBMALLOC_ if(malloc_chain_check(0)!=0) { int fd; fd = open("/usr/local/nextone/logs/malloc.inuse", O_CREAT|O_RDWR ); malloc_dump(fd ); close(fd); } orig_size = malloc_inuse(&histid1); #endif break; case COMMAND_MEMSTOP: #ifdef _DMALLOC_ dmalloc_log_changed(mark, 1, 0, 1); dmalloc_message("end of log"); #elif _DBMALLOC_ current_size = malloc_inuse(&histid2); if(current_size != orig_size) { int fd; fd = open("/usr/local/nextone/logs/malloc.inuse", O_CREAT|O_RDWR ); malloc_list(fd, histid1, histid2); close(fd); } #endif break; case COMMAND_NONE: default: break; } return rc; }