Module: sip-router Branch: janakj/flatstore Commit: 2082c79321a51dff1de6bb64b9b74363f744f6b5 URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=2082c793...
Author: Jan Janak jan@iptel.org Committer: Jan Janak jan@iptel.org Date: Tue Dec 20 11:36:33 2005 +0000
- converted to the new management interface
---
modules/db_flatstore/{flat_fifo.c => flat_rpc.c} | 48 ++++++---------------- modules/db_flatstore/{flat_fifo.h => flat_rpc.h} | 17 +++----- modules/db_flatstore/flatstore_mod.c | 12 +---- 3 files changed, 23 insertions(+), 54 deletions(-)
diff --git a/modules/db_flatstore/flat_fifo.c b/modules/db_flatstore/flat_rpc.c similarity index 58% rename from modules/db_flatstore/flat_fifo.c rename to modules/db_flatstore/flat_rpc.c index bd273a6..f861ea0 100644 --- a/modules/db_flatstore/flat_fifo.c +++ b/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}, +}; diff --git a/modules/db_flatstore/flat_fifo.h b/modules/db_flatstore/flat_rpc.h similarity index 83% rename from modules/db_flatstore/flat_fifo.h rename to modules/db_flatstore/flat_rpc.h index e746574..592da1f 100644 --- a/modules/db_flatstore/flat_fifo.h +++ b/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 */ diff --git a/modules/db_flatstore/flatstore_mod.c b/modules/db_flatstore/flatstore_mod.c index e14daaf..4a2ca2b 100644 --- a/modules/db_flatstore/flatstore_mod.c +++ b/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; }