diff options
Diffstat (limited to 'accel-pptpd')
-rw-r--r-- | accel-pptpd/CMakeLists.txt | 13 | ||||
-rw-r--r-- | accel-pptpd/extra/sigchld.c | 1 | ||||
-rw-r--r-- | accel-pptpd/include/linux_ppp.h | 2 | ||||
-rw-r--r-- | accel-pptpd/logs/CMakeLists.txt | 2 | ||||
-rw-r--r-- | accel-pptpd/logs/log_file.c | 1 | ||||
-rw-r--r-- | accel-pptpd/triton/CMakeLists.txt | 19 | ||||
-rw-r--r-- | accel-pptpd/triton/timer.c | 36 | ||||
-rw-r--r-- | accel-pptpd/triton/timerfd.c | 19 | ||||
-rw-r--r-- | accel-pptpd/triton/timerfd.h | 60 |
9 files changed, 137 insertions, 16 deletions
diff --git a/accel-pptpd/CMakeLists.txt b/accel-pptpd/CMakeLists.txt index b234cba..fb88d1b 100644 --- a/accel-pptpd/CMakeLists.txt +++ b/accel-pptpd/CMakeLists.txt @@ -1,3 +1,16 @@ +INCLUDE(CheckLibraryExists) +INCLUDE(CheckIncludeFiles) + +CHECK_LIBRARY_EXISTS(ssl MD5_Init "" HAVE_SSL) +IF (NOT HAVE_SSL) + MESSAGE(FATAL_ERROR "openssl library not found") +ENDIF (NOT HAVE_SSL) + +CHECK_INCLUDE_FILES("openssl/md5.h" HAVE_SSL) +IF (NOT HAVE_SSL) + MESSAGE(FATAL_ERROR "openssl headers not found") +ENDIF (NOT HAVE_SSL) + SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -fvisibility=hidden -D_GNU_SOURCE -DGCC_SPINLOCK -DMEMDEBUG") INCLUDE_DIRECTORIES(include) diff --git a/accel-pptpd/extra/sigchld.c b/accel-pptpd/extra/sigchld.c index 49bcfd4..240b0dd 100644 --- a/accel-pptpd/extra/sigchld.c +++ b/accel-pptpd/extra/sigchld.c @@ -2,7 +2,6 @@ #include <string.h> #include <errno.h> #include <signal.h> -#include <sys/signalfd.h> #include <sys/wait.h> #include "triton.h" diff --git a/accel-pptpd/include/linux_ppp.h b/accel-pptpd/include/linux_ppp.h index 560d043..ebb4c23 100644 --- a/accel-pptpd/include/linux_ppp.h +++ b/accel-pptpd/include/linux_ppp.h @@ -11,9 +11,9 @@ #define __aligned_u64 __u64 __attribute__((aligned(8))) #endif +#include <linux/ppp_defs.h> #include <linux/if.h> #include <linux/if_ppp.h> -#include <linux/ppp_defs.h> #endif diff --git a/accel-pptpd/logs/CMakeLists.txt b/accel-pptpd/logs/CMakeLists.txt index de66b1e..b2c432d 100644 --- a/accel-pptpd/logs/CMakeLists.txt +++ b/accel-pptpd/logs/CMakeLists.txt @@ -1,5 +1,5 @@ ADD_LIBRARY(log_file SHARED log_file.c) -TARGET_LINK_LIBRARIES(log_file aio rt) +TARGET_LINK_LIBRARIES(log_file rt) INSTALL(TARGETS log_file LIBRARY DESTINATION usr/lib/accel-pptp diff --git a/accel-pptpd/logs/log_file.c b/accel-pptpd/logs/log_file.c index be615ad..f343286 100644 --- a/accel-pptpd/logs/log_file.c +++ b/accel-pptpd/logs/log_file.c @@ -6,7 +6,6 @@ #include <unistd.h> #include <limits.h> #include <aio.h> -#include <sys/signalfd.h> #include "log.h" #include "events.h" diff --git a/accel-pptpd/triton/CMakeLists.txt b/accel-pptpd/triton/CMakeLists.txt index 8e9fd35..e9133ae 100644 --- a/accel-pptpd/triton/CMakeLists.txt +++ b/accel-pptpd/triton/CMakeLists.txt @@ -9,6 +9,25 @@ SET(sources_c event.c ) +INCLUDE(CheckFunctionExists) +CHECK_FUNCTION_EXISTS(timerfd_create HAVE_TIMERFD) + +IF (HAVE_TIMERFD) + ADD_DEFINITIONS(-DHAVE_TIMERFD) +ELSE (HAVE_TIMERFD) + INCLUDE (CheckCSourceCompiles) + CHECK_C_SOURCE_COMPILES(" + #include <sys/syscall.h> + int main() + { + syscall(SYS_timerfd_create); + }" HAVE_SYSCALL) + IF (NOT HAVE_SYSCALL) + MESSAGE(FATAL_ERROR "Your system is too old and is not supported by accel-pptp, sorry...") + ENDIF (NOT HAVE_SYSCALL) + SET(sources_c ${sources_c} timerfd.c) +ENDIF (HAVE_TIMERFD) + INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}) ADD_DEFINITIONS(-DMODULE_PATH="${CMAKE_INSTALL_PREFIX}/usr/lib/accel-pptp") diff --git a/accel-pptpd/triton/timer.c b/accel-pptpd/triton/timer.c index cbf2b13..43cb56f 100644 --- a/accel-pptpd/triton/timer.c +++ b/accel-pptpd/triton/timer.c @@ -2,10 +2,16 @@ #include <stdlib.h> #include <sys/time.h> #include <sys/epoll.h> -#include <sys/timerfd.h> #include <string.h> #include <errno.h> #include <unistd.h> +#include <fcntl.h> + +#ifdef HAVE_TIMERFD +#include <sys/timerfd.h> +#else +#include "timerfd.h" +#endif #include "triton_p.h" @@ -94,6 +100,7 @@ void *timer_thread(void *arg) return NULL; } + int __export triton_timer_add(struct triton_context_t *ctx, struct triton_timer_t *ud, int abs_time) { struct _triton_timer_t *t = mempool_alloc(timer_pool); @@ -106,20 +113,22 @@ int __export triton_timer_add(struct triton_context_t *ctx, struct triton_timer_ t->ctx = (struct _triton_context_t *)ctx->tpd; else t->ctx = (struct _triton_context_t *)default_ctx->tpd; - t->fd = timerfd_create(CLOCK_MONOTONIC, TFD_NONBLOCK); + t->fd = timerfd_create(CLOCK_MONOTONIC, 0); if (t->fd < 0) { - triton_log_error("timer:timerfd_create: %s" ,strerror(errno)); + triton_log_error("timer:timerfd_create: %s", strerror(errno)); mempool_free(t); return -1; } + + if (fcntl(t->fd, F_SETFL, O_NONBLOCK)) { + triton_log_error("timer: failed to set nonblocking mode: %s\n", strerror(errno)); + goto out_err; + } ud->tpd = t; - if (triton_timer_mod(ud, abs_time)) { - close(t->fd); - mempool_free(t); - return -1; - } + if (triton_timer_mod(ud, abs_time)) + goto out_err; spin_lock(&t->ctx->lock); list_add_tail(&t->entry, &t->ctx->timers); @@ -131,15 +140,18 @@ int __export triton_timer_add(struct triton_context_t *ctx, struct triton_timer_ t->ud = NULL; list_del(&t->entry); spin_unlock(&t->ctx->lock); - close(t->fd); - mempool_free(t); - ud->tpd = NULL; - return -1; + goto out_err; } __sync_fetch_and_add(&triton_stat.timer_count, 1); return 0; + +out_err: + ud->tpd = NULL; + close(t->fd); + mempool_free(t); + return -1; } int __export triton_timer_mod(struct triton_timer_t *ud,int abs_time) { diff --git a/accel-pptpd/triton/timerfd.c b/accel-pptpd/triton/timerfd.c new file mode 100644 index 0000000..b026258 --- /dev/null +++ b/accel-pptpd/triton/timerfd.c @@ -0,0 +1,19 @@ +#include <fcntl.h> +#include <unistd.h> +#include <sys/syscall.h> + +#include "timerfd.h" + +int timerfd_create (clockid_t __clock_id, int __flags) +{ + return syscall(SYS_timerfd_create, __clock_id, __flags); +} + + +int timerfd_settime (int __ufd, int __flags, + __const struct itimerspec *__utmr, + struct itimerspec *__otmr) +{ + return syscall(SYS_timerfd_settime, __ufd, __flags, __utmr, __otmr); +} + diff --git a/accel-pptpd/triton/timerfd.h b/accel-pptpd/triton/timerfd.h new file mode 100644 index 0000000..c1bb06f --- /dev/null +++ b/accel-pptpd/triton/timerfd.h @@ -0,0 +1,60 @@ +/* Copyright (C) 2008 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#ifndef _SYS_TIMERFD_H +#define _SYS_TIMERFD_H 1 + +#include <time.h> + + +/* Bits to be set in the FLAGS parameter of `timerfd_create'. */ +enum + { + TFD_CLOEXEC = 02000000, +#define TFD_CLOEXEC TFD_CLOEXEC + TFD_NONBLOCK = 04000 +#define TFD_NONBLOCK TFD_NONBLOCK + }; + + +/* Bits to be set in the FLAGS parameter of `timerfd_settime'. */ +enum + { + TFD_TIMER_ABSTIME = 1 << 0 +#define TFD_TIMER_ABSTIME TFD_TIMER_ABSTIME + }; + + +__BEGIN_DECLS + +/* Return file descriptor for new interval timer source. */ +extern int timerfd_create (clockid_t __clock_id, int __flags) __THROW; + +/* Set next expiration time of interval timer source UFD to UTMR. If + FLAGS has the TFD_TIMER_ABSTIME flag set the timeout value is + absolute. Optionally return the old expiration time in OTMR. */ +extern int timerfd_settime (int __ufd, int __flags, + __const struct itimerspec *__utmr, + struct itimerspec *__otmr) __THROW; + +/* Return the next expiration time of UFD. */ +extern int timerfd_gettime (int __ufd, struct itimerspec *__otmr) __THROW; + +__END_DECLS + +#endif /* sys/timerfd.h */ |