summaryrefslogtreecommitdiffstats
path: root/src/plugin.c
diff options
context:
space:
mode:
authorNalin Dahyabhai <nalin.dahyabhai@pobox.com>2008-04-18 14:21:30 -0400
committerNalin Dahyabhai <nalin.dahyabhai@pobox.com>2008-04-18 14:21:30 -0400
commit3570853eccd1784492f72fac88b2560c9d3b8703 (patch)
tree84060477ab93cea1abff529a5d1534d38a0153cf /src/plugin.c
parent2ddb773155d784323abb300240e4e0d97ae59ff3 (diff)
downloadslapi-nis-3570853eccd1784492f72fac88b2560c9d3b8703.tar.gz
slapi-nis-3570853eccd1784492f72fac88b2560c9d3b8703.tar.xz
slapi-nis-3570853eccd1784492f72fac88b2560c9d3b8703.zip
- initialize the map contents at startup, not init time
- fetch and set up the plugin identity earlier
Diffstat (limited to 'src/plugin.c')
-rw-r--r--src/plugin.c19
1 files changed, 10 insertions, 9 deletions
diff --git a/src/plugin.c b/src/plugin.c
index bf4e979..330fd02 100644
--- a/src/plugin.c
+++ b/src/plugin.c
@@ -35,7 +35,7 @@
/* the module initialization function */
static Slapi_PluginDesc
plugin_description = {
- .spd_id = "nis-plugin",
+ .spd_id = "nis-server",
.spd_vendor = "badvocacy.net",
.spd_version = PACKAGE_VERSION,
.spd_description = "NIS Server Plugin",
@@ -51,6 +51,11 @@ plugin_startup(Slapi_PBlock *pb)
slapi_pblock_get(pb, SLAPI_PLUGIN_PRIVATE, &state);
slapi_log_error(SLAPI_LOG_PLUGIN, plugin_description.spd_id,
"plugin starting\n");
+ /* Initialize the maps and data. */
+ map_init(state);
+ slapi_log_error(SLAPI_LOG_PLUGIN,
+ plugin_description.spd_id,
+ "initialized maps\n");
/* Register the listener sockets with the portmapper. */
if (state->pmap_client_socket != -1) {
for (i = 0; i < state->n_listeners; i++) {
@@ -112,7 +117,7 @@ plugin_shutdown(Slapi_PBlock *pb)
/* Handle the part of startup that needs to be done before we drop privileges:
* bind to listening ports. */
static int
-plugin_state_init(struct plugin_state **lstate)
+plugin_state_init(Slapi_PBlock *pb, struct plugin_state **lstate)
{
int sockfd = -1, err, i;
struct plugin_state *state = NULL;
@@ -129,6 +134,8 @@ plugin_state_init(struct plugin_state **lstate)
goto failed;
}
state->arena = arena;
+ state->plugin_desc = &plugin_description;
+ slapi_pblock_get(pb, SLAPI_PLUGIN_IDENTITY, &state->plugin_identity);
/* Create a socket for use in communicating with the portmapper. */
sockfd = socket(PF_INET, SOCK_DGRAM, 0);
@@ -230,10 +237,6 @@ plugin_state_init(struct plugin_state **lstate)
slapi_log_error(SLAPI_LOG_PLUGIN,
plugin_description.spd_id,
"set up %d listening sockets\n", state->n_listeners);
- map_init(state);
- slapi_log_error(SLAPI_LOG_PLUGIN,
- plugin_description.spd_id,
- "initialized maps\n");
*lstate = state;
return 0;
failed:
@@ -250,7 +253,7 @@ nis_plugin_init(Slapi_PBlock *pb)
{
struct plugin_state *state = NULL;
/* Allocate a memory pool and start listening for connections. */
- if (plugin_state_init(&state) == -1) {
+ if (plugin_state_init(pb, &state) == -1) {
slapi_log_error(SLAPI_LOG_PLUGIN, plugin_description.spd_id,
"error setting up plugin\n");
return -1;
@@ -260,8 +263,6 @@ nis_plugin_init(Slapi_PBlock *pb)
slapi_pblock_set(pb, SLAPI_PLUGIN_DESCRIPTION, &plugin_description);
slapi_pblock_set(pb, SLAPI_PLUGIN_START_FN, &plugin_startup);
slapi_pblock_set(pb, SLAPI_PLUGIN_CLOSE_FN, &plugin_shutdown);
- slapi_pblock_get(pb, SLAPI_PLUGIN_IDENTITY, &state->plugin_identity);
- state->plugin_desc = &plugin_description;
slapi_pblock_set(pb, SLAPI_PLUGIN_PRIVATE, state);
slapi_log_error(SLAPI_LOG_PLUGIN, state->plugin_desc->spd_id,
"registered plugin hooks\n");