1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82
|
/*
* asmail is the AfterStep mailbox monitor
* Copyright (c) 2002-2006 Albert Dorofeev <albert@tigr.net>
* For the updates see http://www.tigr.net/
*
* This software is distributed under GPL. For details see LICENSE file.
*/
#include <pthread.h>
#include "globals.h"
#include <errno.h>
char config_file_name[MAX_INPUT_LENGTH+1] = "";
int flag_verbose = 0;
int flag_allow_insecure = 0;
int flag_no_x = 0;
int flag_no_config = 0;
int flag_config_specified = 0;
struct x11_set_struct x11_set;
struct mbox_struct * mbox = NULL;
pthread_mutex_t update_lock;
pthread_cond_t update_cv;
int update_count = 0;
void signal_update() {
pthread_mutex_lock(&update_lock);
++update_count;
pthread_mutex_unlock(&update_lock);
/* pthread_cond_signal(&update_cv); */
pthread_cond_broadcast(&update_cv);
}
int sleep_update( const int centisec ) {
struct timespec tv;
int result;
clock_gettime(CLOCK_REALTIME, &tv);
tv.tv_sec += centisec / 100;
tv.tv_nsec += centisec % 100 * 10000000;
if ( tv.tv_nsec >= 1000000000 ) {
tv.tv_sec += 1;
tv.tv_nsec -= 1000000000;
}
pthread_mutex_lock(&update_lock);
result = pthread_cond_timedwait(&update_cv, &update_lock, &tv);
pthread_mutex_unlock(&update_lock);
if ( result == ETIMEDOUT )
return 0;
else
return 1;
}
pthread_mutex_t md5_lock;
pthread_mutex_t check_lock;
pthread_cond_t check_cv;
int check_count = 0;
void signal_check() {
pthread_mutex_lock(&check_lock);
++check_count;
pthread_mutex_unlock(&check_lock);
pthread_cond_broadcast(&check_cv);
}
int sleep_check( const int sec ) {
time_t t;
struct timespec tv;
int result;
time(&t);
tv.tv_sec = t + sec;
tv.tv_nsec = 0;
pthread_mutex_lock(&check_lock);
result = pthread_cond_timedwait(&check_cv, &check_lock, &tv);
pthread_mutex_unlock(&check_lock);
if ( result == ETIMEDOUT )
return 0;
else
return 1;
}
|