From 2077413b9eaa3d032cd0905946da459de254dac8 Mon Sep 17 00:00:00 2001 From: Jon Meredith Date: Thu, 18 Jun 2009 09:09:29 -0600 Subject: [PATCH] Added active counts to dbref and portref to help see what is being corrupted in the coredump. --- c_src/bdberl_drv.c | 6 ++++++ c_src/bdberl_drv.h | 3 +++ 2 files changed, 9 insertions(+) diff --git a/c_src/bdberl_drv.c b/c_src/bdberl_drv.c index 100ab7f..c6c8ee9 100644 --- a/c_src/bdberl_drv.c +++ b/c_src/bdberl_drv.c @@ -1900,6 +1900,7 @@ static int add_portref(int dbref, ErlDrvPort port) current = (PortList*)zalloc(sizeof(PortList)); current->port = port; last->next = current; + G_DATABASES[dbref].active_ports++; return 1; } else @@ -1908,6 +1909,7 @@ static int add_portref(int dbref, ErlDrvPort port) current = zalloc(sizeof(PortList)); current->port = port; G_DATABASES[dbref].ports = current; + G_DATABASES[dbref].active_ports++; return 1; } } @@ -1934,6 +1936,7 @@ static int del_portref(int dbref, ErlDrvPort port) // Delete this entry zfree(current); + G_DATABASES[dbref].active_ports--; return 1; } @@ -1970,6 +1973,7 @@ static int add_dbref(PortData* data, int dbref) current = zalloc(sizeof(DbRefList)); current->dbref = dbref; last->next = current; + data->active_dbs++; return 1; } else @@ -1978,6 +1982,7 @@ static int add_dbref(PortData* data, int dbref) current = zalloc(sizeof(DbRefList)); current->dbref = dbref; data->dbrefs = current; + data->active_dbs++; return 1; } } @@ -2009,6 +2014,7 @@ static int del_dbref(PortData* data, int dbref) // Delete this entry zfree(current); + data->active_dbs--; return 1; } diff --git a/c_src/bdberl_drv.h b/c_src/bdberl_drv.h index 9daa47a..2d70e13 100644 --- a/c_src/bdberl_drv.h +++ b/c_src/bdberl_drv.h @@ -112,6 +112,7 @@ typedef struct DB* db; const char* name; PortList* ports; + int active_ports; } Database; @@ -129,6 +130,8 @@ typedef struct DbRefList* dbrefs; /* List of databases that this port has opened */ + int active_dbs; /* Count of entries in dbrefs (for debug) */ + DB_TXN* txn; /* Transaction handle for this port; each port may only have 1 txn * active */