Introduction
Introduction Statistics Contact Development Disclaimer Help
pledge test mode, no need to reopen goodlist and spamlist for each message in t…
git clone git://git.codemadness.org/bmf
Log
Files
Refs
README
LICENSE
---
commit 41e1e6b8e9d49a1300c070f03070db4ce2d0bbbd
parent bd5dd52e982fcb2c07eddb303e585a6e9b738508
Author: Hiltjo Posthuma <[email protected]>
Date: Sat, 22 Sep 2018 18:49:54 +0200
pledge test mode, no need to reopen goodlist and spamlist for each message in t…
Diffstat:
M TODO | 7 +++++++
M bmf.c | 61 +++++++++++++++++++++++------…
2 files changed, 52 insertions(+), 16 deletions(-)
---
diff --git a/TODO b/TODO
@@ -1,3 +1,10 @@
+? optimize: reduce loading/writing of goodlist, spamlist table?
+
+- optimize: preload goodlist spamlist somehow.
+- in test mode (-t) reduce privileges (only stdio).
+
+===
+
* Make extrema size configurable, and default to ~5% of tokens.
* Teach lexer about multiline MIME headers and case (in)sensitivity.
* Teach lexer about MIME quoted-printable and base64 encodings.
diff --git a/bmf.c b/bmf.c
@@ -180,30 +180,50 @@ int main( int argc, char** argv )
exit( 2 );
}
- while( tok.tt != eof )
- {
- if( mboxtype == mbox && tok.tt != from )
- {
- fprintf( stderr, "%s: input does not look like an mbox message\n",…
- exit( 2 );
- }
-
- rdonly = (mode == mode_test || mode == mode_reg_n);
+ if (mode == mode_test) {
+ rdonly = 1;
pblist = pdb->opentable( pdb, "spamlist", rdonly );
if( pblist == NULL )
- {
+ {
fprintf( stderr, "%s: cannot open spamlist\n", argv[0] );
- exit( 2 );
+ exit( 2 );
}
- rdonly = (mode == mode_test || mode == mode_reg_s);
- pglist = pdb->opentable( pdb, "goodlist", rdonly );
+ pglist = pdb->opentable( pdb, "goodlist", rdonly );
if( pglist == NULL )
- {
+ {
fprintf( stderr, "%s: cannot open goodlist\n", argv[0] );
+ exit( 2 );
+ }
+
+ if (pledge("stdio", NULL) == -1)
+ err(1, "pledge");
+ }
+
+ while( tok.tt != eof )
+ {
+ if( mboxtype == mbox && tok.tt != from )
+ {
+ fprintf( stderr, "%s: input does not look like an mbox message\n",…
exit( 2 );
}
+ if (mode != mode_test) {
+ rdonly = 0;
+ pblist = pdb->opentable( pdb, "spamlist", rdonly );
+ if( pblist == NULL ) {
+ fprintf( stderr, "%s: cannot open spamlist\n", argv[0] );
+ exit( 2 );
+ }
+
+ pglist = pdb->opentable( pdb, "goodlist", rdonly );
+ if( pglist == NULL )
+ {
+ fprintf( stderr, "%s: cannot open goodlist\n", argv[0] );
+ exit( 2 );
+ }
+ }
+
vec_create( &mlist );
bvec_loadmsg( &mlist, &lex, &tok );
@@ -282,9 +302,18 @@ int main( int argc, char** argv )
vec_destroy( &mlist );
- pglist->close( pglist );
+ if (mode != mode_test) {
+ pglist->close( pglist );
+ free( pglist );
+ pblist->close( pblist );
+ free( pblist );
+ }
+ }
+
+ if (mode == mode_test) {
+ pglist->close( pglist );
free( pglist );
- pblist->close( pblist );
+ pblist->close( pblist );
free( pblist );
}
You are viewing proxied material from codemadness.org. The copyright of proxied material belongs to its original authors. Any comments or complaints in relation to proxied material should be directed to the original authors of the content concerned. Please see the disclaimer for more details.