Philip Martin <philip.martin_at_wandisco.com> writes:
> Still it's hard to ignore the performance gain. Perhaps we could make
> it (whispers) configurable?
Here's a simple Linux LD_PRELOAD version of the patch. Build it as a
shared library and then the feature can be enabled on any given svn
invocation by setting the environment variable.
/*
Compile like so:
gcc -rdynamic -fPIC -O2 -Wall -shared -o libxxxx.so xxxx.c -ldl
Use like so:
LD_PRELOAD=$PWD/libxxxx.so svn co http://example.com/repo/trunk wc
*/
#include <stdio.h>
#include <stdlib.h>
#include <dlfcn.h>
#include <string.h>
#include <unistd.h>
struct sqlite3;
int sqlite3_open_v2(const char *filename, struct sqlite3 **ppDb, int flags,
const char *zVfs)
{
static int (*sqlite_sqlite3_open_v2)(const char *, struct sqlite3 **, int,
const char *) = NULL;
static int (*sqlite_sqlite3_exec)(struct sqlite3 *, const char *,
int (*)(void *, int, char *, char **),
void *, char **);
int status;
if (!sqlite_sqlite3_open_v2) {
void *handle = dlopen("libsqlite3.so.0", RTLD_LAZY);
if (!handle) {
char *error = dlerror();
fprintf(stderr, "dlopen: %s\n", error ? error : "null");
exit(1);
}
sqlite_sqlite3_open_v2 = dlsym(handle, "sqlite3_open_v2");
char *error = dlerror();
if (error || !sqlite_sqlite3_open_v2) {
fprintf(stderr, "dlsym(open_v2): %s\n", error ? error : "null");
exit(1);
}
sqlite_sqlite3_exec = dlsym(handle, "sqlite3_exec");
error = dlerror();
if (error || !sqlite_sqlite3_exec) {
fprintf(stderr, "dlsym(exec): %s\n", error ? error : "null");
exit(1);
}
}
status = sqlite_sqlite3_open_v2(filename, ppDb, flags, zVfs);
if (!status) {
char *error;
if (sqlite_sqlite3_exec(*ppDb, "pragma locking_mode = exclusive",
NULL, NULL, &error)) {
fprintf(stderr, "sqlite3_exec: %s\n", error ? error : "null");
exit(1);
}
}
return status;
}
--
uberSVN: Apache Subversion Made Easy
http://www.uberSVN.com
Received on 2012-02-14 17:38:58 CET