[sr-dev] git:master: xmpp: register and start xmpp manager process

Daniel-Constantin Mierla miconda at gmail.com
Fri Oct 1 21:29:03 CEST 2010


Module: sip-router
Branch: master
Commit: 7b7542b8e2323e70b2b32b5b659d296219374850
URL:    http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=7b7542b8e2323e70b2b32b5b659d296219374850

Author: Daniel-Constantin Mierla <miconda at gmail.com>
Committer: Daniel-Constantin Mierla <miconda at gmail.com>
Date:   Fri Oct  1 21:27:59 2010 +0200

xmpp: register and start xmpp manager process

- reported by Elias Baixas

---

 modules_k/xmpp/xmpp.c |   27 ++++++++++++++++++++++++++-
 1 files changed, 26 insertions(+), 1 deletions(-)

diff --git a/modules_k/xmpp/xmpp.c b/modules_k/xmpp/xmpp.c
index 5d634d4..e7a0093 100644
--- a/modules_k/xmpp/xmpp.c
+++ b/modules_k/xmpp/xmpp.c
@@ -134,6 +134,7 @@ MODULE_VERSION
 struct tm_binds tmb;
 
 static int  mod_init(void);
+static int  child_init(int rank);
 static void xmpp_process(int rank);
 static int  cmd_send_message(struct sip_msg* msg, char* _foo, char* _bar);
 
@@ -200,7 +201,7 @@ struct module_exports exports = {
 	mod_init,        /* Initialization function */
 	0,               /* Response function */
 	0,               /* Destroy function */
-	0,               /* Child init function */
+	child_init,      /* Child init function */
 };
 
 /*
@@ -242,6 +243,30 @@ static int mod_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, "XMPP Manager", 1);
+		if (pid<0)
+			return -1; /* error */
+		if(pid==0){
+			/* child */
+			xmpp_process(1);
+		}
+	}
+
 	return 0;
 }
 




More information about the sr-dev mailing list