some fixes
This commit is contained in:
parent
3690534459
commit
5a26ac47f4
1681
smmapdfw/aclocal.m4
vendored
1681
smmapdfw/aclocal.m4
vendored
File diff suppressed because it is too large
Load Diff
592
smmapdfw/config.guess
vendored
592
smmapdfw/config.guess
vendored
File diff suppressed because it is too large
Load Diff
@ -6,9 +6,6 @@
|
|||||||
/* enable Net-SNMP */
|
/* enable Net-SNMP */
|
||||||
#undef ENABLE_NETSNMP
|
#undef ENABLE_NETSNMP
|
||||||
|
|
||||||
/* enable stats */
|
|
||||||
#undef ENABLE_STATS
|
|
||||||
|
|
||||||
/* Define to 1 if you have the <arpa/inet.h> header file. */
|
/* Define to 1 if you have the <arpa/inet.h> header file. */
|
||||||
#undef HAVE_ARPA_INET_H
|
#undef HAVE_ARPA_INET_H
|
||||||
|
|
||||||
@ -174,10 +171,8 @@
|
|||||||
/* Define to `int' if <sys/types.h> does not define. */
|
/* Define to `int' if <sys/types.h> does not define. */
|
||||||
#undef pid_t
|
#undef pid_t
|
||||||
|
|
||||||
/* Define to `unsigned' if <sys/types.h> does not define. */
|
/* Define to `unsigned int' if <sys/types.h> does not define. */
|
||||||
#undef size_t
|
#undef size_t
|
||||||
|
|
||||||
/* Define as `fork' if `vfork' does not work. */
|
/* Define as `fork' if `vfork' does not work. */
|
||||||
#undef vfork
|
#undef vfork
|
||||||
|
|
||||||
|
|
||||||
|
5205
smmapdfw/configure
vendored
5205
smmapdfw/configure
vendored
File diff suppressed because it is too large
Load Diff
@ -170,15 +170,6 @@ dnl (default=no)])],
|
|||||||
dnl cyrus_BUILD=libcyrus_worker.la
|
dnl cyrus_BUILD=libcyrus_worker.la
|
||||||
dnl )
|
dnl )
|
||||||
|
|
||||||
ENABLE_STATS=0
|
|
||||||
AC_ARG_ENABLE(stats,
|
|
||||||
[AC_HELP_STRING(--enable-stats, [
|
|
||||||
Enables statistics collection.
|
|
||||||
(default=no)])],
|
|
||||||
if test "x$enableval" = xyes; then ENABLE_STATS=1; fi
|
|
||||||
if test "x$enableval" = xno; then ENABLE_STATS=0; fi
|
|
||||||
|
|
||||||
)
|
|
||||||
|
|
||||||
# Checks for programs.
|
# Checks for programs.
|
||||||
AC_PROG_CC
|
AC_PROG_CC
|
||||||
@ -266,7 +257,6 @@ if test "x$BDB_NOT_FOUND" = "x1"; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
AC_DEFINE_UNQUOTED(ENABLE_CACHE, ${ENABLE_CACHE}, [enable cache])
|
AC_DEFINE_UNQUOTED(ENABLE_CACHE, ${ENABLE_CACHE}, [enable cache])
|
||||||
AC_DEFINE_UNQUOTED(ENABLE_STATS, ${ENABLE_STATS}, [enable stats])
|
|
||||||
AC_DEFINE_UNQUOTED(ENABLE_NETSNMP, ${ENABLE_NETSNMP}, [enable Net-SNMP])
|
AC_DEFINE_UNQUOTED(ENABLE_NETSNMP, ${ENABLE_NETSNMP}, [enable Net-SNMP])
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
include_HEADERS=containers_public.h queue.h smtp.h cfg.h count.h safe_write.h sunos_comp.h htdns.h smmapd.h htmalloc.h stats.h htcache.h htbuffer.h
|
include_HEADERS=containers_public.h queue.h smtp.h cfg.h count.h safe_write.h sunos_comp.h htdns.h smmapd.h htmalloc.h stats.h htcache.h htbuffer.h dvl.h
|
||||||
lib_LTLIBRARIES = libsmmapdfw.la
|
lib_LTLIBRARIES = libsmmapdfw.la
|
||||||
libsmmapdfw_la_SOURCES = cfg.c queue.c count.c safe_write.c config_public.c htdns.c smtp.c htmalloc.c stats.c htcache.c htbuffer.c
|
libsmmapdfw_la_SOURCES = cfg.c queue.c count.c safe_write.c config_public.c htdns.c smtp.c htmalloc.c stats.c htcache.c htbuffer.c
|
||||||
libsmmapdfw_la_LIBADD = @BDB_LIBS@
|
libsmmapdfw_la_LIBADD = @BDB_LIBS@
|
||||||
|
@ -87,7 +87,7 @@ RC = @RC@
|
|||||||
STRIP = @STRIP@
|
STRIP = @STRIP@
|
||||||
VERSION = @VERSION@
|
VERSION = @VERSION@
|
||||||
|
|
||||||
include_HEADERS = containers_public.h queue.h smtp.h cfg.h count.h safe_write.h sunos_comp.h htdns.h smmapd.h htmalloc.h stats.h htcache.h htbuffer.h
|
include_HEADERS = containers_public.h queue.h smtp.h cfg.h count.h safe_write.h sunos_comp.h htdns.h smmapd.h htmalloc.h stats.h htcache.h htbuffer.h dvl.h
|
||||||
lib_LTLIBRARIES = libsmmapdfw.la
|
lib_LTLIBRARIES = libsmmapdfw.la
|
||||||
libsmmapdfw_la_SOURCES = cfg.c queue.c count.c safe_write.c config_public.c htdns.c smtp.c htmalloc.c stats.c htcache.c htbuffer.c
|
libsmmapdfw_la_SOURCES = cfg.c queue.c count.c safe_write.c config_public.c htdns.c smtp.c htmalloc.c stats.c htcache.c htbuffer.c
|
||||||
libsmmapdfw_la_LIBADD = @BDB_LIBS@
|
libsmmapdfw_la_LIBADD = @BDB_LIBS@
|
||||||
|
@ -102,18 +102,21 @@ int containers_dispatcher(container_handle_t *ch, char *input, htbuffer_t *outpu
|
|||||||
int result, err;
|
int result, err;
|
||||||
worker_handle_t *wh, *wh_last, *wh2;
|
worker_handle_t *wh, *wh_last, *wh2;
|
||||||
|
|
||||||
|
if (input == NULL) {
|
||||||
|
syslog(LOG_ERR, "dispatcher: no input at all");
|
||||||
|
return SMM_ILLEGAL_INPUT;
|
||||||
|
}
|
||||||
syslog(LOG_DEBUG, "dispatcher: input: %s", input);
|
syslog(LOG_DEBUG, "dispatcher: input: %s", input);
|
||||||
|
|
||||||
data = strchr(input, ' ');
|
data = strchr(input, ' ');
|
||||||
if (NULL == data) {
|
if (NULL == data || (strlen(data) < 1)) {
|
||||||
syslog(LOG_ERR, "dispatcher: illegal input (%s)", input);
|
syslog(LOG_ERR, "dispatcher: illegal input (%s)", input);
|
||||||
return SMM_ILLEGAL_INPUT;
|
return SMM_ILLEGAL_INPUT;
|
||||||
}
|
}
|
||||||
|
|
||||||
data++; /* skip the blank */
|
*data = '\0'; /* terminate class */
|
||||||
|
data++; /* skip the former blank, now null */
|
||||||
class = input;
|
class = input;
|
||||||
class[strlen(class)-strlen(data)-1] = '\0';
|
|
||||||
|
|
||||||
syslog(LOG_DEBUG, "dispatcher: class: %s, data: %s", class, data);
|
syslog(LOG_DEBUG, "dispatcher: class: %s, data: %s", class, data);
|
||||||
|
|
||||||
|
@ -73,6 +73,7 @@
|
|||||||
|
|
||||||
#include "sunos_comp.h"
|
#include "sunos_comp.h"
|
||||||
|
|
||||||
|
#include "dvl.h"
|
||||||
|
|
||||||
#define CFG_SECTION_GLOBAL "global"
|
#define CFG_SECTION_GLOBAL "global"
|
||||||
#define CFG_NAME_ADDRESS "address"
|
#define CFG_NAME_ADDRESS "address"
|
||||||
@ -129,20 +130,20 @@ typedef struct networkerThread_s networkerThread_t;
|
|||||||
ht_queue_t terminated_networker_queue;
|
ht_queue_t terminated_networker_queue;
|
||||||
pthread_t cleanerThread;
|
pthread_t cleanerThread;
|
||||||
|
|
||||||
#if ENABLE_STATS==1
|
|
||||||
pthread_t statsThread;
|
pthread_t statsThread;
|
||||||
#endif
|
|
||||||
|
|
||||||
#if ENABLE_NETSNMP==1
|
#if ENABLE_NETSNMP==1
|
||||||
pthread_t snmpThread;
|
pthread_t snmpThread;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
count_t thread_counter;
|
count_t thread_counter;
|
||||||
|
|
||||||
cfg_t *cfg;
|
cfg_t *cfg;
|
||||||
|
|
||||||
int netstring_disabled = 0;
|
int netstring_disabled = 0;
|
||||||
|
|
||||||
#if ENABLE_STATS==1
|
|
||||||
|
|
||||||
void * statser(void * arg) {
|
void * statser(void * arg) {
|
||||||
int stdout_nice = atoi(findcfgx(cfg, "stats", "stdout_nice", "0"));
|
int stdout_nice = atoi(findcfgx(cfg, "stats", "stdout_nice", "0"));
|
||||||
int syslog_nice = atoi(findcfgx(cfg, "stats", "syslog_nice", "0"));
|
int syslog_nice = atoi(findcfgx(cfg, "stats", "syslog_nice", "0"));
|
||||||
@ -153,7 +154,6 @@ void * statser(void * arg) {
|
|||||||
sleep(period);
|
sleep(period);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
#if ENABLE_NETSNMP==1
|
#if ENABLE_NETSNMP==1
|
||||||
void * snmper(void * arg) {
|
void * snmper(void * arg) {
|
||||||
@ -191,6 +191,10 @@ void * cleaner(void * arg) {
|
|||||||
|
|
||||||
#define OUTPUT_BUFSIZE ANSWER_BUFSIZE+25 /* a bit more than answer for the result text */
|
#define OUTPUT_BUFSIZE ANSWER_BUFSIZE+25 /* a bit more than answer for the result text */
|
||||||
void * networker(void * arg) {
|
void * networker(void * arg) {
|
||||||
|
if (arg == NULL) {
|
||||||
|
syslog(LOG_CRIT, "networker thread started with argument NULL, thread dies");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
char buffer[BUFSIZE+1];
|
char buffer[BUFSIZE+1];
|
||||||
char *input;
|
char *input;
|
||||||
@ -206,6 +210,7 @@ void * networker(void * arg) {
|
|||||||
|
|
||||||
|
|
||||||
networkerThread_t * thread = (networkerThread_t *) arg;
|
networkerThread_t * thread = (networkerThread_t *) arg;
|
||||||
|
|
||||||
thread->pthread = pthread_self();
|
thread->pthread = pthread_self();
|
||||||
|
|
||||||
incStatCounter(globalStatCounter, STAT_CNT_NETWORKER_THREADS);
|
incStatCounter(globalStatCounter, STAT_CNT_NETWORKER_THREADS);
|
||||||
@ -232,17 +237,23 @@ void * networker(void * arg) {
|
|||||||
input = buffer;
|
input = buffer;
|
||||||
} else {
|
} else {
|
||||||
len = strtol(buffer, &input, 10);
|
len = strtol(buffer, &input, 10);
|
||||||
if ((0 == len) && (buffer == input)) {
|
if (input == NULL) {
|
||||||
syslog(LOG_DEBUG, "networker: netstring unparsable, no length found: %s", buffer);
|
syslog(LOG_ERR, "networker:netstring unparsable, nothing remains after length");
|
||||||
|
dispatcher_result = SMM_NETSTRING_UNPARSABLE;
|
||||||
|
} else if ((0 == len) && (buffer == input)) {
|
||||||
|
syslog(LOG_ERR, "networker: netstring unparsable, no length found: %s", dvls(buffer));
|
||||||
dispatcher_result = SMM_NETSTRING_UNPARSABLE;
|
dispatcher_result = SMM_NETSTRING_UNPARSABLE;
|
||||||
} else if (*input++ != ':') {
|
} else if (*input++ != ':') {
|
||||||
syslog(LOG_DEBUG, "networker: netstring unparsable, no colon found: %s", buffer);
|
syslog(LOG_ERR, "networker: netstring unparsable, no colon found: %s", dvls(buffer));
|
||||||
|
dispatcher_result = SMM_NETSTRING_UNPARSABLE;
|
||||||
|
} else if (input == NULL) {
|
||||||
|
syslog(LOG_ERR, "networker:netstring unparsable, nothing remains after colon");
|
||||||
dispatcher_result = SMM_NETSTRING_UNPARSABLE;
|
dispatcher_result = SMM_NETSTRING_UNPARSABLE;
|
||||||
} else if (strlen(input)-1 != len) {
|
} else if (strlen(input)-1 != len) {
|
||||||
syslog(LOG_DEBUG, "networker: netstring unparsable, length does not match: %s", buffer);
|
syslog(LOG_ERR, "networker: netstring unparsable, length does not match: %s", dvls(buffer));
|
||||||
dispatcher_result = SMM_NETSTRING_UNPARSABLE;
|
dispatcher_result = SMM_NETSTRING_UNPARSABLE;
|
||||||
} else if (input[strlen(input)-1] != ',') {
|
} else if (input[strlen(input)-1] != ',') {
|
||||||
syslog(LOG_DEBUG, "networker: netstring unparsable, no terminating comma: %s", buffer);
|
syslog(LOG_ERR, "networker: netstring unparsable, no terminating comma: %s", dvls(buffer));
|
||||||
dispatcher_result = SMM_NETSTRING_UNPARSABLE;
|
dispatcher_result = SMM_NETSTRING_UNPARSABLE;
|
||||||
} else {
|
} else {
|
||||||
input[strlen(input)-1] = '\0'; /* strip off the comma */
|
input[strlen(input)-1] = '\0'; /* strip off the comma */
|
||||||
@ -250,10 +261,9 @@ void * networker(void * arg) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!dispatcher_result) {
|
if (!dispatcher_result) {
|
||||||
// answer[0] = '\0';
|
|
||||||
htbuffer_clear(answer);
|
htbuffer_clear(answer);
|
||||||
dispatcher_result = containers_dispatcher(container_handle, input, answer);
|
dispatcher_result = containers_dispatcher(container_handle, input, answer);
|
||||||
syslog(LOG_DEBUG, "networker: dispatcher result: %d, answer: %s", dispatcher_result, answer->buf);
|
syslog(LOG_DEBUG, "networker: dispatcher result: %d, answer: %s", dispatcher_result, dvls(answer->buf));
|
||||||
}
|
}
|
||||||
|
|
||||||
incStatCounter(globalStatCounter, dispatcher_result + STAT_CNT_OFFSET);
|
incStatCounter(globalStatCounter, dispatcher_result + STAT_CNT_OFFSET);
|
||||||
@ -289,7 +299,6 @@ void * networker(void * arg) {
|
|||||||
|
|
||||||
htbuffer_free(answer);
|
htbuffer_free(answer);
|
||||||
|
|
||||||
|
|
||||||
thread->result = 1;
|
thread->result = 1;
|
||||||
queue_put(&terminated_networker_queue, thread);
|
queue_put(&terminated_networker_queue, thread);
|
||||||
}
|
}
|
||||||
@ -353,21 +362,34 @@ int server() {
|
|||||||
|
|
||||||
count_init(&thread_counter);
|
count_init(&thread_counter);
|
||||||
queue_init(&terminated_networker_queue);
|
queue_init(&terminated_networker_queue);
|
||||||
pthread_create(&cleanerThread, NULL, &cleaner, NULL);
|
int cleanerStartRc = pthread_create(&cleanerThread, NULL, &cleaner, NULL);
|
||||||
|
if (0 != cleanerStartRc) {
|
||||||
|
syslog(LOG_ERR, "server: failure when starting cleaner thread: %d",
|
||||||
|
cleanerStartRc);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
#if ENABLE_STATS==1
|
|
||||||
enableStats = atoi(findcfgx(cfg, "global", "enable_stats", "0"));
|
enableStats = atoi(findcfgx(cfg, "global", "enable_stats", "0"));
|
||||||
if (enableStats) {
|
if (enableStats) {
|
||||||
syslog(LOG_INFO, "server: starting stats thread");
|
syslog(LOG_INFO, "server: starting stats thread");
|
||||||
pthread_create(&statsThread, NULL, &statser, NULL);
|
int staterStartRc = pthread_create(&statsThread, NULL, &statser, NULL);
|
||||||
|
if (0 != cleanerStartRc) {
|
||||||
|
syslog(LOG_ERR, "server: failure when starting stater thread: %d",
|
||||||
|
staterStartRc);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endif /* ENABLE_STATS */
|
|
||||||
|
|
||||||
#if ENABLE_NETSNMP==1
|
#if ENABLE_NETSNMP==1
|
||||||
enableSnmp = atoi(findcfgx(cfg, "global", "enable_snmp", "0"));
|
enableSnmp = atoi(findcfgx(cfg, "global", "enable_snmp", "0"));
|
||||||
if (enableSnmp) {
|
if (enableSnmp) {
|
||||||
syslog(LOG_INFO, "server: starting snmp subagent thread");
|
syslog(LOG_INFO, "server: starting snmp subagent thread");
|
||||||
pthread_create(&snmpThread, NULL, &snmper, NULL);
|
int snmperStartRc = pthread_create(&snmpThread, NULL, &snmper, NULL);
|
||||||
|
if (0 != snmperStartRc) {
|
||||||
|
syslog(LOG_ERR, "server: failure when starting snmper thread: %d",
|
||||||
|
snmperStartRc);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endif /* ENABLE_NETSNMP */
|
#endif /* ENABLE_NETSNMP */
|
||||||
|
|
||||||
@ -486,6 +508,7 @@ int main(int argc, char **argv) {
|
|||||||
server_setupCounterList();
|
server_setupCounterList();
|
||||||
globalStatCounter = initStatCounter("global", server_counterDefs);
|
globalStatCounter = initStatCounter("global", server_counterDefs);
|
||||||
|
|
||||||
|
|
||||||
if (0 != (err = server())) {
|
if (0 != (err = server())) {
|
||||||
syslog(LOG_ERR, "main: server fails: %d", err);
|
syslog(LOG_ERR, "main: server fails: %d", err);
|
||||||
exit(1);
|
exit(1);
|
||||||
|
@ -14,10 +14,10 @@ enable_snmp = 1
|
|||||||
; netstring_disabled = 1
|
; netstring_disabled = 1
|
||||||
|
|
||||||
[snmp]
|
[snmp]
|
||||||
agentx_socket = /var/agentx/master
|
agentx_socket = 127.0.0.1:9161
|
||||||
|
|
||||||
[stats]
|
[stats]
|
||||||
stdout_nice = 2
|
stdout_nice = 0
|
||||||
syslog_nice = 1
|
syslog_nice = 1
|
||||||
period = 1
|
period = 1
|
||||||
|
|
||||||
|
@ -36,6 +36,7 @@
|
|||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
|
#include <signal.h>
|
||||||
|
|
||||||
#include "htcache.h"
|
#include "htcache.h"
|
||||||
|
|
||||||
@ -88,6 +89,7 @@ void verify_setupCounterList() {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
struct verify_container_handle_s {
|
struct verify_container_handle_s {
|
||||||
cfgl_t *cfg;
|
cfgl_t *cfg;
|
||||||
statCounter_t *statCounter;
|
statCounter_t *statCounter;
|
||||||
@ -121,10 +123,30 @@ struct verify_work_handle_s {
|
|||||||
verify_result_t *result;
|
verify_result_t *result;
|
||||||
ht_queue_t *terminator_queue;
|
ht_queue_t *terminator_queue;
|
||||||
verify_container_handle_t *vch;
|
verify_container_handle_t *vch;
|
||||||
|
|
||||||
|
int whereAreWe1;
|
||||||
|
int whereAreWe2;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct verify_work_handle_s verify_work_handle_t;
|
typedef struct verify_work_handle_s verify_work_handle_t;
|
||||||
|
|
||||||
|
/* --- debugging ------------------------------------- */
|
||||||
|
verify_work_handle_t *lastVerifyWorkHandle = NULL;
|
||||||
|
void showLastVerifyWorkHandleDetails(int signum) {
|
||||||
|
printf("showLastVerifyWorkHandleDetails:\n");
|
||||||
|
printf(" address: %p\n, lastVerifyWorkHandle");
|
||||||
|
if (lastVerifyWorkHandle != NULL) {
|
||||||
|
printf(" debug step: %d\n", lastVerifyWorkHandle->whereAreWe1);
|
||||||
|
printf(" debug sub step: %d\n", lastVerifyWorkHandle->whereAreWe2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#define DEBUG_INSTALL do { signal(SIGUSR2, showLastVerifyWorkHandleDetails); } while(0)
|
||||||
|
#define DEBUG_INIT do { lastVerifyWorkHandle->whereAreWe1 = 0; lastVerifyWorkHandle->whereAreWe2 = 0; } while(0)
|
||||||
|
#define DEBUG_SUB_STEP_RESET do {lastVerifyWorkHandle->whereAreWe2 = 0; } while(0)
|
||||||
|
#define DEBUG_STEP do { lastVerifyWorkHandle->whereAreWe1++; } while(0)
|
||||||
|
#define DEBUG_SUB_STEP do { lastVerifyWorkHandle->whereAreWe2++; } while(0)
|
||||||
|
/* --------------------------------------------------- */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
struct checker_thread_s {
|
struct checker_thread_s {
|
||||||
@ -257,6 +279,8 @@ int verify_work_setup(void *handle, void **work_handle) {
|
|||||||
vwh->vch = (verify_container_handle_t*)handle;
|
vwh->vch = (verify_container_handle_t*)handle;
|
||||||
|
|
||||||
*work_handle = vwh;
|
*work_handle = vwh;
|
||||||
|
|
||||||
|
DEBUG_INSTALL;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -408,6 +432,8 @@ int verify_work(void *handle, void *work_handle, char *input, htbuffer_t *output
|
|||||||
verify_work_handle_t *vwh = (verify_work_handle_t*) work_handle;
|
verify_work_handle_t *vwh = (verify_work_handle_t*) work_handle;
|
||||||
struct timespec ts;
|
struct timespec ts;
|
||||||
|
|
||||||
|
lastVerifyWorkHandle = vwh;
|
||||||
|
DEBUG_INIT;
|
||||||
|
|
||||||
syslog(LOG_DEBUG, "verify (%p) verify_work: going to verify %s\n", vwh, input);
|
syslog(LOG_DEBUG, "verify (%p) verify_work: going to verify %s\n", vwh, input);
|
||||||
|
|
||||||
@ -429,30 +455,48 @@ int verify_work(void *handle, void *work_handle, char *input, htbuffer_t *output
|
|||||||
wt->checker_cnt = 0;
|
wt->checker_cnt = 0;
|
||||||
wt->vwh = work_handle;
|
wt->vwh = work_handle;
|
||||||
|
|
||||||
|
DEBUG_STEP; // 1
|
||||||
|
|
||||||
syslog(LOG_DEBUG, "verify (%p) verify_work: going to start worker thread, id=%d",
|
syslog(LOG_DEBUG, "verify (%p) verify_work: going to start worker thread, id=%d",
|
||||||
vwh, vwh->id);
|
vwh, vwh->id);
|
||||||
|
DEBUG_STEP; // 2
|
||||||
|
|
||||||
pthread_mutex_lock(vwh->result_mutex);
|
pthread_mutex_lock(vwh->result_mutex);
|
||||||
|
DEBUG_STEP; // 3
|
||||||
err = pthread_create(&tid, NULL, &worker_thread, wt);
|
err = pthread_create(&tid, NULL, &worker_thread, wt);
|
||||||
|
DEBUG_STEP; // 4
|
||||||
if (-1 == err) {
|
if (-1 == err) {
|
||||||
incStatCounter(vwh->vch->statCounter, STAT_CNT_VERIFIER_WORKER_THREADS_FAILED);
|
incStatCounter(vwh->vch->statCounter, STAT_CNT_VERIFIER_WORKER_THREADS_FAILED);
|
||||||
free(wt->input);
|
free(wt->input);
|
||||||
free(wt);
|
free(wt);
|
||||||
PERM_NOK_RETURN("unable to create worker thread");
|
PERM_NOK_RETURN("unable to create worker thread");
|
||||||
}
|
}
|
||||||
|
DEBUG_STEP; // 5
|
||||||
|
|
||||||
|
|
||||||
syslog(LOG_DEBUG, "verify (%p) verify_work: waiting for result", vwh);
|
syslog(LOG_DEBUG, "verify (%p) verify_work: waiting for result", vwh);
|
||||||
ts.tv_sec = time(0) + vch->timeout_result;
|
ts.tv_sec = time(0) + vch->timeout_result;
|
||||||
ts.tv_nsec = 0;
|
ts.tv_nsec = 0;
|
||||||
|
DEBUG_STEP; // 6
|
||||||
|
|
||||||
err = pthread_cond_timedwait(vwh->result_cond, vwh->result_mutex, &ts);
|
err = pthread_cond_timedwait(vwh->result_cond, vwh->result_mutex, &ts);
|
||||||
|
DEBUG_STEP; // 7
|
||||||
pthread_mutex_unlock(vwh->result_mutex);
|
pthread_mutex_unlock(vwh->result_mutex);
|
||||||
|
DEBUG_STEP; // 8
|
||||||
if (ETIMEDOUT == err) {
|
if (ETIMEDOUT == err) {
|
||||||
incStatCounter(vwh->vch->statCounter, STAT_CNT_VERIFIER_WORKER_THREADS_TIMEOUT);
|
incStatCounter(vwh->vch->statCounter, STAT_CNT_VERIFIER_WORKER_THREADS_TIMEOUT);
|
||||||
TEMP_NOK_RETURN("worker thread timed out");
|
TEMP_NOK_RETURN("worker thread timed out");
|
||||||
}
|
}
|
||||||
|
DEBUG_STEP; // 9
|
||||||
|
|
||||||
|
|
||||||
// snprintf(output, ANSWER_BUFSIZE, vwh->result->output);
|
// snprintf(output, ANSWER_BUFSIZE, vwh->result->output);
|
||||||
htbuffer_strcpy(output, vwh->result->output);
|
htbuffer_strcpy(output, vwh->result->output);
|
||||||
|
DEBUG_STEP; // 10
|
||||||
|
|
||||||
free(vwh->result->output);
|
free(vwh->result->output);
|
||||||
|
DEBUG_STEP; // 11
|
||||||
|
|
||||||
return vwh->result->result;
|
return vwh->result->result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user