Created
July 16, 2013 05:11
-
-
Save BohuTANG/6005951 to your computer and use it in GitHub Desktop.
nessDB solaris patch, from fc
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/Makefile b/Makefile | |
index 5631c4d..0e1e04e 100644 | |
--- a/Makefile | |
+++ b/Makefile | |
@@ -1,9 +1,9 @@ | |
CC = gcc | |
#debug levle | |
-DOG = -rdynamic -DDOG | |
-DEBUG = -g -ggdb -DINFO $(DOG) | |
-CFLAGS = -c -std=c99 -W -Wall -Werror -fPIC $(DEBUG) $(BGMERGE) | |
+DOG = | |
+DEBUG = | |
+CFLAGS = -c -std=c99 -fPIC $(DEBUG) $(BGMERGE) | |
LIB_OBJS = \ | |
./engine/xmalloc.o\ | |
@@ -31,7 +31,7 @@ LIBRARY = libnessdb.so | |
all: $(LIBRARY) | |
clean: | |
- -rm -f $(LIBRARY) | |
+ -rm -f $(LIBRARY) | |
-rm -f $(LIB_OBJS) | |
-rm -f $(EXE) | |
-rm -f $(TEST) | |
diff --git a/engine/debug.c b/engine/debug.c | |
index d014eb6..24f9caf 100644 | |
--- a/engine/debug.c | |
+++ b/engine/debug.c | |
@@ -9,49 +9,49 @@ | |
#define EVENT_NAME "ness.event" | |
-void __debug_raw(int level, const char *msg, | |
- char *file, int line) | |
+void __debug_raw(int level, const char *msg, | |
+ char *file, int line) | |
{ | |
const char *c = ".-*#"; | |
time_t now = time(NULL); | |
FILE *fp; | |
char buf[64]; | |
- strftime(buf, sizeof(buf), "%d %b %I:%M:%S", | |
+ strftime(buf, sizeof(buf), "%d %b %I:%M:%S", | |
localtime(&now)); | |
if (level == LEVEL_ERROR) { | |
- | |
+ | |
fp = fopen(EVENT_NAME, "a"); | |
- if (fp) { | |
- fprintf(stderr, "[%d] %s %c %s, os-error:%s %s:%d\n", | |
- (int)getpid(), | |
- buf, | |
- c[level], | |
- msg, | |
- strerror(errno), | |
- file, | |
+ if (fp) { | |
+ fprintf(stderr, "[%d] %s %c %s, os-error:%s %s:%d\n", | |
+ (int)getpid(), | |
+ buf, | |
+ c[level], | |
+ msg, | |
+ strerror(errno), | |
+ file, | |
line); | |
- fprintf(fp, "[%d] %s %c %s, os-error:%s %s:%d\n", | |
+ fprintf(fp, "[%d] %s %c %s, os-error:%s %s:%d\n", | |
(int)getpid(), | |
buf, | |
c[level], | |
msg, | |
- strerror(errno), | |
- file, | |
+ strerror(errno), | |
+ file, | |
line); | |
fflush(fp); | |
fclose(fp); | |
} | |
} else | |
- fprintf(stderr, "[%d] %s %c %s \n", | |
- (int)getpid(), | |
- buf, | |
- c[level], | |
+ fprintf(stderr, "[%d] %s %c %s \n", | |
+ (int)getpid(), | |
+ buf, | |
+ c[level], | |
msg); | |
} | |
-void __debug(char *file, int line, | |
+void __debug(char *file, int line, | |
DEBUG_LEVEL level, const char *fmt, ...) | |
{ | |
va_list ap; | |
@@ -63,79 +63,3 @@ void __debug(char *file, int line, | |
__debug_raw((int)level, msg, file, line); | |
} | |
- | |
- | |
-static void *__get_context_eip(ucontext_t *uc) | |
-{ | |
-#if defined(__APPLE__) && !defined(MAC_OS_X_VERSION_10_6) | |
- /* OSX < 10.6 */ | |
- #if defined(__x86_64__) | |
- return (void *) uc->uc_mcontext->__ss.__rip; | |
- #elif defined(__i386__) | |
- return (void *) uc->uc_mcontext->__ss.__eip; | |
- #else | |
- return (void *) uc->uc_mcontext->__ss.__srr0; | |
- #endif | |
-#elif defined(__APPLE__) && defined(MAC_OS_X_VERSION_10_6) | |
- /* OSX >= 10.6 */ | |
- #if defined(_STRUCT_X86_THREAD_STATE64) && !defined(__i386__) | |
- return (void *) uc->uc_mcontext->__ss.__rip; | |
- #else | |
- return (void *) uc->uc_mcontext->__ss.__eip; | |
- #endif | |
-#elif defined(__linux__) | |
- /* Linux */ | |
- #if defined(__i386__) | |
- return (void *) uc->uc_mcontext.gregs[14]; /* Linux 32 */ | |
- #elif defined(__X86_64__) || defined(__x86_64__) | |
- return (void *) uc->uc_mcontext.gregs[16]; /* Linux 64 */ | |
- #elif defined(__ia64__) /* Linux IA64 */ | |
- return (void *) uc->uc_mcontext.sc_ip; | |
- #endif | |
-#else | |
- return NULL; | |
-#endif | |
-} | |
- | |
-void __log_stacktrace(ucontext_t *uc) | |
-{ | |
- void *trace[100]; | |
- int trace_size = 0, fd; | |
- | |
- fd = open(EVENT_NAME, O_APPEND | O_CREAT | O_WRONLY, 0644); | |
- if (fd == -1) | |
- return; | |
- | |
- /* Generate the stack trace */ | |
- trace_size = backtrace(trace, 100); | |
- | |
- /* overwrite sigaction with caller's address */ | |
- if (__get_context_eip(uc) != NULL) | |
- trace[1] = __get_context_eip(uc); | |
- | |
- /* Write symbols to log file */ | |
- backtrace_symbols_fd(trace, trace_size, fd); | |
- close(fd); | |
- exit(EXIT_FAILURE); | |
-} | |
- | |
-void __dog_signal(int sig, siginfo_t *info, void *secret) | |
-{ | |
- (void)sig; | |
- (void)info; | |
- | |
- ucontext_t *uc = (ucontext_t *) secret; | |
- __log_stacktrace(uc); | |
-} | |
- | |
-void __DEBUG_INIT_SIGNAL() | |
-{ | |
- struct sigaction act; | |
- | |
- /* Watchdog was actually disabled, so we have to setup the signal | |
- * handler. */ | |
- sigemptyset(&act.sa_mask); | |
- act.sa_flags = SA_NODEFER | SA_ONSTACK | SA_SIGINFO; | |
- act.sa_sigaction = __dog_signal; | |
- sigaction(SIGSEGV, &act, NULL); | |
-} | |
diff --git a/engine/internal.h b/engine/internal.h | |
index bfca0ee..2c3f8ed 100644 | |
--- a/engine/internal.h | |
+++ b/engine/internal.h | |
@@ -10,14 +10,14 @@ | |
#if defined(__linux__) || defined(__OpenBSD__) || defined(__NetBSD__) | |
#define _XOPEN_SOURCE 700 | |
#else | |
-#define _XOPEN_SOURCE | |
+//#define _XOPEN_SOURCE | |
#endif | |
#define _LARGEFILE_SOURCE | |
#define _FILE_OFFSET_BITS 64 | |
#ifndef O_BINARY | |
-#define O_BINARY (0) | |
+#define O_BINARY (0) | |
#endif | |
#include <stdio.h> | |
@@ -36,7 +36,6 @@ | |
#include <sys/stat.h> | |
#include <execinfo.h> | |
#include <signal.h> | |
-#include <ucontext.h> | |
#include <time.h> | |
#include <sys/time.h> | |
#include <stdarg.h> | |
@@ -63,7 +62,7 @@ | |
#define NESSDB_VERSION ("v2.0") /* nessDB version flag */ | |
#define NESSDB_SST_SEGMENT (4) /* SST splited numbers */ | |
-#define NESSDB_PATH_SIZE (1024) /* Max length of path */ | |
+#define NESSDB_PATH_SIZE (1024) /* Max length of path */ | |
#define NESSDB_MAX_VAL_SIZE (1024*1024*10) /* Max value length */ | |
#define NESSDB_COMPRESS_LIMIT (1024) /* Flag of compression */ | |
@@ -76,7 +75,7 @@ | |
#define LEVEL_BASE (4) | |
#define L0_SIZE (256*1024) | |
#define BLOCK_GAP (256) | |
-#define NESSDB_MAX_KEY_SIZE (36) | |
+#define NESSDB_MAX_KEY_SIZE (36) | |
#define NESSDB_SST_EXT (".SST") | |
#define NESSDB_DB ("ness.DB") | |
@@ -104,7 +103,7 @@ struct stats { | |
unsigned long long STATS_LEVEL_MERGES; /* all counts #levels merge */ | |
unsigned long long STATS_SST_SPLITS; /* all counts #SST split */ | |
unsigned long long STATS_SST_MERGEONE; /* all counts #SST merge to one */ | |
- time_t STATS_START_TIME; | |
+ time_t STATS_START_TIME; | |
double STATS_DB_WASTED; | |
}; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment