Exemplo n.º 1
0
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
}
Exemplo n.º 2
0
/**
 * Respond to a POOL_USAGE message by sending back string form of memory
 * usage stats.
 **/
static void msg_req_dmalloc_mark(struct messaging_context *msg,
				 void *private_data,
				 uint32_t msg_type,
				 struct server_id server_id,
				 DATA_BLOB *data)
{
#ifdef ENABLE_DMALLOC
	our_dm_mark = dmalloc_mark();
	DEBUG(2,("Got MSG_REQ_DMALLOC_MARK: mark set\n"));
#else
	DEBUG(2,("Got MSG_REQ_DMALLOC_MARK but dmalloc not in this process\n"));
#endif
}
Exemplo n.º 3
0
static void l2tp_init(void)
{
    l2tp_log(LOG_INFO, "started");
#ifdef L2TP_DMALLOC
    /* dmalloc debug options are set in the environment. However,
     * certain options cause problems to this application. We
     * therefore ensure that the troublesome options are disabled,
     * regardless of the user's settings.  The disabled options
     * are: alloc-blank, free-blank, force-linear.  If these
     * options are enabled, it causes strange problems in the
     * generated RPC code.
     */
    dmalloc_debug(dmalloc_debug_current() & 0xff5dffff);
    l2tp_dmalloc_mark = dmalloc_mark();
    if (getenv("DMALLOC_OPTIONS") != NULL) {
        l2tp_log(LOG_WARNING, "DMALLOC debugging enabled");
    }
#endif
    l2tp_my_pid = getpid();

    atexit(l2tp_cleanup);
    L2TP_DEBUG(L2TP_FUNC, "%s (%s %s): trace flags = %08lx", __FUNCTION__, __DATE__, __TIME__, l2tp_opt_trace_flags);
    usl_set_debug(l2tp_opt_debug, l2tp_system_log);

    usl_signal_terminate_hook = l2tp_die;
    usl_signal_init();
    usl_fd_init();
    usl_timer_init();
    usl_pid_init();
    l2tp_net_init();

    l2tp_rand_fd = open("/dev/random", O_RDONLY);
    if (l2tp_rand_fd < 0) {
        fprintf(stderr, "No /dev/random device found. Exiting.\n");
        exit(1);
    }

    usl_signal_notifier_add(l2tp_signal_handler, NULL);

    l2tp_avp_init();
    l2tp_peer_init();
    l2tp_api_init();
    l2tp_xprt_init();
    l2tp_tunnel_init();
    l2tp_session_init();
    l2tp_ppp_init();
}
Exemplo n.º 4
0
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;
}
Exemplo n.º 5
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;
}