static void _new(ContextInfoDB *self) { self->data = g_array_new(FALSE, FALSE, sizeof(ContextualDataRecord)); self->index = g_hash_table_new_full(g_str_hash, g_str_equal, NULL, g_free); self->is_data_indexed = FALSE; g_atomic_counter_set(&self->ref_cnt, 1); }
void log_queue_init_instance(LogQueue *self, const gchar *persist_name) { g_atomic_counter_set(&self->ref_cnt, 1); self->free_fn = log_queue_free_method; self->persist_name = persist_name ? g_strdup(persist_name) : NULL; g_static_mutex_init(&self->lock); }
void log_pipe_init_instance(LogPipe *self) { g_atomic_counter_set(&self->ref_cnt, 1); self->pipe_next = NULL; self->queue = log_pipe_forward_msg; self->free_fn = log_pipe_free_method; /* self->notify = log_pipe_forward_notify; */ }
void log_source_init_instance(LogSource *self, GlobalConfig *cfg) { log_pipe_init_instance(&self->super, cfg); self->super.queue = log_source_queue; self->super.free_fn = log_source_free; self->super.init = log_source_init; self->super.deinit = log_source_deinit; g_atomic_counter_set(&self->window_size, -1); self->ack_tracker = NULL; }
/*+ Allocate and initialize a GSockAddrUnix instance, using libc sockaddr_un strucutre. Parameters: saun sockaddr_un structure to convert sunlen size of saun Returns: the new instance +*/ GSockAddr * g_sockaddr_unix_new2(struct sockaddr_un *saun, int sunlen) { GSockAddrUnix *addr = g_new0(GSockAddrUnix, 1); g_atomic_counter_set(&addr->refcnt, 1); addr->flags = 0; addr->sa_funcs = &unix_sockaddr_funcs; addr->salen = sunlen; addr->saun = *saun; return (GSockAddr *) addr; }
/*+ Allocate and initialize an IPv6 socket address using libc sockaddr * structure. Parameters: sin the sockaddr_in6 structure to convert Returns: the allocated instance. +*/ GSockAddr * g_sockaddr_inet6_new2(struct sockaddr_in6 *sin6) { GSockAddrInet6 *addr = g_slice_new0(GSockAddrInet6); g_atomic_counter_set(&addr->refcnt, 1); addr->flags = 0; addr->salen = sizeof(struct sockaddr_in6); addr->sin6 = *sin6; addr->sa_funcs = &inet6_sockaddr_funcs; return (GSockAddr *) addr; }
/*+ Allocate and initialize an IPv4 socket address using libc sockaddr * structure. Parameters: sin the sockaddr_in structure to convert Returns: the allocated instance. +*/ GSockAddr * g_sockaddr_inet_new2(struct sockaddr_in *sin) { GSockAddrInet *self = g_slice_new0(GSockAddrInet); g_atomic_counter_set(&self->refcnt, 1); self->flags = 0; self->salen = sizeof(struct sockaddr_in); self->sin = *sin; self->sa_funcs = &inet_sockaddr_funcs; return (GSockAddr *) self; }
/*+ Allocate and initialize an IPv4 socket address using libc sockaddr * structure. Parameters: sin the sockaddr_in structure to convert Returns: the allocated instance. +*/ GSockAddr * g_sockaddr_inet_new2(struct sockaddr_in *sin) { GSockAddrInet *addr = g_new0(GSockAddrInet, 1); g_atomic_counter_set(&addr->refcnt, 1); addr->flags = 0; addr->salen = sizeof(struct sockaddr_in); addr->sin = *sin; addr->sa_funcs = &inet_sockaddr_funcs; return (GSockAddr *) addr; }
void log_pipe_init_instance(LogPipe *self) { g_atomic_counter_set(&self->ref_cnt, 1); self->pipe_next = NULL; /* NOTE: queue == NULL means that this pipe simply forwards the * message along the pipeline, e.g. like it has called * log_msg_forward_msg. Since this is a common case, it is better * inlined (than to use an indirect call) for performance. */ self->queue = NULL; self->free_fn = log_pipe_free_method; }
/*+ Allocate and initialize an IPv6 socket address. Parameters: ip text representation of an IP address port port number in host byte order Returns: the new instance +*/ GSockAddr * g_sockaddr_inet6_new(const gchar *ip, guint16 port) { GSockAddrInet6 *addr = g_slice_new0(GSockAddrInet6); g_atomic_counter_set(&addr->refcnt, 1); addr->flags = 0; addr->salen = sizeof(struct sockaddr_in6); addr->sin6.sin6_family = AF_INET6; inet_pton(AF_INET6, ip, &addr->sin6.sin6_addr); addr->sin6.sin6_port = htons(port); addr->sa_funcs = &inet6_sockaddr_funcs; return (GSockAddr *) addr; }
/*+ Allocate and initialize an IPv4 socket address. Parameters: ip text representation of an IP address port port number in host byte order Returns: the new instance +*/ GSockAddr * g_sockaddr_inet_new(const gchar *ip, guint16 port) { GSockAddrInet *self = NULL; struct in_addr ina; if (inet_aton(ip, &ina)) { self = g_slice_new0(GSockAddrInet); g_atomic_counter_set(&self->refcnt, 1); self->flags = 0; self->salen = sizeof(struct sockaddr_in); self->sin.sin_family = AF_INET; self->sin.sin_port = htons(port); self->sin.sin_addr = ina; self->sa_funcs = &inet_sockaddr_funcs; } return (GSockAddr *) self; }
/*+ Allocate and initialize an IPv4 socket address. Parameters: ip text representation of an IP address port port number in host byte order Returns: the new instance +*/ GSockAddr * g_sockaddr_inet_new(gchar *ip, guint16 port) { GSockAddrInet *addr = NULL; struct in_addr ina; if (inet_aton(ip, &ina)) { addr = g_new0(GSockAddrInet, 1); g_atomic_counter_set(&addr->refcnt, 1); addr->flags = 0; addr->salen = sizeof(struct sockaddr_in); addr->sin.sin_family = AF_INET; addr->sin.sin_port = htons(port); addr->sin.sin_addr = ina; addr->sa_funcs = &inet_sockaddr_funcs; } return (GSockAddr *) addr; }
GSockAddr * g_sockaddr_inet_range_new(gchar *ip, guint16 min_port, guint16 max_port) { GSockAddrInetRange *addr = g_new0(GSockAddrInetRange, 1); g_atomic_counter_set(&addr->refcnt, 1); addr->flags = 0; addr->salen = sizeof(struct sockaddr_in); addr->sin.sin_family = AF_INET; inet_aton(ip, &addr->sin.sin_addr); addr->sin.sin_port = 0; addr->sa_funcs = &inet_range_sockaddr_funcs; if (max_port > min_port) { addr->last_port = (rand() % (max_port - min_port)) + min_port; } addr->min_port = min_port; addr->max_port = max_port; return (GSockAddr *) addr; }
void log_source_set_options(LogSource *self, LogSourceOptions *options, gint stats_level, gint stats_source, const gchar *stats_id, const gchar *stats_instance, gboolean threaded, gboolean pos_tracked) { /* NOTE: we don't adjust window_size even in case it was changed in the * configuration and we received a SIGHUP. This means that opened * connections will not have their window_size changed. */ if (g_atomic_counter_get(&self->window_size) == -1) g_atomic_counter_set(&self->window_size, options->init_window_size); self->options = options; self->stats_level = stats_level; self->stats_source = stats_source; if (self->stats_id) g_free(self->stats_id); self->stats_id = stats_id ? g_strdup(stats_id) : NULL; if (self->stats_instance) g_free(self->stats_instance); self->stats_instance = stats_instance ? g_strdup(stats_instance): NULL; self->threaded = threaded; self->pos_tracked = pos_tracked; _create_ack_tracker_if_not_exists(self, pos_tracked); }
/*+ Allocate and initialize a GSockAddrUnix instance. Parameters: name socket filename Returns: the new instance +*/ GSockAddr * g_sockaddr_unix_new(const gchar *name) { GSockAddrUnix *addr = g_new0(GSockAddrUnix, 1); g_atomic_counter_set(&addr->refcnt, 1); addr->flags = 0; addr->sa_funcs = &unix_sockaddr_funcs; addr->saun.sun_family = AF_UNIX; if (name) { strncpy(addr->saun.sun_path, name, sizeof(addr->saun.sun_path) - 1); addr->saun.sun_path[sizeof(addr->saun.sun_path) - 1] = 0; addr->salen = sizeof(addr->saun) - sizeof(addr->saun.sun_path) + strlen(addr->saun.sun_path) + 1; } else { addr->saun.sun_path[0] = 0; addr->salen = 2; } return (GSockAddr *) addr; }