summaryrefslogtreecommitdiff
path: root/src/common/core.c
diff options
context:
space:
mode:
authorcelest <celest@54d463be-8e91-2dee-dedb-b68131a5f0ec>2005-02-22 16:08:24 +0000
committercelest <celest@54d463be-8e91-2dee-dedb-b68131a5f0ec>2005-02-22 16:08:24 +0000
commitf65bf4bd28cd9240c889bfd2a1f4650d91760a2d (patch)
tree6730a4d5ca802cc2c4cdb128dca07f1e95cac0fb /src/common/core.c
parent6b0b62a5b2a9d85f60afe4fe048403101bd8f39d (diff)
downloadhercules-f65bf4bd28cd9240c889bfd2a1f4650d91760a2d.tar.gz
hercules-f65bf4bd28cd9240c889bfd2a1f4650d91760a2d.tar.bz2
hercules-f65bf4bd28cd9240c889bfd2a1f4650d91760a2d.tar.xz
hercules-f65bf4bd28cd9240c889bfd2a1f4650d91760a2d.zip
* Corrected Spiral Pierce's hits in the skill_db
* Moved /common/*.o into a obj folder when compiling * Updated core and map server to jA 1094~1115 git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/branches/stable@1162 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src/common/core.c')
-rw-r--r--src/common/core.c74
1 files changed, 35 insertions, 39 deletions
diff --git a/src/common/core.c b/src/common/core.c
index fbd607080..016ade08d 100644
--- a/src/common/core.c
+++ b/src/common/core.c
@@ -9,10 +9,13 @@
#include <signal.h>
#include <string.h>
#ifdef DUMPSTACK
-#include <execinfo.h>
+ #ifndef _WIN32 // HAVE_EXECINFO_H
+ #include <execinfo.h>
+ #endif
#endif
#include "../common/mmo.h"
+#include "malloc.h"
#include "core.h"
#include "socket.h"
#include "timer.h"
@@ -92,44 +95,44 @@ static void sig_proc(int sn)
* Dumps the stack using glibc's backtrace
*-----------------------------------------
*/
-#ifdef DUMPSTACK
static void sig_dump(int sn)
{
- FILE *fp;
- void* array[20];
+ #ifdef DUMPSTACK
+ FILE *fp;
+ void* array[20];
- char **stack;
- size_t size;
- int no = 0;
- char tmp[256];
+ char **stack;
+ size_t size;
+ int no = 0;
+ char tmp[256];
- // search for a usable filename
- do {
- sprintf(tmp,"save/stackdump_%04d.txt", ++no);
- } while((fp = fopen(tmp,"r")) && (fclose(fp), no < 9999));
- // dump the trace into the file
- if ((fp = fopen (tmp,"w")) != NULL) {
+ // search for a usable filename
+ do {
+ sprintf(tmp,"save/stackdump_%04d.txt", ++no);
+ } while((fp = fopen(tmp,"r")) && (fclose(fp), no < 9999));
+ // dump the trace into the file
+ if ((fp = fopen (tmp,"w")) != NULL) {
- fprintf(fp,"Exception: %s\n", strsignal(sn));
- fprintf(fp,"Stack trace:\n");
- size = backtrace (array, 20);
- stack = backtrace_symbols (array, size);
+ fprintf(fp,"Exception: %s\n", strsignal(sn));
+ fprintf(fp,"Stack trace:\n");
+ size = backtrace (array, 20);
+ stack = backtrace_symbols (array, size);
- for (no = 0; no < size; no++) {
+ for (no = 0; no < size; no++) {
- fprintf(fp, "%s\n", stack[no]);
+ fprintf(fp, "%s\n", stack[no]);
- }
- fprintf(fp,"End of stack trace\n");
+ }
+ fprintf(fp,"End of stack trace\n");
- fclose(fp);
- free(stack);
- }
+ fclose(fp);
+ free(stack);
+ }
+ #endif
// When pass the signal to the system's default handler
compat_signal(sn, SIG_DFL);
raise(sn);
}
-#endif
int get_svn_revision(char *svnentry) { // Warning: minor syntax checking
char line[1024];
@@ -204,28 +207,20 @@ int main(int argc,char **argv)
compat_signal(SIGPIPE,SIG_IGN);
compat_signal(SIGTERM,sig_proc);
compat_signal(SIGINT,sig_proc);
-
-#ifndef DUMPSTACK
- // Signal to create coredumps by system when necessary (crash)
- compat_signal(SIGSEGV, SIG_DFL);
- compat_signal(SIGFPE, SIG_DFL);
- compat_signal(SIGILL, SIG_DFL);
- #ifndef _WIN32
- compat_signal(SIGBUS, SIG_DFL);
- compat_signal(SIGTRAP, SIG_DFL);
- #endif
-#else
+
+ // Signal to create coredumps by system when necessary (crash)
compat_signal(SIGSEGV, sig_dump);
compat_signal(SIGFPE, sig_dump);
compat_signal(SIGILL, sig_dump);
#ifndef _WIN32
compat_signal(SIGBUS, sig_dump);
- compat_signal(SIGTRAP, SIG_DFL);
+ compat_signal(SIGTRAP, SIG_DFL);
#endif
-#endif
display_title();
+ do_init_memmgr(argv[0]); // 一番最初に実行する必要がある
+
tick_ = time(0);
do_init(argc,argv);
@@ -234,5 +229,6 @@ int main(int argc,char **argv)
do_sendrecv(next);
do_parsepacket();
}
+
return 0;
}