Module: sip-router
Branch: janakj/flatstore
Commit: 46b6981987a2ce15a2327f6da09741d860f25cb8
URL:
http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=46b6981…
Author: Jan Janak <jan(a)iptel.org>
Committer: Jan Janak <jan(a)iptel.org>
Date: Wed Feb 18 23:43:12 2009 +0100
Make km_sources compile, part two.
List of changes:
* Call km_mod_init, km_child_init, km_mod_destroy from the real init
functions in flatstore_mod.c and make the km_ functions non-static
so that they are callable from other object files.
* Renamed non-static global variables in km_flatstore_mod.c to avoid
conflicts with variables with the same name in flatstore_mod.c
(local_timestamp->km_local_timestamp, flat_rotate->km_flat_rotate)
---
modules/db_flatstore/flatstore_mod.c | 15 ++++++++++++-
modules/db_flatstore/km_flat_mi.c | 3 +-
modules/db_flatstore/km_flatstore.c | 4 +-
modules/db_flatstore/km_flatstore_mod.c | 32 ++++++++++++------------------
modules/db_flatstore/km_flatstore_mod.h | 10 +++++++-
5 files changed, 38 insertions(+), 26 deletions(-)
diff --git a/modules/db_flatstore/flatstore_mod.c b/modules/db_flatstore/flatstore_mod.c
index 78c29e8..0f7b5b5 100644
--- a/modules/db_flatstore/flatstore_mod.c
+++ b/modules/db_flatstore/flatstore_mod.c
@@ -29,8 +29,8 @@
/** \file
* Flatstore module interface.
*/
-
#include "flatstore_mod.h"
+#include "km_flatstore_mod.h"
#include "flat_con.h"
#include "flat_cmd.h"
#include "flat_rpc.h"
@@ -166,22 +166,33 @@ static int mod_init(void)
*flat_rotate = time(0);
flat_local_timestamp = *flat_rotate;
- return 0;
+
+ return km_mod_init();
}
static void mod_destroy(void)
{
+ km_mod_destroy();
if (flat_pid.s) free(flat_pid.s);
if (flat_rotate) shm_free(flat_rotate);
}
+/*
+ * FIXME: We should check whether just calling km_child_init would really work
+ * here. This function comes from kamailio and since the core of sip-router is
+ * based on SER 2.0, the way how child_init is called and values of the rank
+ * variable could be incompatible with km_child_init function. A solution here
+ * would be to rewrite km_child_init with ser 2.0 init stuff in mind.
+ */
static int child_init(int rank)
{
char* tmp;
unsigned int v;
+ km_child_init(rank);
+
if (rank <= 0) {
v = -rank;
} else {
diff --git a/modules/db_flatstore/km_flat_mi.c b/modules/db_flatstore/km_flat_mi.c
index 992e2a4..2200148 100644
--- a/modules/db_flatstore/km_flat_mi.c
+++ b/modules/db_flatstore/km_flat_mi.c
@@ -23,6 +23,7 @@
*/
#include "flatstore_mod.h"
+#include "km_flatstore_mod.h"
#include "km_flat_mi.h"
@@ -34,7 +35,7 @@ struct mi_root* mi_flat_rotate_cmd(struct mi_root* cmd_tree, void*
param)
if(rpl_tree == NULL)
return rpl_tree;
- *flat_rotate = time(0);
+ *km_flat_rotate = time(0);
return rpl_tree;
}
diff --git a/modules/db_flatstore/km_flatstore.c b/modules/db_flatstore/km_flatstore.c
index 499a98e..7a2fbaf 100644
--- a/modules/db_flatstore/km_flatstore.c
+++ b/modules/db_flatstore/km_flatstore.c
@@ -158,9 +158,9 @@ int flat_db_insert(const db1_con_t* h, const db_key_t* k, const
db_val_t* v,
int l;
char *s, *p;
- if (local_timestamp < *flat_rotate) {
+ if (km_local_timestamp < *km_flat_rotate) {
flat_rotate_logs();
- local_timestamp = *flat_rotate;
+ km_local_timestamp = *km_flat_rotate;
}
f = CON_FILE(h);
diff --git a/modules/db_flatstore/km_flatstore_mod.c
b/modules/db_flatstore/km_flatstore_mod.c
index d968594..ebb5304 100644
--- a/modules/db_flatstore/km_flatstore_mod.c
+++ b/modules/db_flatstore/km_flatstore_mod.c
@@ -37,12 +37,6 @@
/*MODULE_VERSION*/
-static int child_init(int rank);
-
-static int mod_init(void);
-
-static void mod_destroy(void);
-
int db_flat_bind_api(db_func_t *dbb);
/*
@@ -61,9 +55,9 @@ char* km_flat_delimiter = "|";
* Timestamp of the last log rotation request from
* the FIFO interface
*/
-time_t* flat_rotate;
+time_t* km_flat_rotate;
-time_t local_timestamp;
+time_t km_local_timestamp;
/*
* Flatstore database module interface
@@ -98,40 +92,40 @@ struct kam_module_exports km_exports = {
mi_cmds, /* exported MI functions */
0, /* exported pseudo-variables */
0, /* extra processes */
- mod_init, /* module initialization function */
+ km_mod_init, /* module initialization function */
0, /* response function*/
- mod_destroy, /* destroy function */
- child_init /* per-child init function */
+ km_mod_destroy, /* destroy function */
+ km_child_init /* per-child init function */
};
-static int mod_init(void)
+int km_mod_init(void)
{
if (strlen(km_flat_delimiter) != 1) {
LM_ERR("delimiter has to be exactly one character\n");
return -1;
}
- flat_rotate = (time_t*)shm_malloc(sizeof(time_t));
- if (!flat_rotate) {
+ km_flat_rotate = (time_t*)shm_malloc(sizeof(time_t));
+ if (!km_flat_rotate) {
LM_ERR("no shared memory left\n");
return -1;
}
- *flat_rotate = time(0);
- local_timestamp = *flat_rotate;
+ *km_flat_rotate = time(0);
+ km_local_timestamp = *km_flat_rotate;
return 0;
}
-static void mod_destroy(void)
+void km_mod_destroy(void)
{
- if (flat_rotate) shm_free(flat_rotate);
+ if (km_flat_rotate) shm_free(km_flat_rotate);
}
-static int child_init(int rank)
+int km_child_init(int rank)
{
if (rank <= 0) {
km_flat_pid = - rank;
diff --git a/modules/db_flatstore/km_flatstore_mod.h
b/modules/db_flatstore/km_flatstore_mod.h
index b605c11..3ca8c50 100644
--- a/modules/db_flatstore/km_flatstore_mod.h
+++ b/modules/db_flatstore/km_flatstore_mod.h
@@ -48,14 +48,20 @@ extern char* km_flat_delimiter;
* The timestamp of log rotation request from
* the FIFO interface
*/
-extern time_t* flat_rotate;
+extern time_t* km_flat_rotate;
/*
* Local timestamp marking the time of the
* last log rotation in the process
*/
-extern time_t local_timestamp;
+extern time_t km_local_timestamp;
+
+int km_mod_init(void);
+
+void km_mod_destroy(void);
+
+int km_child_init(int rank);
#endif /* KM_FLATSTORE_MOD_H */