2
0
Эх сурвалжийг харах

- converted to the new management interface

Jan Janak 20 жил өмнө
parent
commit
2082c79321

+ 13 - 35
modules/db_flatstore/flat_fifo.c → modules/db_flatstore/flat_rpc.c

@@ -1,7 +1,7 @@
 /* 
  * $Id$ 
  *
- * Flatstore module FIFO interface
+ * Flatstore module interface
  *
  * Copyright (C) 2004 FhG Fokus
  *
@@ -27,45 +27,23 @@
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
-#include "../../dprint.h"
-#include "../../fifo_server.h"
 #include "flatstore_mod.h"
-#include "flat_fifo.h"
+#include "flat_rpc.h"
 
 
-#define FLAT_ROTATE "flat_rotate"
-#define FLAT_ROTATE_LEN (sizeof(FLAT_ROTATE) - 1)
-
-
-static int flat_rotate_cmd(FILE* pipe, char* response_file);
-
-
-/*
- * Initialize the FIFO interface
- */
-int init_flat_fifo(void)
+static void rotate(rpc_t* rpc, void* c)
 {
-	if (register_fifo_cmd(flat_rotate_cmd, FLAT_ROTATE, 0) < 0) {
-		LOG(L_CRIT, "flatstore: Cannot register flat_rotate\n");
-		return -1;
-	}
-	
-	return 0;
+	*flat_rotate = time(0);
 }
 
 
-static int flat_rotate_cmd(FILE* pipe, char* response_file)
-{
-	FILE* reply_file;
-	
-	reply_file = open_reply_pipe(response_file);
-	if (reply_file == 0) {
-		LOG(L_ERR, "flat_rotate_cmd: File not open\n");
-		return -1;
-	}
+static const char* flat_rotate_doc[2] = {
+	"Close and reopen flatrotate files during log rotation.",
+	0
+};
 
-	*flat_rotate = time(0);
-	fputs( "200 OK\n", reply_file);
-	fclose(reply_file);
-	return 1;
-}
+
+rpc_export_t flat_rpc[] = {
+	{"flatstore.rotate", rotate, flat_rotate_doc, 0},
+	{0, 0, 0, 0},
+};

+ 7 - 10
modules/db_flatstore/flat_fifo.h → modules/db_flatstore/flat_rpc.h

@@ -1,9 +1,9 @@
 /* 
  * $Id$ 
  *
- * Flatstore module FIFO interface
+ * Flatstore module interface
  *
- * Copyright (C) 2004 FhG Fokus
+ * Copyright (C) 2004-2005 FhG FOKUS
  *
  * This file is part of ser, a free SIP server.
  *
@@ -27,14 +27,11 @@
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
-#ifndef _FLAT_FIFO_H
-#define _FLAT_FIFO_H
-
-/*
- * Initialize the FIFO interface
- */
-int init_flat_fifo(void);
+#ifndef _FLAT_RPC_H
+#define _FLAT_RPC_H
 
+#include "../../rpc.h"
 
-#endif /* _FLAT_FIFO_H */
+extern rpc_export_t flat_rpc[];
 
+#endif /* _FLAT_RPC_H */

+ 3 - 9
modules/db_flatstore/flatstore_mod.c

@@ -36,7 +36,7 @@
 #include "../../sr_module.h"
 #include "../../mem/shm_mem.h"
 #include "flatstore.h"
-#include "flat_fifo.h"
+#include "flat_rpc.h"
 #include "flatstore_mod.h"
 
 MODULE_VERSION
@@ -97,7 +97,7 @@ static param_export_t params[] = {
 struct module_exports exports = {	
 	"flatstore",
 	cmds,
-	0,           /* RPC methods */
+	flat_rpc,    /* RPC methods */
 	params,      /*  module parameters */
 	mod_init,    /* module initialization function */
 	0,           /* response function*/
@@ -114,12 +114,6 @@ static int mod_init(void)
 		return -1;
 	}
 
-	     /* Initialize fifo interface */
-	if (init_flat_fifo() < 0) {
-		LOG(L_ERR, "flatstore: FIFO initialization failed\n");
-		return -1;
-	}
-
 	flat_rotate = (time_t*)shm_malloc(sizeof(time_t));
 	if (!flat_rotate) {
 		LOG(L_ERR, "flatstore: No shared memory left\n");
@@ -144,7 +138,7 @@ static int child_init(int rank)
 	if (rank <= 0) {
 		flat_pid = - rank;
 	} else {
-		flat_pid = rank - PROC_UNIXSOCK;
+		flat_pid = rank - PROC_MIN;
 	}
 	return 0;
 }