void main_init() { /* one-time initialization */ #ifdef USE_SYSTEMD int i; systemd_fds=sd_listen_fds(1); if(systemd_fds<0) fatal("systemd initialization failed"); listen_fds_start=SD_LISTEN_FDS_START; /* set non-blocking mode on systemd file descriptors */ for(i=0; i<systemd_fds; ++i) set_nonblock(listen_fds_start+i, 1); #else systemd_fds=0; /* no descriptors received */ listen_fds_start=3; /* the value is not really important */ #endif /* basic initialization contains essential functions required for logging * subsystem to function properly, thus all errors here are fatal */ if(ssl_init()) /* initialize SSL library */ fatal("SSL initialization failed"); if(sthreads_init()) /* initialize critical sections & SSL callbacks */ fatal("Threads initialization failed"); if(cron_init()) /* initialize periodic events */ fatal("Cron initialization failed"); options_defaults(); options_apply(); #ifndef USE_FORK get_limits(); /* required by setup_fd() */ #endif fds=s_poll_alloc(); if(signal_pipe_init()) fatal("Signal pipe initialization failed: " "check your personal firewall"); stunnel_info(LOG_NOTICE); }
int is_smallest(t_node *src, t_node *cmp) { src = get_limits(src, 0); if (src && cmp && src->data > cmp->data) return (1); return (0); }
void box_rep::find_limits (path bp, point& lim1, point& lim2) { box b= this; get_limits (lim1, lim2); while (!is_nil (bp)) { point slim1, slim2; b = b->subbox (bp->item); bp = bp->next; b->get_limits (slim1, slim2); if (slim1 != point ()) { lim1= slim1; lim2= slim2; } } }
void main_initialize() { /* one-time initialization */ /* basic initialization contains essential functions required for logging * subsystem to function properly, thus all errors here are fatal */ if(ssl_init()) /* initialize SSL library */ fatal("SSL initialization failed"); if(sthreads_init()) /* initialize critical sections & SSL callbacks */ fatal("Threads initialization failed"); #ifndef USE_FORK get_limits(); /* required by setup_fd() */ #endif fds=s_poll_alloc(); if(signal_pipe_init()) fatal("Signal pipe initialization failed: " "check your personal firewall"); stunnel_info(LOG_NOTICE); }
static void fill_coord(t_fdf *fdf, char *nbr, int i, int j) { int alph; t_coord *e; e = fdf->tab[i] + j; e->pt.x = j; e->pt.y = ft_atoi(nbr); e->pt.z = i; e->end = 1; alph = 1 - e->pt.x - e->pt.y - e->pt.z; e->pos.x = e->pt.x * fdf->base.i.pos.x + e->pt.y * fdf->base.j.pos.x + e->pt.z * fdf->base.k.pos.x + fdf->base.o.pos.x * alph; e->pos.y = e->pt.x * fdf->base.i.pos.y + e->pt.y * fdf->base.j.pos.y + e->pt.z * fdf->base.k.pos.y + fdf->base.o.pos.y * alph; get_limits(e, fdf); }
static void daemon_loop(void) { SOCKADDR_UNION addr; s_poll_set fds; LOCAL_OPTIONS *opt; get_limits(); s_poll_zero(&fds); #ifndef USE_WIN32 s_poll_add(&fds, signal_pipe_init(), 1, 0); #endif if(!local_options.next) { s_log(LOG_ERR, "No connections defined in config file"); exit(1); } num_clients=0; /* bind local ports */ for(opt=local_options.next; opt; opt=opt->next) { if(!opt->option.accept) /* no need to bind this service */ continue; memcpy(&addr, &opt->local_addr.addr[0], sizeof(SOCKADDR_UNION)); if((opt->fd=socket(addr.sa.sa_family, SOCK_STREAM, 0))<0) { sockerror("local socket"); exit(1); } if(alloc_fd(opt->fd)) exit(1); if(set_socket_options(opt->fd, 0)<0) exit(1); s_ntop(opt->local_address, &addr); if(bind(opt->fd, &addr.sa, addr_len(addr))) { s_log(LOG_ERR, "Error binding %s to %s", opt->servname, opt->local_address); sockerror("bind"); exit(1); } s_log(LOG_DEBUG, "%s bound to %s", opt->servname, opt->local_address); if(listen(opt->fd, 5)) { sockerror("listen"); exit(1); } #ifdef FD_CLOEXEC fcntl(opt->fd, F_SETFD, FD_CLOEXEC); /* close socket in child execvp */ #endif s_poll_add(&fds, opt->fd, 1, 0); } #if !defined (USE_WIN32) && !defined (__vms) if(!(options.option.foreground)) daemonize(); drop_privileges(); create_pid(); #endif /* !defined USE_WIN32 && !defined (__vms) */ /* create exec+connect services */ for(opt=local_options.next; opt; opt=opt->next) { if(opt->option.accept) /* skip ordinary (accepting) services */ continue; enter_critical_section(CRIT_CLIENTS); /* for multi-cpu machines */ num_clients++; leave_critical_section(CRIT_CLIENTS); create_client(-1, -1, alloc_client_session(opt, -1, -1), client); } while(1) { if(s_poll_wait(&fds, -1)<0) /* non-critical error */ log_error(LOG_INFO, get_last_socket_error(), "daemon_loop: s_poll_wait"); else for(opt=local_options.next; opt; opt=opt->next) if(s_poll_canread(&fds, opt->fd)) accept_connection(opt); } s_log(LOG_ERR, "INTERNAL ERROR: End of infinite loop 8-)"); }