int sock_fd_init (void) { static int initialized = 0; if (sockets || handles) return (0); sockets = xmalloc (sizeof (SockSocket_t) * INC_SIZE); if (!sockets) return (DDS_RETCODE_OUT_OF_RESOURCES); handles = xmalloc (sizeof (SockHandle_t) * INC_SIZE); if (!handles) { xfree (sockets); return (DDS_RETCODE_OUT_OF_RESOURCES); } num_socks = 0; max_socks = INC_SIZE; num_handles = 0; max_handles = INC_SIZE; if (!initialized) { lock_init_nr (sock_lock, "sock"); lock_init_nr (poll_lock, "poll"); initialized = 1; } return (0); }
int sock_fd_init (void) { static int initialized = 0; if (fds) return (0); #if defined (NUTTX_RTOS) fds = malloc (sizeof (struct pollfd) * FD_INC_SIZE); fcts = malloc (sizeof (RSDATAFCT) * FD_INC_SIZE); ud = malloc (sizeof (void *) * FD_INC_SIZE); names = malloc (sizeof (const char *) * FD_INC_SIZE); #else fds = xmalloc (sizeof (struct pollfd) * FD_INC_SIZE); fcts = xmalloc (sizeof (RSDATAFCT) * FD_INC_SIZE); ud = xmalloc (sizeof (void *) * FD_INC_SIZE); names = xmalloc (sizeof (const char *) * FD_INC_SIZE); #endif if (!fds || !fcts || !ud || !names) return (1); atomic_set_w (num_fds, 0); atomic_set_w (max_fds, FD_INC_SIZE); if (!initialized) { lock_init_nr (sock_lock, "lock"); fd_max_size = config_get_number (DC_IP_Sockets, FD_MAX_SIZE); initialized = 1; } return (0); }
static void lock_init (void) { if (inits & LOCK_INIT) return; lock_init_nr (sp_lock, "Security Plugin Lock"); inits |= LOCK_INIT; }
int dds_cond_init (cond_t *cv) { int res; cv->waiters = 0; cv->was_broadcast = 0; res = DDS_RETCODE_OK; if (sema_init (cv->sema, 1)) res = 1; else if (lock_init_nr (cv->waiters_lock, NULL)) res = 1; else if (ev_init (cv->waiters_done)) res = 1; return (res); }
int locator_pool_init (const POOL_LIMITS *locrefs, const POOL_LIMITS *locators) { const char *env_str; if (mem_blocks [0].md_addr) { /* Was already initialized -- reset. */ mds_reset (mem_blocks, MB_END); return (LOC_OK); } if (!locrefs || !locrefs->reserved || !locators || !locators->reserved) return (LOC_ERR_PARAM); MDS_POOL_TYPE (mem_blocks, MB_LOCREF, *locrefs, sizeof (LocatorRef_t)); MDS_POOL_TYPE (mem_blocks, MB_LOCATOR, *locators, sizeof (LocatorNode_t)); /* Allocate all pools in one go. */ mem_size = mds_alloc (mem_blocks, mem_names, MB_END); #ifndef FORCE_MALLOC if (!mem_size) { warn_printf ("locator_pool_init: not enough memory available!\r\n"); return (LOC_ERR_NOMEM); } log_printf (LOC_ID, 0, "locator_pool_init: %lu bytes allocated for locators.\r\n", (unsigned long) mem_size); #endif sl_init (&loc_list, sizeof (LocatorNode_t *)); lock_init_nr (loc_lock, "Locators"); if ((env_str = config_get_string (DC_IP_NoMCast, NULL)) != NULL) { if (!*env_str || !strcmp (env_str, "any") || !strcmp (env_str, "ANY")) { loc_force_no_mcast = 1; loc_no_mcast = NULL; } else { loc_force_no_mcast = 0; loc_no_mcast = ip_filter_new (env_str, IPF_DOMAIN | IPF_MASK, 0); } } return (LOC_OK); }
void thread_init (void) { lock_init_nr (rclock, "RCLock"); }
void thread_init (void) { pthread_mutexattr_init (&recursive_mutex); pthread_mutexattr_settype (&recursive_mutex, PTHREAD_MUTEX_RECURSIVE_NP); lock_init_nr (rclock, "rclock"); }