Пример #1
0
void cfg_cleanup(cfg_s *cfg)
{
	int i;

	for (i = 0; i < CFG_IEND; i++)
	{
		str_cleanup(&cfg->ints[i].key);
	}

	for (i = 0; i < CFG_SEND; i++)
	{
		str_cleanup(&cfg->strs[i].key);
		str_cleanup(&cfg->strs[i].val);		
	}
}
Пример #2
0
void client_main(CLI *c) {
    s_log(LOG_DEBUG, "Service [%s] started", c->opt->servname);
    if(c->opt->option.program && c->opt->option.remote) {
            /* exec and connect options specified together
             * -> spawn a local program instead of stdio */
        for(;;) {
            SERVICE_OPTIONS *opt=c->opt;
            memset(c, 0, sizeof(CLI)); /* connect_local needs clean c */
            c->opt=opt;
            if(!setjmp(c->err))
                c->local_rfd.fd=c->local_wfd.fd=connect_local(c);
            else
                break;
            client_run(c);
            if(!c->opt->option.retry)
                break;
            sleep(1); /* FIXME: not a good idea in ucontext threading */
            str_stats();
            if(service_options.next) /* don't str_cleanup in inetd mode */
                str_cleanup();
        }
    } else
        client_run(c);
    str_free(c);
}
Пример #3
0
/* per-thread thread-local storage cleanup */
void tls_cleanup() {
    TLS_DATA *tls_data;

    tls_data=tls_get();
    if(!tls_data)
        return;
    str_cleanup(tls_data);
    str_free(tls_data->id); /* detached allocation */
    tls_set(NULL);
    free(tls_data);
}
Пример #4
0
void *client(void *arg) {
    CLI *c=arg;

#ifdef DEBUG_STACK_SIZE
    stack_info(1); /* initialize */
#endif
    s_log(LOG_DEBUG, "Service %s started", c->opt->servname);
    if(c->opt->option.remote && c->opt->option.program) {
            /* connect and exec options specified together */
            /* -> spawn a local program instead of stdio */
        while((c->local_rfd.fd=c->local_wfd.fd=connect_local(c))>=0) {
            run_client(c);
            if(!c->opt->option.retry)
                break;
            sleep(1); /* FIXME: not a good idea in ucontext threading */
            str_stats();
            str_cleanup();
        }
    } else
        run_client(c);
    /* str_free() cannot be used here, because corresponding
       calloc() is called from a different thread */
    free(c);
#ifdef DEBUG_STACK_SIZE
    stack_info(0); /* display computed value */
#endif
#ifdef USE_UCONTEXT
    s_log(LOG_DEBUG, "Context %ld closed", ready_head->id);
#endif
    str_stats();
    str_cleanup();
    /* s_log() is not allowed after str_cleanup() */
#if defined(USE_WIN32) && !defined(_WIN32_WCE)
    _endthread();
#endif
#ifdef USE_UCONTEXT
    s_poll_wait(NULL, 0, 0); /* wait on poll() */
#endif
    return NULL;
}
Пример #5
0
void *client_thread(void *arg)
{
	CLI *c = arg;

#ifdef DEBUG_STACK_SIZE
	stack_info(1);		
#endif
	client_main(c);
#ifdef DEBUG_STACK_SIZE
	stack_info(0);		
#endif
	str_stats();
	str_cleanup();
	
	return NULL;
}
Пример #6
0
void *client_thread(void *arg) {
    CLI *c=arg;

#ifdef DEBUG_STACK_SIZE
    stack_info(1); /* initialize */
#endif
    client_main(c);
#ifdef DEBUG_STACK_SIZE
    stack_info(0); /* display computed value */
#endif
    str_stats();
    str_cleanup();
    /* s_log() is not allowed after str_cleanup() */
#if defined(USE_WIN32) && !defined(_WIN32_WCE)
    _endthread();
#endif
#ifdef USE_UCONTEXT
    s_poll_wait(NULL, 0, 0); /* wait on poll() */
#endif
    return NULL;
}
Пример #7
0
void serialinfo_cleanup(serialinfo_s *sinfo)
{
	str_cleanup(&sinfo->device);
}