
marvin at rectangular
Apr 29, 2007, 9:37 PM
Post #1 of 1
(47 views)
Permalink
|
|
r2375 - in trunk: c_src/KinoSearch/Store perl/lib/KinoSearch/Store perl/t
|
|
Author: creamyg Date: 2007-04-29 21:37:46 -0700 (Sun, 29 Apr 2007) New Revision: 2375 Modified: trunk/c_src/KinoSearch/Store/FSFileDes.c trunk/c_src/KinoSearch/Store/FileDes.c trunk/c_src/KinoSearch/Store/FileDes.h trunk/c_src/KinoSearch/Store/RAMFileDes.c trunk/perl/lib/KinoSearch/Store/FileDes.pm trunk/perl/t/213-segment_merging.t Log: Add FileDes_open_count to track opened FileDes objects. Modified: trunk/c_src/KinoSearch/Store/FSFileDes.c =================================================================== --- trunk/c_src/KinoSearch/Store/FSFileDes.c 2007-04-30 04:36:17 UTC (rev 2374) +++ trunk/c_src/KinoSearch/Store/FSFileDes.c 2007-04-30 04:37:46 UTC (rev 2375) @@ -16,7 +16,6 @@ } \ } while (0) - FSFileDes* FSFileDes_new(const char *path, int oflags, int fdmode, const char *fmode) { @@ -43,7 +42,8 @@ self->path = strdup(path); /* track number of live FileDes released into the wild */ - FileDes_global_count++; + FileDes_object_count++; + FileDes_open_count++; return self; } @@ -58,7 +58,7 @@ free(self->path); /* decrement count of FileDes structs in existence */ - FileDes_global_count--; + FileDes_object_count--; free(self); } @@ -119,6 +119,7 @@ CONFESS("Failed to close file '%s': %s", self->path, strerror(errno)); } + FileDes_open_count--; self->fhandle = NULL; } } Modified: trunk/c_src/KinoSearch/Store/FileDes.c =================================================================== --- trunk/c_src/KinoSearch/Store/FileDes.c 2007-04-30 04:36:17 UTC (rev 2374) +++ trunk/c_src/KinoSearch/Store/FileDes.c 2007-04-30 04:37:46 UTC (rev 2375) @@ -5,7 +5,8 @@ #define KINO_WANT_FILEDES_VTABLE #include "KinoSearch/Store/FileDes.r" -i32_t kino_FileDes_global_count = 0; +i32_t kino_FileDes_object_count = 0; +i32_t kino_FileDes_open_count = 0; void FileDes_fdseek(FileDes *self, u64_t target) Modified: trunk/c_src/KinoSearch/Store/FileDes.h =================================================================== --- trunk/c_src/KinoSearch/Store/FileDes.h 2007-04-30 04:36:17 UTC (rev 2374) +++ trunk/c_src/KinoSearch/Store/FileDes.h 2007-04-30 04:37:46 UTC (rev 2375) @@ -55,14 +55,20 @@ * they're the canary in the coal mine for detecting object-destruction memory * leaks. */ -extern chy_i32_t kino_FileDes_global_count; +extern chy_i32_t kino_FileDes_object_count; +/* Similar to above, but incremented upon successful open and decremented on + * successful close + */ +extern chy_i32_t kino_FileDes_open_count; + /* Size of the memory buffer used by both InStream and OutStream. */ #define KINO_IO_STREAM_BUF_SIZE 1024 #ifdef KINO_USE_SHORT_NAMES - #define FileDes_global_count kino_FileDes_global_count + #define FileDes_object_count kino_FileDes_object_count + #define FileDes_open_count kino_FileDes_open_count #define IO_STREAM_BUF_SIZE KINO_IO_STREAM_BUF_SIZE #endif Modified: trunk/c_src/KinoSearch/Store/RAMFileDes.c =================================================================== --- trunk/c_src/KinoSearch/Store/RAMFileDes.c 2007-04-30 04:36:17 UTC (rev 2374) +++ trunk/c_src/KinoSearch/Store/RAMFileDes.c 2007-04-30 04:37:46 UTC (rev 2375) @@ -22,7 +22,8 @@ self->path = strdup(path); /* track number of live FileDes released into the wild */ - FileDes_global_count++; + FileDes_object_count++; + FileDes_open_count++; return self; } @@ -34,7 +35,7 @@ free(self->path); /* decrement count of FileDes structs in existence */ - FileDes_global_count--; + FileDes_object_count--; free(self); } @@ -155,6 +156,7 @@ RAMFileDes_fdclose(RAMFileDes *self) { UNUSED_VAR(self); + FileDes_open_count--; } /* Copyright 2006-2007 Marvin Humphrey Modified: trunk/perl/lib/KinoSearch/Store/FileDes.pm =================================================================== --- trunk/perl/lib/KinoSearch/Store/FileDes.pm 2007-04-30 04:36:17 UTC (rev 2374) +++ trunk/perl/lib/KinoSearch/Store/FileDes.pm 2007-04-30 04:37:46 UTC (rev 2375) @@ -52,13 +52,25 @@ =cut chy_i32_t -global_count() +object_count() CODE: - RETVAL = kino_FileDes_global_count; + RETVAL = kino_FileDes_object_count; OUTPUT: RETVAL =for comment +For testing purposes only. Track number of FileDes objects in an open state. + +=cut + +chy_i32_t +open_count() +CODE: + RETVAL = kino_FileDes_open_count; +OUTPUT: RETVAL + +=for comment + For testing purposes only. Used to help produce buffer alignment tests. =cut Modified: trunk/perl/t/213-segment_merging.t =================================================================== --- trunk/perl/t/213-segment_merging.t 2007-04-30 04:36:17 UTC (rev 2374) +++ trunk/perl/t/213-segment_merging.t 2007-04-30 04:37:46 UTC (rev 2375) @@ -18,7 +18,7 @@ sub analyzer { KinoSearch::Analysis::Tokenizer->new } package main; -use Test::More tests => 6; +use Test::More tests => 7; use File::Spec::Functions qw( catfile tmpdir ); use File::Path qw( rmtree ); @@ -121,5 +121,7 @@ rmtree($invindex_loc); } -is( KinoSearch::Store::FileDes::global_count(), +is( KinoSearch::Store::FileDes::object_count(), 0, "All FileDes objects have been cleaned up" ); +is( KinoSearch::Store::FileDes::open_count(), + 0, "All FileDes closed" );
|