Update of /cvsroot/mahogany/M/src/modules/spam
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30110/src/modules/spam
Modified Files:
DspamFilter.cpp
Log Message:
keep sqlite db connection permanently opened
Index: DspamFilter.cpp
===================================================================
RCS file: /cvsroot/mahogany/M/src/modules/spam/DspamFilter.cpp,v
retrieving revision 1.14
retrieving revision 1.15
diff -b -u -2 -r1.14 -r1.15
--- DspamFilter.cpp 28 Oct 2004 20:27:22 -0000 1.14
+++ DspamFilter.cpp 28 Oct 2004 21:05:38 -0000 1.15
@@ -33,4 +33,5 @@
#include "Message.h"
#include "HeaderInfo.h"
+#include "MAtExit.h"
#include "SpamFilter.h"
@@ -40,4 +41,5 @@
{
#include <libdspam.h>
+ #include <sqlite_drv.h>
}
@@ -68,5 +70,14 @@
dspam_addattribute(m_ctx, "SQLitePragma", "synchronous = OFF");
- dspam_attach(m_ctx, NULL);
+ dspam_attach(m_ctx, ms_dbh);
+ if ( !ms_dbh )
+ {
+ // we haven't had database connection yet, so dspam_attach must have
+ // created a new one -- detach it from the context to avoid deleting
+ // it and reuse it for subsequent contexts
+ _sqlite_drv_storage *storage = (_sqlite_drv_storage *)m_ctx->storage;
+ ms_dbh = storage->dbh;
+ storage->dbh_attached = 1;
+ }
}
@@ -83,5 +94,19 @@
DSPAM_CTX *operator->() const { return m_ctx; }
+ // close the database connection
+ static void CloseDatabase()
+ {
+ if ( ms_dbh )
+ {
+ sqlite_close(ms_dbh);
+ ms_dbh = NULL;
+ }
+ }
+
private:
+ // the database connection reused by all contexts
+ static sqlite *ms_dbh;
+
+
DSPAM_CTX *m_ctx;
@@ -89,4 +114,9 @@
};
+sqlite *DspamCtx::ms_dbh = NULL;
+
+MRunFunctionAtExit closeSQlite(DspamCtx::CloseDatabase);
+
+
// normal DSPAM context
class DspamProcessCtx : public DspamCtx
-------------------------------------------------------
This Newsletter Sponsored by: Macrovision
For reliable Linux application installations, use the industry's leading
setup authoring tool, InstallShield X. Learn more and evaluate
today. http://clk.atdmt.com/MSI/go/ins0030000001msi/direct/01/
_______________________________________________
Mahogany-cvsupdates mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/mahogany-cvsupdates