Module: sip-router
Branch: master
Commit: 9379c50b8eafea6ca3a9f7105f5ee73912fdc161
URL:
http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=9379c50…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: Fri Oct 1 21:39:25 2010 +0200
purple: register and start purple manager process
---
modules_k/purple/purple.c | 28 ++++++++++++++++++++++++++--
1 files changed, 26 insertions(+), 2 deletions(-)
diff --git a/modules_k/purple/purple.c b/modules_k/purple/purple.c
index 528c499..f85b9d5 100644
--- a/modules_k/purple/purple.c
+++ b/modules_k/purple/purple.c
@@ -41,6 +41,7 @@
MODULE_VERSION
static int init(void);
+static int child_init(int rank);
static void destroy(void);
static void runprocs(int rank);
static int func_send_message(struct sip_msg* msg);
@@ -104,7 +105,7 @@ struct module_exports exports= {
init, /* module initialization function */
0, /* response function */
destroy, /* destroy function */
- 0, /* per-child init function */
+ child_init, /* per-child init function */
};
@@ -216,9 +217,32 @@ static int init(void) {
return -1;
}
+ /* add space for one extra process */
+ register_procs(1);
+
return 0;
}
-
+
+/**
+ * initialize child processes
+ */
+static int child_init(int rank)
+{
+ int pid;
+
+ if (rank==PROC_MAIN) {
+ pid=fork_process(PROC_NOCHLDINIT, "PURPLE Manager", 1);
+ if (pid<0)
+ return -1; /* error */
+ if(pid==0){
+ /* child */
+ runprocs(1);
+ }
+ }
+
+ return 0;
+}
+
static void destroy(void) {
LM_DBG("cleaning up...\n");
close(pipefds[0]);