浏览代码

xmpp: register and start xmpp manager process

- reported by Elias Baixas
Daniel-Constantin Mierla 15 年之前
父节点
当前提交
7b7542b8e2
共有 1 个文件被更改,包括 26 次插入1 次删除
  1. 26 1
      modules_k/xmpp/xmpp.c

+ 26 - 1
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;
 }