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 */