changes for stats in verifier

This commit is contained in:
whottgen
2004-11-04 22:46:22 +00:00
parent cafbf37771
commit 7e2b1365b4
5 changed files with 71 additions and 21 deletions

View File

@ -48,6 +48,7 @@
#include "smtp.h"
#include "htmalloc.h"
#include "stats.h"
#define SMM_LOCAL_PERM_NOK 101
#define SMM_LOCAL_TEMP_NOK 102
@ -241,6 +242,7 @@ int verify_work_destroy(void *handle, void *work_handle) {
/* clean up the checker stuff */
pthread_join(ct->thread, NULL);
decStatCounter(STAT_CNT_VERIFIER_CHECKER_R_THREADS);
syslog(LOG_DEBUG, "verify (%p) verify_work_destroy, checker_thread (id=%d) joined",
work_handle, ct->id);
@ -251,6 +253,7 @@ int verify_work_destroy(void *handle, void *work_handle) {
}
err = pthread_join(wt->thread, NULL);
decStatCounter(STAT_CNT_VERIFIER_WORKER_R_THREADS);
syslog(LOG_DEBUG, "verify (%p) verify_work_destroy, worker_thread (id=%d) joined",
work_handle, wt->id);
free(wt->input);
@ -307,6 +310,7 @@ void cache_insert(verify_container_handle_t *vch, const char *address, int resul
if (ret != 0) {
syslog(LOG_DEBUG, "cache_insert: couldn't insert record");
} else {
incStatCounter(STAT_CNT_VERIFIER_CACHE);
syslog(LOG_DEBUG, "cache_insert: record inserted");
}
dbm_close(cache);
@ -363,6 +367,7 @@ int cache_lookup(verify_container_handle_t *vch, const char* address, int *resul
if (ret != 0) {
syslog(LOG_DEBUG, "cache_insert: couldn't delete record");
} else {
decStatCounter(STAT_CNT_VERIFIER_CACHE);
syslog(LOG_DEBUG, "cache_insert: record deleted");
}
dbm_close(cache);
@ -448,6 +453,7 @@ int verify_work(void *handle, void *work_handle, char *input, char *output) {
pthread_mutex_lock(vwh->result_mutex);
err = pthread_create(&tid, NULL, &worker_thread, wt);
if (-1 == err) {
incStatCounter(STAT_CNT_VERIFIER_WORKER_THREADS_FAILED);
free(wt->input);
free(wt);
PERM_NOK_RETURN("unable to create worker thread");
@ -459,6 +465,7 @@ int verify_work(void *handle, void *work_handle, char *input, char *output) {
err = pthread_cond_timedwait(vwh->result_cond, vwh->result_mutex, &ts);
pthread_mutex_unlock(vwh->result_mutex);
if (ETIMEDOUT == err) {
incStatCounter(STAT_CNT_VERIFIER_WORKER_THREADS_TIMEOUT);
TEMP_NOK_RETURN("worker thread timed out");
}
@ -533,6 +540,9 @@ static void *checker_thread(void *arg) {
ct->thread = pthread_self();
incStatCounter(STAT_CNT_VERIFIER_CHECKER_THREADS);
incStatCounter(STAT_CNT_VERIFIER_CHECKER_R_THREADS);
/*
Connect to ct->ip_address using ct->email_address,
put the result text in ct->output, TBD: by copy or pointer,
@ -656,6 +666,8 @@ static void *worker_thread(void *arg) {
wt->thread = pthread_self();
incStatCounter(STAT_CNT_VERIFIER_WORKER_R_THREADS);
incStatCounter(STAT_CNT_VERIFIER_WORKER_THREADS);
@ -668,6 +680,7 @@ static void *worker_thread(void *arg) {
if (0 == cache_lookup(wt->vwh->vch, wt->input, &result, &cached_output)) {
syslog(LOG_DEBUG, "verify (%p) worker_thread: got a cached result for %s -> %d, %s",
wt->vwh, wt->input, result, cached_output);
incStatCounter(STAT_CNT_VERIFIER_ANSWERED_FROM_CACHE);
wt->output = cached_output;
} else {
domain_part += 1;
@ -699,6 +712,7 @@ static void *worker_thread(void *arg) {
err = pthread_create(&tid, NULL, &checker_thread, ct);
if (-1 == err) {
incStatCounter(STAT_CNT_VERIFIER_CHECKER_THREADS_FAILED);
syslog(LOG_ERR, "verify (%p) worker_thread: unable to create checker thread", wt->vwh);
free(ct);
} else {
@ -718,6 +732,7 @@ static void *worker_thread(void *arg) {
wt->input, ct->result, ct->output);
pthread_join(ct->thread, NULL);
decStatCounter(STAT_CNT_VERIFIER_CHECKER_R_THREADS);
syslog(LOG_DEBUG, "verify (%p) worker_thread: checker thread joined", wt->vwh);
if ((SMM_LOCAL_TEMP_NOK != ct->result) &&
@ -757,14 +772,17 @@ static void *worker_thread(void *arg) {
switch (result) {
case SMM_LOCAL_TEMP_NOK:
sprintf(wt->result->output, "<TNOK><%s>", wt->output);
incStatCounter(STAT_CNT_VERIFIER_RETURNED_TNOK);
result = SMM_OK;
break;
case SMM_LOCAL_PERM_NOK:
sprintf(wt->result->output, "<NOK><%s>", wt->output);
incStatCounter(STAT_CNT_VERIFIER_RETURNED_NOK);
result = SMM_OK;
break;
case SMM_LOCAL_OK:
sprintf(wt->result->output, "<OK><%s>", wt->output);
incStatCounter(STAT_CNT_VERIFIER_RETURNED_OK);
result = SMM_OK;
break;
default: