aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@rambler-co.ru>2009-04-29 16:37:03 +0400
committerVsevolod Stakhov <vsevolod@rambler-co.ru>2009-04-29 16:37:03 +0400
commit6cb3a859197585047802ec6216b19a33c08db116 (patch)
tree2879715ffc1e4d42736053ceb3e92e5540030cfa
parent99caa0aca331669149c7b77b4a5d851a3e0a2b49 (diff)
downloadrspamd-6cb3a859197585047802ec6216b19a33c08db116.tar.gz
rspamd-6cb3a859197585047802ec6216b19a33c08db116.zip
* Enable gprof support
-rw-r--r--CMakeLists.txt8
-rw-r--r--config.h.in2
-rw-r--r--src/main.c3
-rw-r--r--src/worker.c16
4 files changed, 27 insertions, 2 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 3b89b265b..59537af11 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -22,6 +22,7 @@ OPTION(ENABLE_PERL "Enable perl support [default: OFF]"
OPTION(ENABLE_LUA "Enable lua support [default: OFF]" OFF)
OPTION(SKIP_RELINK_RPATH "Skip relinking and full RPATH for the install tree" OFF)
OPTION(ENABLE_REDIRECTOR "Enable redirector install [default: OFF]" OFF)
+OPTION(ENABLE_PROFILING "Enable profiling [default: OFF]" OFF)
# Build optimized code for following CPU (default i386)
#SET(CPU_TUNE "i686")
@@ -136,6 +137,13 @@ IF(NOT LIBEVENT_LIBRARY)
MESSAGE(FATAL_ERROR "libevent is required for building rspamd")
ENDIF(NOT LIBEVENT_LIBRARY)
+IF(ENABLE_PROFILING MATCHES "ON")
+ SET(WITH_PROFILER 1)
+ SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -pg")
+ SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -pg")
+ENDIF(ENABLE_PROFILING MATCHES "ON")
+
+
FIND_PATH(LIBEVENT_INCLUDE event.h PATHS /opt/include
/usr/include
/usr/local/include
diff --git a/config.h.in b/config.h.in
index 1fd8a5361..14530362f 100644
--- a/config.h.in
+++ b/config.h.in
@@ -99,6 +99,8 @@
#cmakedefine WITH_LUA 1
+#cmakedefine WITH_PROFILER 1
+
#define RVERSION "${RSPAMD_VERSION}"
#define RSPAMD_MASTER_SITE_URL "${RSPAMD_MASTER_SITE_URL}"
diff --git a/src/main.c b/src/main.c
index 2bc79cf14..bb8028441 100644
--- a/src/main.c
+++ b/src/main.c
@@ -687,8 +687,7 @@ main (int argc, char **argv, char **env)
}
msg_info ("main: terminating...");
-
-
+
if (rspamd->cfg->bind_family == AF_UNIX) {
unlink (rspamd->cfg->bind_host);
}
diff --git a/src/worker.c b/src/worker.c
index 20e04ed5e..ee00bb63b 100644
--- a/src/worker.c
+++ b/src/worker.c
@@ -53,7 +53,11 @@ void sig_handler (int signo)
switch (signo) {
case SIGINT:
case SIGTERM:
+#ifdef WITH_PROFILER
+ exit (0);
+#else
_exit (1);
+#endif
break;
}
}
@@ -293,6 +297,18 @@ start_worker (struct rspamd_worker *worker, int listen_sock)
{
struct sigaction signals;
int i;
+#ifdef WITH_PROFILER
+ extern void _start (void), etext (void);
+ monstartup ((u_long) &_start, (u_long) &etext);
+#endif
+#if 0
+ /* Try to create temp directory for gmon.out and chdir to it */
+ char prof_dir[PATH_MAX];
+ snprintf (prof_dir, sizeof (prof_dir), "%s/rspamd-prof-%d", worker->srv->cfg->temp_dir, (int)getpid ());
+ if (mkdir (prof_dir, S_IRUSR | S_IWUSR | S_IXUSR | S_IXOTH | S_IROTH | S_IXGRP | S_IRGRP) != -1) {
+ chdir (prof_dir);
+ }
+#endif
worker->srv->pid = getpid ();
worker->srv->type = TYPE_WORKER;