Use wrapped threading functions in ha plugin
This commit is contained in:
@@ -21,8 +21,8 @@
|
|||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <pthread.h>
|
|
||||||
|
|
||||||
|
#include <threading/thread.h>
|
||||||
#include <processing/jobs/callback_job.h>
|
#include <processing/jobs/callback_job.h>
|
||||||
|
|
||||||
#define HA_FIFO IPSEC_PIDDIR "/charon.ha"
|
#define HA_FIFO IPSEC_PIDDIR "/charon.ha"
|
||||||
@@ -60,13 +60,14 @@ struct private_ha_ctl_t {
|
|||||||
*/
|
*/
|
||||||
static job_requeue_t dispatch_fifo(private_ha_ctl_t *this)
|
static job_requeue_t dispatch_fifo(private_ha_ctl_t *this)
|
||||||
{
|
{
|
||||||
int fifo, old;
|
int fifo;
|
||||||
|
bool oldstate;
|
||||||
char buf[8];
|
char buf[8];
|
||||||
u_int segment;
|
u_int segment;
|
||||||
|
|
||||||
pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, &old);
|
oldstate = thread_cancelability(TRUE);
|
||||||
fifo = open(HA_FIFO, O_RDONLY);
|
fifo = open(HA_FIFO, O_RDONLY);
|
||||||
pthread_setcancelstate(old, NULL);
|
thread_cancelability(oldstate);
|
||||||
if (fifo == -1)
|
if (fifo == -1)
|
||||||
{
|
{
|
||||||
DBG1(DBG_CFG, "opening HA fifo failed: %s", strerror(errno));
|
DBG1(DBG_CFG, "opening HA fifo failed: %s", strerror(errno));
|
||||||
|
|||||||
@@ -15,11 +15,10 @@
|
|||||||
|
|
||||||
#include "ha_segments.h"
|
#include "ha_segments.h"
|
||||||
|
|
||||||
#include <pthread.h>
|
|
||||||
|
|
||||||
#include <threading/mutex.h>
|
#include <threading/mutex.h>
|
||||||
#include <threading/condvar.h>
|
#include <threading/condvar.h>
|
||||||
#include <utils/linked_list.h>
|
#include <utils/linked_list.h>
|
||||||
|
#include <threading/thread.h>
|
||||||
#include <processing/jobs/callback_job.h>
|
#include <processing/jobs/callback_job.h>
|
||||||
|
|
||||||
#define DEFAULT_HEARTBEAT_DELAY 1000
|
#define DEFAULT_HEARTBEAT_DELAY 1000
|
||||||
@@ -255,16 +254,15 @@ METHOD(listener_t, alert_hook, bool,
|
|||||||
*/
|
*/
|
||||||
static job_requeue_t watchdog(private_ha_segments_t *this)
|
static job_requeue_t watchdog(private_ha_segments_t *this)
|
||||||
{
|
{
|
||||||
int oldstate;
|
bool timeout, oldstate;
|
||||||
bool timeout;
|
|
||||||
|
|
||||||
this->mutex->lock(this->mutex);
|
this->mutex->lock(this->mutex);
|
||||||
pthread_cleanup_push((void*)this->mutex->unlock, this->mutex);
|
thread_cleanup_push((void*)this->mutex->unlock, this->mutex);
|
||||||
pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, &oldstate);
|
oldstate = thread_cancelability(TRUE);
|
||||||
timeout = this->condvar->timed_wait(this->condvar, this->mutex,
|
timeout = this->condvar->timed_wait(this->condvar, this->mutex,
|
||||||
this->heartbeat_timeout);
|
this->heartbeat_timeout);
|
||||||
pthread_setcancelstate(oldstate, NULL);
|
thread_cancelability(oldstate);
|
||||||
pthread_cleanup_pop(TRUE);
|
thread_cleanup_pop(TRUE);
|
||||||
if (timeout)
|
if (timeout)
|
||||||
{
|
{
|
||||||
DBG1(DBG_CFG, "no heartbeat received, taking all segments");
|
DBG1(DBG_CFG, "no heartbeat received, taking all segments");
|
||||||
|
|||||||
@@ -20,10 +20,10 @@
|
|||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <pthread.h>
|
|
||||||
|
|
||||||
#include <daemon.h>
|
#include <daemon.h>
|
||||||
#include <utils/host.h>
|
#include <utils/host.h>
|
||||||
|
#include <threading/thread.h>
|
||||||
#include <processing/jobs/callback_job.h>
|
#include <processing/jobs/callback_job.h>
|
||||||
|
|
||||||
typedef struct private_ha_socket_t private_ha_socket_t;
|
typedef struct private_ha_socket_t private_ha_socket_t;
|
||||||
@@ -121,12 +121,12 @@ METHOD(ha_socket_t, pull, ha_message_t*,
|
|||||||
{
|
{
|
||||||
ha_message_t *message;
|
ha_message_t *message;
|
||||||
char buf[1024];
|
char buf[1024];
|
||||||
int oldstate;
|
bool oldstate;
|
||||||
ssize_t len;
|
ssize_t len;
|
||||||
|
|
||||||
pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, &oldstate);
|
oldstate = thread_cancelability(TRUE);
|
||||||
len = recv(this->fd, buf, sizeof(buf), 0);
|
len = recv(this->fd, buf, sizeof(buf), 0);
|
||||||
pthread_setcancelstate(oldstate, NULL);
|
thread_cancelability(oldstate);
|
||||||
if (len <= 0)
|
if (len <= 0)
|
||||||
{
|
{
|
||||||
switch (errno)
|
switch (errno)
|
||||||
|
|||||||
Reference in New Issue
Block a user