Commit 79f4bed7 authored by Yoni Fogel's avatar Yoni Fogel

Addresses #1531 Fix test_logflush

git-svn-id: file:///svn/toku/tokudb@9966 c7de825b-a66e-492c-adef-691d508d4ae1
parent 2a879690
...@@ -5,7 +5,6 @@ ...@@ -5,7 +5,6 @@
#include <db.h> #include <db.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <fcntl.h> #include <fcntl.h>
#include <sys/mman.h>
// Return the offset // Return the offset
static int static int
...@@ -15,22 +14,15 @@ grep_for_in_logs (const char *str) { ...@@ -15,22 +14,15 @@ grep_for_in_logs (const char *str) {
#else #else
#define lname ENVDIR "//log.0000000001" #define lname ENVDIR "//log.0000000001"
#endif #endif
int fd = open(lname, O_RDONLY); #define COMMAND "grep -F -o"
assert(fd>=0); char systembuf[strlen(str)+sizeof(COMMAND " \"\" " lname " > /dev/null")];
int64_t file_size; int bytes = snprintf(systembuf, sizeof(systembuf), COMMAND " \"%s\" %s > /dev/null", str, lname);
int r = toku_os_get_file_size(fd, &file_size); assert(bytes>=0);
assert(r==0); assert((size_t)bytes<sizeof(systembuf));
void *addr_v = mmap(0, file_size, PROT_READ, MAP_PRIVATE, fd, 0); int r = system(systembuf);
assert(addr_v!=MAP_FAILED); assert(r!=-1);
char *fstr = addr_v; if (r>0) r = -1;
int searchlen=strlen(str); return r;
int i;
for (i=0; i+searchlen<file_size; i++) {
if (memcmp(str, fstr+i, searchlen)==0) {
return i;
}
}
return -1;
} }
int int
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment