#define PRINTF_ATTRIBUTE(a,b)
#endif /* HAVE_ATTRIBUTE_PRINTF_FORMAT */
+#ifdef HAVE_CONSTRUCTOR_ATTRIBUTE
+#define CONSTRUCTOR_ATTRIBUTE __attribute__ ((constructor))
+#else
+#define CONSTRUCTOR_ATTRIBUTE
+#endif /* HAVE_CONSTRUCTOR_ATTRIBUTE */
+
#ifdef HAVE_DESTRUCTOR_ATTRIBUTE
#define DESTRUCTOR_ATTRIBUTE __attribute__ ((destructor))
#else
static void nwrap_init(void);
static bool nwrap_gr_parse_line(struct nwrap_cache *nwrap, char *line);
static void nwrap_gr_unload(struct nwrap_cache *nwrap);
+void nwrap_constructor(void) CONSTRUCTOR_ATTRIBUTE;
void nwrap_destructor(void) DESTRUCTOR_ATTRIBUTE;
/*********************************************************
nwrap_initialized = true;
- /* Initialize pthread_atfork handlers */
- pthread_atfork(&nwrap_thread_prepare, &nwrap_thread_parent,
- &nwrap_thread_child);
-
env = getenv("NSS_WRAPPER_MAX_HOSTENTS");
if (env != NULL) {
max_hostents_tmp = (size_t)strtol(env, &endptr, 10);
return nwrap_gethostname(name, len);
}
+/****************************
+ * CONSTRUCTOR
+ ***************************/
+void nwrap_constructor(void)
+{
+ pthread_atfork(&nwrap_thread_prepare,
+ &nwrap_thread_parent,
+ &nwrap_thread_child);
+
+ /*
+ * Here is safe place to call nwrap_init() and initialize data
+ * for the main process.
+ */
+ nwrap_init();
+}
+
/****************************
* DESTRUCTOR
***************************/