Ticket #1147: mlockall-autoconf-02.patch

File mlockall-autoconf-02.patch, 1.4 KB (added by ioerror, 10 years ago)

A more elegant patch that only tries to link if we actually have mlockall

  • configure.in

    diff --git a/configure.in b/configure.in
    index 7ffa578..d3487dd 100644
    a b if test x$tcmalloc = xyes ; then 
    628628   LDFLAGS="-ltcmalloc $LDFLAGS"
    629629fi
    630630
     631# By default, we're going to assume we don't have mlockall()
     632# bionic and other platforms have various broken mlockall subsystems
     633# some of systems don't have a working mlockall, some aren't linkable
     634AC_DEFINE([USE_MLOCKALL], [0], ["Does our platform have a linkable mlockall?"])
     635AC_CHECK_FUNCS(mlockall,
     636            AC_MSG_CHECKING([whether we can link mlockall])
     637            AC_TRY_LINK([#include <sys/mman.h>],
     638            [mlockall(MCL_CURRENT|MCL_FUTURE); return 0;],
     639            [AC_DEFINE(USE_MLOCKALL,[1]) AC_MSG_RESULT([yes])],
     640            [AC_DEFINE(USE_MLOCKALL,[0]) AC_MSG_RESULT([no])]))
     641
    631642# Allow user to specify an alternate syslog facility
    632643AC_ARG_WITH(syslog-facility,
    633644[  --with-syslog-facility=LOG syslog facility to use (default=LOG_DAEMON)],
  • src/common/compat.c

    diff --git a/src/common/compat.c b/src/common/compat.c
    index 9e5dca3..c2cfbd9 100644
    a b tor_mlockall(void) 
    22732273   * http://msdn.microsoft.com/en-us/library/aa366895(VS.85).aspx
    22742274   */
    22752275
    2276 #ifdef HAVE_SYS_MMAN_H
     2276#ifdef USE_MLOCKALL
    22772277  ret = tor_set_max_memlock();
    22782278  if (ret == 0) {
    22792279    /* Perhaps we only want to log this if we're in a verbose mode? */