Browse Source

* Enable gprof support

tags/0.2.7
Vsevolod Stakhov 15 years ago
parent
commit
6cb3a85919
4 changed files with 27 additions and 2 deletions
  1. 8
    0
      CMakeLists.txt
  2. 2
    0
      config.h.in
  3. 1
    2
      src/main.c
  4. 16
    0
      src/worker.c

+ 8
- 0
CMakeLists.txt View File

@@ -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

+ 2
- 0
config.h.in View File

@@ -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}"


+ 1
- 2
src/main.c View File

@@ -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);
}

+ 16
- 0
src/worker.c View File

@@ -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;

Loading…
Cancel
Save