Просмотр исходного кода

ncd: NCDModule: don't store a pointer to struct NCDModuleInst_iparams in NCDModuleInst. Instead, store it in struct
NCDModuleInst_params, to save memory.

ambrop7 13 лет назад
Родитель
Сommit
a3ea934a96

+ 10 - 11
ncd/NCDModule.c

@@ -68,7 +68,7 @@ static void inst_assert_backend (NCDModuleInst *n)
            n->state == STATE_DYING)
 }
 
-void NCDModuleInst_Init (NCDModuleInst *n, const struct NCDModule *m, void *mem, const NCDObject *method_object, NCDValRef args, const struct NCDModuleInst_params *params, const struct NCDModuleInst_iparams *iparams)
+void NCDModuleInst_Init (NCDModuleInst *n, const struct NCDModule *m, void *mem, const NCDObject *method_object, NCDValRef args, const struct NCDModuleInst_params *params)
 {
     ASSERT(m)
     ASSERT(m->func_new2)
@@ -79,16 +79,15 @@ void NCDModuleInst_Init (NCDModuleInst *n, const struct NCDModule *m, void *mem,
     ASSERT(params->func_event)
     ASSERT(params->func_getobj)
     ASSERT(params->logfunc)
-    ASSERT(iparams)
-    ASSERT(iparams->func_initprocess)
-    ASSERT(iparams->func_interp_exit)
-    ASSERT(iparams->func_interp_getargs)
-    ASSERT(iparams->func_interp_getretrytime)
+    ASSERT(params->iparams)
+    ASSERT(params->iparams->func_initprocess)
+    ASSERT(params->iparams->func_interp_exit)
+    ASSERT(params->iparams->func_interp_getargs)
+    ASSERT(params->iparams->func_interp_getretrytime)
     
     // init arguments
     n->m = m;
     n->params = params;
-    n->iparams = iparams;
     
     // set initial instance argument
     n->inst_user = mem;
@@ -295,7 +294,7 @@ void NCDModuleInst_Backend_InterpExit (NCDModuleInst *n, int exit_code)
     DebugObject_Access(&n->d_obj);
     inst_assert_backend(n);
     
-    n->iparams->func_interp_exit(exit_code);
+    n->params->iparams->func_interp_exit(exit_code);
 }
 
 int NCDModuleInst_Backend_InterpGetArgs (NCDModuleInst *n, NCDValMem *mem, NCDValRef *out_value)
@@ -305,7 +304,7 @@ int NCDModuleInst_Backend_InterpGetArgs (NCDModuleInst *n, NCDValMem *mem, NCDVa
     ASSERT(mem)
     ASSERT(out_value)
     
-    int res = n->iparams->func_interp_getargs(mem, out_value);
+    int res = n->params->iparams->func_interp_getargs(mem, out_value);
     ASSERT(res == 0 || res == 1)
     ASSERT(res == 0 || (NCDVal_Assert(*out_value), 1))
     
@@ -317,7 +316,7 @@ btime_t NCDModuleInst_Backend_InterpGetRetryTime (NCDModuleInst *n)
     DebugObject_Access(&n->d_obj);
     inst_assert_backend(n);
     
-    return n->iparams->func_interp_getretrytime();
+    return n->params->iparams->func_interp_getretrytime();
 }
 
 int NCDModuleProcess_Init (NCDModuleProcess *o, NCDModuleInst *n, const char *template_name, NCDValRef args, void *user, NCDModuleProcess_handler_event handler_event)
@@ -346,7 +345,7 @@ int NCDModuleProcess_Init (NCDModuleProcess *o, NCDModuleInst *n, const char *te
     o->interp_func_getobj = NULL;
     
     // init interpreter part
-    if (!(n->iparams->func_initprocess(o, template_name))) {
+    if (!(n->params->iparams->func_initprocess(o, template_name))) {
         goto fail1;
     }
     

+ 9 - 5
ncd/NCDModule.h

@@ -251,8 +251,9 @@ struct NCDModuleInst_new_params {
 
 /**
  * Contains parameters to {@link NCDModuleInst_Init} that are passed indirectly.
- * This only contains parameters related to communication between the backend
- * and the creator of the module instance.
+ * This itself only contains parameters related to communication between the
+ * backend and the creator of the module instance; other parameters are passed
+ * via the iparams member;
  */
 struct NCDModuleInst_params {
     /**
@@ -267,6 +268,11 @@ struct NCDModuleInst_params {
      * Log function which appends a log prefix with {@link BLog_Append}.
      */
     BLog_logfunc logfunc;
+    /**
+     * Pointer to an {@link NCDModuleInst_iparams} structure, which exposes
+     * services provided by the interpreter.
+     */
+    const struct NCDModuleInst_iparams *iparams;
 };
 
 /**
@@ -317,7 +323,6 @@ struct NCDModuleInst_iparams {
 typedef struct NCDModuleInst_s {
     const struct NCDModule *m;
     const struct NCDModuleInst_params *params;
-    const struct NCDModuleInst_iparams *iparams;
     void *inst_user;
     int state;
     int is_error;
@@ -361,9 +366,8 @@ typedef struct NCDModuleProcess_s {
  *             as long as the instance exists.
  * @param user argument to callback functions
  * @param params more parameters, see {@link NCDModuleInst_params}
- * @param iparams more parameters, see {@link NCDModuleInst_iparams}
  */
-void NCDModuleInst_Init (NCDModuleInst *n, const struct NCDModule *m, void *mem, const NCDObject *method_object, NCDValRef args, const struct NCDModuleInst_params *params, const struct NCDModuleInst_iparams *iparams);
+void NCDModuleInst_Init (NCDModuleInst *n, const struct NCDModule *m, void *mem, const NCDObject *method_object, NCDValRef args, const struct NCDModuleInst_params *params);
 
 /**
  * Frees the instance.

+ 2 - 2
ncd/modules/command_template.c

@@ -50,7 +50,7 @@ static void lock_handler (command_template_instance *o)
     
     if (o->state == STATE_ADDING_LOCK) {
         // start process
-        if (!BProcess_Init(&o->process, o->i->iparams->manager, (BProcess_handler)process_handler, o, o->do_exec, CmdLine_Get(&o->do_cmdline), NULL)) {
+        if (!BProcess_Init(&o->process, o->i->params->iparams->manager, (BProcess_handler)process_handler, o, o->do_exec, CmdLine_Get(&o->do_cmdline), NULL)) {
             NCDModuleInst_Backend_Log(o->i, o->blog_channel, BLOG_ERROR, "BProcess_Init failed");
             free_template(o, 1);
             return;
@@ -60,7 +60,7 @@ static void lock_handler (command_template_instance *o)
         o->state = STATE_ADDING;
     } else {
         // start process
-        if (!BProcess_Init(&o->process, o->i->iparams->manager, (BProcess_handler)process_handler, o, o->undo_exec, CmdLine_Get(&o->undo_cmdline), NULL)) {
+        if (!BProcess_Init(&o->process, o->i->params->iparams->manager, (BProcess_handler)process_handler, o, o->undo_exec, CmdLine_Get(&o->undo_cmdline), NULL)) {
             NCDModuleInst_Backend_Log(o->i, o->blog_channel, BLOG_ERROR, "BProcess_Init failed");
             free_template(o, 1);
             return;

+ 4 - 4
ncd/modules/daemon.c

@@ -152,7 +152,7 @@ static void start_process (struct instance *o)
     }
     
     // start process
-    int res = BProcess_Init(&o->process, o->i->iparams->manager, (BProcess_handler)process_handler, o, exec, CmdLine_Get(&cl), NULL);
+    int res = BProcess_Init(&o->process, o->i->params->iparams->manager, (BProcess_handler)process_handler, o, exec, CmdLine_Get(&cl), NULL);
     CmdLine_Free(&cl);
     free(exec);
     
@@ -167,7 +167,7 @@ static void start_process (struct instance *o)
     
 fail:
     // start timer
-    BReactor_SetTimer(o->i->iparams->reactor, &o->timer);
+    BReactor_SetTimer(o->i->params->iparams->reactor, &o->timer);
     
     // set state retrying
     o->state = STATE_RETRYING;
@@ -198,7 +198,7 @@ static void process_handler (struct instance *o, int normally, uint8_t normally_
     BLog(BLOG_ERROR, "daemon crashed");
     
     // start timer
-    BReactor_SetTimer(o->i->iparams->reactor, &o->timer);
+    BReactor_SetTimer(o->i->params->iparams->reactor, &o->timer);
     
     // set state retrying
     o->state = STATE_RETRYING;
@@ -233,7 +233,7 @@ fail0:
 static void instance_free (struct instance *o)
 {
     // free timer
-    BReactor_RemoveTimer(o->i->iparams->reactor, &o->timer);
+    BReactor_RemoveTimer(o->i->params->iparams->reactor, &o->timer);
     
     NCDModuleInst_Backend_Dead(o->i);
 }

+ 3 - 3
ncd/modules/foreach.c

@@ -180,7 +180,7 @@ static void work (struct instance *o)
     assert_state(o);
     
     // stop timer
-    BReactor_RemoveTimer(o->i->iparams->reactor, &o->timer);
+    BReactor_RemoveTimer(o->i->params->iparams->reactor, &o->timer);
     
     if (o->state == ISTATE_WAITING) {
         return;
@@ -282,7 +282,7 @@ static void advance (struct instance *o)
     
 fail:
     // set timer
-    BReactor_SetTimer(o->i->iparams->reactor, &o->timer);
+    BReactor_SetTimer(o->i->params->iparams->reactor, &o->timer);
 }
 
 static void timer_handler (struct instance *o)
@@ -642,7 +642,7 @@ static void instance_free (struct instance *o)
     BFree(o->elems);
     
     // free timer
-    BReactor_RemoveTimer(o->i->iparams->reactor, &o->timer);
+    BReactor_RemoveTimer(o->i->params->iparams->reactor, &o->timer);
     
     NCDModuleInst_Backend_Dead(o->i);
 }

+ 2 - 2
ncd/modules/imperative.c

@@ -117,7 +117,7 @@ static void go_deinit (struct instance *o)
     }
     
     // start timer
-    BReactor_SetTimer(o->i->iparams->reactor, &o->deinit_timer);
+    BReactor_SetTimer(o->i->params->iparams->reactor, &o->deinit_timer);
     
     // set state deinit working
     o->state = STATE_DEINIT_WORKING;
@@ -168,7 +168,7 @@ static void deinit_process_handler_event (struct instance *o, int event)
             ASSERT(o->state == STATE_DEINIT_WORKING)
             
             // stop timer
-            BReactor_RemoveTimer(o->i->iparams->reactor, &o->deinit_timer);
+            BReactor_RemoveTimer(o->i->params->iparams->reactor, &o->deinit_timer);
             
             // start terminating
             NCDModuleProcess_Terminate(&o->process);

+ 4 - 4
ncd/modules/net_backend_badvpn.c

@@ -95,7 +95,7 @@ void try_process (struct instance *o)
     }
     
     // start process
-    if (!BProcess_Init(&o->process, o->i->iparams->manager, (BProcess_handler)process_handler, o, ((char **)c.arr.v)[0], (char **)c.arr.v, o->user)) {
+    if (!BProcess_Init(&o->process, o->i->params->iparams->manager, (BProcess_handler)process_handler, o, ((char **)c.arr.v)[0], (char **)c.arr.v, o->user)) {
         ModuleLog(o->i, BLOG_ERROR, "BProcess_Init failed");
         goto fail1;
     }
@@ -112,7 +112,7 @@ fail1:
 fail0:
     // retry
     o->started = 0;
-    BReactor_SetTimer(o->i->iparams->reactor, &o->timer);
+    BReactor_SetTimer(o->i->params->iparams->reactor, &o->timer);
 }
 
 void process_handler (struct instance *o, int normally, uint8_t normally_exit_status)
@@ -133,7 +133,7 @@ void process_handler (struct instance *o, int normally, uint8_t normally_exit_st
     }
     
     // set timer
-    BReactor_SetTimer(o->i->iparams->reactor, &o->timer);
+    BReactor_SetTimer(o->i->params->iparams->reactor, &o->timer);
 }
 
 void timer_handler (struct instance *o)
@@ -219,7 +219,7 @@ void instance_free (struct instance *o)
     ASSERT(!o->started)
     
     // free timer
-    BReactor_RemoveTimer(o->i->iparams->reactor, &o->timer);
+    BReactor_RemoveTimer(o->i->params->iparams->reactor, &o->timer);
     
     // set device down
     if (!NCDIfConfig_set_down(o->ifname)) {

+ 1 - 1
ncd/modules/net_backend_rfkill.c

@@ -167,7 +167,7 @@ static void func_new (void *vo, NCDModuleInst *i, const struct NCDModuleInst_new
     }
     
     // init monitor
-    if (!NCDRfkillMonitor_Init(&o->monitor, o->i->iparams->reactor, (NCDRfkillMonitor_handler)monitor_handler, o)) {
+    if (!NCDRfkillMonitor_Init(&o->monitor, o->i->params->iparams->reactor, (NCDRfkillMonitor_handler)monitor_handler, o)) {
         ModuleLog(o->i, BLOG_ERROR, "monitor failed");
         goto fail0;
     }

+ 3 - 3
ncd/modules/net_backend_waitdevice.c

@@ -60,7 +60,7 @@ struct instance {
 
 static void client_handler (struct instance *o, char *devpath, int have_map, BStringMap map)
 {
-    if (o->devpath && !strcmp(devpath, o->devpath) && !NCDUdevManager_Query(o->i->iparams->umanager, o->devpath)) {
+    if (o->devpath && !strcmp(devpath, o->devpath) && !NCDUdevManager_Query(o->i->params->iparams->umanager, o->devpath)) {
         // free devpath
         free(o->devpath);
         
@@ -70,7 +70,7 @@ static void client_handler (struct instance *o, char *devpath, int have_map, BSt
         // signal down
         NCDModuleInst_Backend_Down(o->i);
     } else {
-        const BStringMap *cache_map = NCDUdevManager_Query(o->i->iparams->umanager, devpath);
+        const BStringMap *cache_map = NCDUdevManager_Query(o->i->params->iparams->umanager, devpath);
         if (!cache_map) {
             goto out;
         }
@@ -133,7 +133,7 @@ static void func_new (void *vo, NCDModuleInst *i, const struct NCDModuleInst_new
     o->ifname = NCDVal_StringValue(arg);
     
     // init client
-    NCDUdevClient_Init(&o->client, o->i->iparams->umanager, o, (NCDUdevClient_handler)client_handler);
+    NCDUdevClient_Init(&o->client, o->i->params->iparams->umanager, o, (NCDUdevClient_handler)client_handler);
     
     // compile regex
     if (regcomp(&o->reg, DEVPATH_REGEX, REG_EXTENDED)) {

+ 1 - 1
ncd/modules/net_backend_waitlink.c

@@ -101,7 +101,7 @@ static void func_new (void *vo, NCDModuleInst *i, const struct NCDModuleInst_new
     }
     
     // init monitor
-    if (!NCDInterfaceMonitor_Init(&o->monitor, ifindex, NCDIFMONITOR_WATCH_LINK, i->iparams->reactor, o, (NCDInterfaceMonitor_handler)monitor_handler, (NCDInterfaceMonitor_handler_error)monitor_handler_error)) {
+    if (!NCDInterfaceMonitor_Init(&o->monitor, ifindex, NCDIFMONITOR_WATCH_LINK, i->params->iparams->reactor, o, (NCDInterfaceMonitor_handler)monitor_handler, (NCDInterfaceMonitor_handler_error)monitor_handler_error)) {
         ModuleLog(o->i, BLOG_ERROR, "NCDInterfaceMonitor_Init failed");
         goto fail0;
     }

+ 2 - 2
ncd/modules/net_backend_wpa_supplicant.c

@@ -435,7 +435,7 @@ static void func_new (void *vo, NCDModuleInst *i, const struct NCDModuleInst_new
     }
     
     // init process
-    if (!BInputProcess_Init(&o->process, o->i->iparams->reactor, o->i->iparams->manager, o,
+    if (!BInputProcess_Init(&o->process, o->i->params->iparams->reactor, o->i->params->iparams->manager, o,
                             (BInputProcess_handler_terminated)process_handler_terminated,
                             (BInputProcess_handler_closed)process_handler_closed
     )) {
@@ -444,7 +444,7 @@ static void func_new (void *vo, NCDModuleInst *i, const struct NCDModuleInst_new
     }
     
     // init input interface
-    PacketPassInterface_Init(&o->pipe_input, MAX_LINE_LEN, (PacketPassInterface_handler_send)process_pipe_handler_send, o, BReactor_PendingGroup(o->i->iparams->reactor));
+    PacketPassInterface_Init(&o->pipe_input, MAX_LINE_LEN, (PacketPassInterface_handler_send)process_pipe_handler_send, o, BReactor_PendingGroup(o->i->params->iparams->reactor));
     
     // init buffer
     if (!LineBuffer_Init(&o->pipe_buffer, BInputProcess_GetInput(&o->process), &o->pipe_input, MAX_LINE_LEN, '\n')) {

+ 1 - 1
ncd/modules/net_ipv4_arp_probe.c

@@ -145,7 +145,7 @@ static void func_new (void *vo, NCDModuleInst *i, const struct NCDModuleInst_new
     }
     
     // init arpprobe
-    if (!BArpProbe_Init(&o->arpprobe, ifname, addr, i->iparams->reactor, o, (BArpProbe_handler)arpprobe_handler)) {
+    if (!BArpProbe_Init(&o->arpprobe, ifname, addr, i->params->iparams->reactor, o, (BArpProbe_handler)arpprobe_handler)) {
         ModuleLog(o->i, BLOG_ERROR, "BArpProbe_Init failed");
         goto fail0;
     }

+ 1 - 1
ncd/modules/net_ipv4_dhcp.c

@@ -162,7 +162,7 @@ static void func_new (void *vo, NCDModuleInst *i, const struct NCDModuleInst_new
     }
     
     // init DHCP
-    if (!BDHCPClient_Init(&o->dhcp, ifname, opts, o->i->iparams->reactor, o->i->iparams->random2, (BDHCPClient_handler)dhcp_handler, o)) {
+    if (!BDHCPClient_Init(&o->dhcp, ifname, opts, o->i->params->iparams->reactor, o->i->params->iparams->random2, (BDHCPClient_handler)dhcp_handler, o)) {
         ModuleLog(o->i, BLOG_ERROR, "BDHCPClient_Init failed");
         goto fail0;
     }

+ 1 - 1
ncd/modules/net_ipv6_wait_dynamic_addr.c

@@ -117,7 +117,7 @@ static void func_new (void *vo, NCDModuleInst *i, const struct NCDModuleInst_new
     }
     
     // init monitor
-    if (!NCDInterfaceMonitor_Init(&o->monitor, ifindex, NCDIFMONITOR_WATCH_IPV6_ADDR, i->iparams->reactor, o, (NCDInterfaceMonitor_handler)monitor_handler, (NCDInterfaceMonitor_handler_error)monitor_handler_error)) {
+    if (!NCDInterfaceMonitor_Init(&o->monitor, ifindex, NCDIFMONITOR_WATCH_IPV6_ADDR, i->params->iparams->reactor, o, (NCDInterfaceMonitor_handler)monitor_handler, (NCDInterfaceMonitor_handler_error)monitor_handler_error)) {
         ModuleLog(o->i, BLOG_ERROR, "NCDInterfaceMonitor_Init failed");
         goto fail0;
     }

+ 2 - 2
ncd/modules/net_watch_interfaces.c

@@ -299,7 +299,7 @@ static void client_handler (struct instance *o, char *devpath, int have_map, BSt
     // lookup existing device with this devpath
     struct device *ex_device = find_device_by_devpath(o, devpath);
     // lookup cache entry
-    const BStringMap *cache_map = NCDUdevManager_Query(o->i->iparams->umanager, devpath);
+    const BStringMap *cache_map = NCDUdevManager_Query(o->i->params->iparams->umanager, devpath);
     
     if (!cache_map) {
         if (ex_device) {
@@ -356,7 +356,7 @@ static void func_new (void *vo, NCDModuleInst *i, const struct NCDModuleInst_new
     }
     
     // init client
-    NCDUdevClient_Init(&o->client, o->i->iparams->umanager, o, (NCDUdevClient_handler)client_handler);
+    NCDUdevClient_Init(&o->client, o->i->params->iparams->umanager, o, (NCDUdevClient_handler)client_handler);
     
     // init devices list
     LinkedList1_Init(&o->devices_list);

+ 2 - 2
ncd/modules/process_manager.c

@@ -192,7 +192,7 @@ void process_free (struct process *p)
     LinkedList1_Remove(&o->processes_list, &p->processes_list_node);
     
     // free timer
-    BReactor_RemoveTimer(o->i->iparams->reactor, &p->retry_timer);
+    BReactor_RemoveTimer(o->i->params->iparams->reactor, &p->retry_timer);
     
     // free name
     free(p->name);
@@ -373,7 +373,7 @@ void process_try (struct process *p)
         ModuleLog(o->i, BLOG_ERROR, "NCDModuleProcess_Init failed");
         
         // set timer
-        BReactor_SetTimer(o->i->iparams->reactor, &p->retry_timer);
+        BReactor_SetTimer(o->i->params->iparams->reactor, &p->retry_timer);
         
         // set state
         p->state = PROCESS_STATE_RETRYING;

+ 1 - 1
ncd/modules/run.c

@@ -140,7 +140,7 @@ static void func_new (void *vo, NCDModuleInst *i, const struct NCDModuleInst_new
     o->i = i;
     
     // init dummy event lock
-    BEventLock_Init(&o->lock, BReactor_PendingGroup(i->iparams->reactor));
+    BEventLock_Init(&o->lock, BReactor_PendingGroup(i->params->iparams->reactor));
     
     command_template_new(&o->cti, i, params, build_cmdline, template_free_func, o, BLOG_CURRENT_CHANNEL, &o->lock);
     return;

+ 1 - 1
ncd/modules/runonce.c

@@ -249,7 +249,7 @@ static void func_new (void *vo, NCDModuleInst *i, const struct NCDModuleInst_new
     p_params.do_setsid = do_setsid;
     
     // start process
-    if (!BProcess_Init2(&o->process, o->i->iparams->manager, (BProcess_handler)process_handler, o, exec, CmdLine_Get(&cl), p_params)) {
+    if (!BProcess_Init2(&o->process, o->i->params->iparams->manager, (BProcess_handler)process_handler, o, exec, CmdLine_Get(&cl), p_params)) {
         ModuleLog(i, BLOG_ERROR, "BProcess_Init failed");
         CmdLine_Free(&cl);
         free(exec);

+ 3 - 3
ncd/modules/sleep.c

@@ -100,7 +100,7 @@ static void func_new (void *vo, NCDModuleInst *i, const struct NCDModuleInst_new
     o->dying = 0;
     
     // set timer
-    BReactor_SetTimerAfter(o->i->iparams->reactor, &o->timer, o->ms_start);
+    BReactor_SetTimerAfter(o->i->params->iparams->reactor, &o->timer, o->ms_start);
     return;
     
 fail0:
@@ -111,7 +111,7 @@ fail0:
 void instance_free (struct instance *o)
 {
     // free timer
-    BReactor_RemoveTimer(o->i->iparams->reactor, &o->timer);
+    BReactor_RemoveTimer(o->i->params->iparams->reactor, &o->timer);
     
     NCDModuleInst_Backend_Dead(o->i);
 }
@@ -124,7 +124,7 @@ static void func_die (void *vo)
     o->dying = 1;
     
     // set timer
-    BReactor_SetTimerAfter(o->i->iparams->reactor, &o->timer, o->ms_stop);
+    BReactor_SetTimerAfter(o->i->params->iparams->reactor, &o->timer, o->ms_stop);
 }
 
 static const struct NCDModule modules[] = {

+ 5 - 5
ncd/modules/sys_evdev.c

@@ -118,7 +118,7 @@ static void device_handler (struct instance *o, int events)
     }
     
     // stop reading
-    BReactor_SetFileDescriptorEvents(o->i->iparams->reactor, &o->bfd, 0);
+    BReactor_SetFileDescriptorEvents(o->i->params->iparams->reactor, &o->bfd, 0);
     
     // set processing
     o->processing = 1;
@@ -132,7 +132,7 @@ static void device_nextevent (struct instance *o)
     ASSERT(o->processing)
     
     // start reading
-    BReactor_SetFileDescriptorEvents(o->i->iparams->reactor, &o->bfd, BREACTOR_READ);
+    BReactor_SetFileDescriptorEvents(o->i->params->iparams->reactor, &o->bfd, BREACTOR_READ);
     
     // set not processing
     o->processing = 0;
@@ -171,11 +171,11 @@ static void func_new (void *vo, NCDModuleInst *i, const struct NCDModuleInst_new
     
     // init BFileDescriptor
     BFileDescriptor_Init(&o->bfd, o->evdev_fd, (BFileDescriptor_handler)device_handler, o);
-    if (!BReactor_AddFileDescriptor(o->i->iparams->reactor, &o->bfd)) {
+    if (!BReactor_AddFileDescriptor(o->i->params->iparams->reactor, &o->bfd)) {
         ModuleLog(o->i, BLOG_ERROR, "BReactor_AddFileDescriptor failed");
         goto fail1;
     }
-    BReactor_SetFileDescriptorEvents(o->i->iparams->reactor, &o->bfd, BREACTOR_READ);
+    BReactor_SetFileDescriptorEvents(o->i->params->iparams->reactor, &o->bfd, BREACTOR_READ);
     
     // set not processing
     o->processing = 0;
@@ -193,7 +193,7 @@ fail0:
 void instance_free (struct instance *o, int is_error)
 {
     // free BFileDescriptor
-    BReactor_RemoveFileDescriptor(o->i->iparams->reactor, &o->bfd);
+    BReactor_RemoveFileDescriptor(o->i->params->iparams->reactor, &o->bfd);
     
     // close device.
     // Ignore close error which happens if the device is removed.

+ 1 - 1
ncd/modules/sys_request_client.c

@@ -548,7 +548,7 @@ static void func_new (void *vo, NCDModuleInst *i, const struct NCDModuleInst_new
     }
     
     // init client
-    if (!NCDRequestClient_Init(&o->client, addr, i->iparams->reactor, o,
+    if (!NCDRequestClient_Init(&o->client, addr, i->params->iparams->reactor, o,
         (NCDRequestClient_handler_error)client_handler_error,
         (NCDRequestClient_handler_connected)client_handler_connected)) {
         ModuleLog(o->i, BLOG_ERROR, "NCDRequestClient_Init failed");

+ 3 - 3
ncd/modules/sys_request_server.c

@@ -175,7 +175,7 @@ static void listener_handler (struct instance *o)
 {
     ASSERT(!o->dying)
     
-    BReactor *reactor = o->i->iparams->reactor;
+    BReactor *reactor = o->i->params->iparams->reactor;
     BPendingGroup *pg = BReactor_PendingGroup(reactor);
     
     struct connection *c = malloc(sizeof(*c));
@@ -679,7 +679,7 @@ static int init_listen (struct instance *o, NCDValRef listen_addr_arg)
         }
         
         // init listener
-        if (!BListener_InitUnix(&o->listener, o->unix_socket_path, o->i->iparams->reactor, o, (BListener_handler)listener_handler)) {
+        if (!BListener_InitUnix(&o->listener, o->unix_socket_path, o->i->params->iparams->reactor, o, (BListener_handler)listener_handler)) {
             ModuleLog(o->i, BLOG_ERROR, "BListener_InitUnix failed");
             return 0;
         }
@@ -709,7 +709,7 @@ static int init_listen (struct instance *o, NCDValRef listen_addr_arg)
         BAddr_InitFromIpaddrAndPort(&addr, ipaddr, hton16(port));
         
         // init listener
-        if (!BListener_Init(&o->listener, addr, o->i->iparams->reactor, o, (BListener_handler)listener_handler)) {
+        if (!BListener_Init(&o->listener, addr, o->i->params->iparams->reactor, o, (BListener_handler)listener_handler)) {
             ModuleLog(o->i, BLOG_ERROR, "BListener_Init failed");
             return 0;
         }

+ 6 - 6
ncd/modules/sys_watch_directory.c

@@ -107,7 +107,7 @@ static void next_dir_event (struct instance *o)
             o->dir_handle = NULL;
             
             // start receiving inotify events
-            BReactor_SetFileDescriptorEvents(o->i->iparams->reactor, &o->bfd, BREACTOR_READ);
+            BReactor_SetFileDescriptorEvents(o->i->params->iparams->reactor, &o->bfd, BREACTOR_READ);
             return;
         }
     } while (!strcmp(entry->d_name, ".") || !strcmp(entry->d_name, ".."));
@@ -169,7 +169,7 @@ static void next_inotify_event (struct instance *o)
     
     if (o->events_index == o->events_count) {
         // wait for more events
-        BReactor_SetFileDescriptorEvents(o->i->iparams->reactor, &o->bfd, BREACTOR_READ);
+        BReactor_SetFileDescriptorEvents(o->i->params->iparams->reactor, &o->bfd, BREACTOR_READ);
         return;
     }
     
@@ -203,7 +203,7 @@ static void inotify_fd_handler (struct instance *o, int events)
     }
     
     // stop waiting for inotify events
-    BReactor_SetFileDescriptorEvents(o->i->iparams->reactor, &o->bfd, 0);
+    BReactor_SetFileDescriptorEvents(o->i->params->iparams->reactor, &o->bfd, 0);
     
     ASSERT(res <= sizeof(o->events))
     ASSERT(res % sizeof(o->events[0]) == 0)
@@ -272,7 +272,7 @@ static void func_new (void *vo, NCDModuleInst *i, const struct NCDModuleInst_new
     
     // init BFileDescriptor
     BFileDescriptor_Init(&o->bfd, o->inotify_fd, (BFileDescriptor_handler)inotify_fd_handler, o);
-    if (!BReactor_AddFileDescriptor(o->i->iparams->reactor, &o->bfd)) {
+    if (!BReactor_AddFileDescriptor(o->i->params->iparams->reactor, &o->bfd)) {
         ModuleLog(o->i, BLOG_ERROR, "BReactor_AddFileDescriptor failed");
         goto fail1;
     }
@@ -291,7 +291,7 @@ static void func_new (void *vo, NCDModuleInst *i, const struct NCDModuleInst_new
     return;
     
 fail2:
-    BReactor_RemoveFileDescriptor(o->i->iparams->reactor, &o->bfd);
+    BReactor_RemoveFileDescriptor(o->i->params->iparams->reactor, &o->bfd);
 fail1:
     if (close(o->inotify_fd) < 0) {
         ModuleLog(o->i, BLOG_ERROR, "close failed");
@@ -311,7 +311,7 @@ void instance_free (struct instance *o, int is_error)
     }
     
     // free BFileDescriptor
-    BReactor_RemoveFileDescriptor(o->i->iparams->reactor, &o->bfd);
+    BReactor_RemoveFileDescriptor(o->i->params->iparams->reactor, &o->bfd);
     
     // close inotify
     if (close(o->inotify_fd) < 0) {

+ 2 - 2
ncd/modules/sys_watch_input.c

@@ -278,7 +278,7 @@ static void client_handler (struct instance *o, char *devpath, int have_map, BSt
     // lookup existing device with this devpath
     struct device *ex_device = find_device_by_devpath(o, devpath);
     // lookup cache entry
-    const BStringMap *cache_map = NCDUdevManager_Query(o->i->iparams->umanager, devpath);
+    const BStringMap *cache_map = NCDUdevManager_Query(o->i->params->iparams->umanager, devpath);
     
     if (!cache_map) {
         if (ex_device) {
@@ -360,7 +360,7 @@ static void func_new (void *vo, NCDModuleInst *i, const struct NCDModuleInst_new
     o->devnode_type = NCDVal_StringValue(devnode_type_arg);
     
     // init client
-    NCDUdevClient_Init(&o->client, o->i->iparams->umanager, o, (NCDUdevClient_handler)client_handler);
+    NCDUdevClient_Init(&o->client, o->i->params->iparams->umanager, o, (NCDUdevClient_handler)client_handler);
     
     // init devices list
     LinkedList1_Init(&o->devices_list);

+ 2 - 2
ncd/modules/sys_watch_usb.c

@@ -263,7 +263,7 @@ static void client_handler (struct instance *o, char *devpath, int have_map, BSt
     // lookup existing device with this devpath
     struct device *ex_device = find_device_by_devpath(o, devpath);
     // lookup cache entry
-    const BStringMap *cache_map = NCDUdevManager_Query(o->i->iparams->umanager, devpath);
+    const BStringMap *cache_map = NCDUdevManager_Query(o->i->params->iparams->umanager, devpath);
     
     if (!cache_map) {
         if (ex_device) {
@@ -329,7 +329,7 @@ static void func_new (void *vo, NCDModuleInst *i, const struct NCDModuleInst_new
     }
     
     // init client
-    NCDUdevClient_Init(&o->client, o->i->iparams->umanager, o, (NCDUdevClient_handler)client_handler);
+    NCDUdevClient_Init(&o->client, o->i->params->iparams->umanager, o, (NCDUdevClient_handler)client_handler);
     
     // init devices list
     LinkedList1_Init(&o->devices_list);

+ 2 - 1
ncd/ncd.c

@@ -371,6 +371,7 @@ int main (int argc, char **argv)
     module_params.func_event = statement_instance_func_event;
     module_params.func_getobj = statement_instance_func_getobj;
     module_params.logfunc = (BLog_logfunc)statement_instance_logfunc;
+    module_params.iparams = &module_iparams;
     module_iparams.reactor = &reactor;
     module_iparams.manager = &manager;
     module_iparams.umanager = &umanager;
@@ -1109,7 +1110,7 @@ void process_advance (struct process *p)
     process_assert_pointers(p);
     
     // initialize module instance
-    NCDModuleInst_Init(&ps->inst, module, mem, object_ptr, args, &module_params, &module_iparams);
+    NCDModuleInst_Init(&ps->inst, module, mem, object_ptr, args, &module_params);
     return;
     
 fail1: