diff options
author | Charles Longeau <chl@cvs.openbsd.org> | 2011-08-30 17:06:02 +0000 |
---|---|---|
committer | Charles Longeau <chl@cvs.openbsd.org> | 2011-08-30 17:06:02 +0000 |
commit | 1a5e179e6e5f721414297ef3fa9cb93d64d76688 (patch) | |
tree | b079bc13b3e5896a955d035dc49343d126aec09c | |
parent | 103184768056c27708d498d7b979adb223d1eadf (diff) |
Call free() into ramqueue_remove_{batch,host,message,envelope}() instead of just after the function call.
While there, also include stats counters into their respective function.
ok gilles@
-rw-r--r-- | usr.sbin/smtpd/ramqueue.c | 9 | ||||
-rw-r--r-- | usr.sbin/smtpd/runner.c | 23 |
2 files changed, 12 insertions, 20 deletions
diff --git a/usr.sbin/smtpd/ramqueue.c b/usr.sbin/smtpd/ramqueue.c index 272e34bcf09..1d13a66cb89 100644 --- a/usr.sbin/smtpd/ramqueue.c +++ b/usr.sbin/smtpd/ramqueue.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ramqueue.c,v 1.16 2011/08/26 14:39:47 chl Exp $ */ +/* $OpenBSD: ramqueue.c,v 1.17 2011/08/30 17:06:01 chl Exp $ */ /* * Copyright (c) 2011 Gilles Chehade <gilles@openbsd.org> @@ -353,18 +353,24 @@ void ramqueue_remove_batch(struct ramqueue_host *rq_host, struct ramqueue_batch *rq_batch) { TAILQ_REMOVE(&rq_host->batch_queue, rq_batch, batch_entry); + free(rq_batch); + env->stats->ramqueue.batches--; } void ramqueue_remove_host(struct ramqueue *rqueue, struct ramqueue_host *rq_host) { RB_REMOVE(hosttree, &rqueue->hosttree, rq_host); + free(rq_host); + env->stats->ramqueue.hosts--; } void ramqueue_remove_message(struct ramqueue *rqueue, struct ramqueue_message *rq_msg) { RB_REMOVE(msgtree, &rqueue->msgtree, rq_msg); + free(rq_msg); + env->stats->ramqueue.messages--; } void @@ -483,6 +489,7 @@ ramqueue_remove_envelope(struct ramqueue *rq, struct ramqueue_envelope *rq_evp) TAILQ_REMOVE(&rq_batch->envelope_queue, rq_evp, batchqueue_entry); TAILQ_REMOVE(&rq->queue, rq_evp, queue_entry); env->stats->ramqueue.envelopes--; + free(rq_evp); } diff --git a/usr.sbin/smtpd/runner.c b/usr.sbin/smtpd/runner.c index 08274989778..5e15e34c6bf 100644 --- a/usr.sbin/smtpd/runner.c +++ b/usr.sbin/smtpd/runner.c @@ -1,4 +1,4 @@ -/* $OpenBSD: runner.c,v 1.115 2011/08/29 21:43:09 chl Exp $ */ +/* $OpenBSD: runner.c,v 1.116 2011/08/30 17:06:01 chl Exp $ */ /* * Copyright (c) 2008 Gilles Chehade <gilles@openbsd.org> @@ -431,7 +431,6 @@ runner_process_batch(struct ramqueue_envelope *rq_evp, time_t curtm) IMSG_SMTP_ENQUEUE, PROC_SMTP, 0, -1, &evp, sizeof evp); ramqueue_remove_envelope(&env->sc_rqueue, rq_evp); - free(rq_evp); } env->stats->runner.bounces_active++; env->stats->runner.bounces++; @@ -452,7 +451,6 @@ runner_process_batch(struct ramqueue_envelope *rq_evp, time_t curtm) IMSG_MDA_SESS_NEW, PROC_MDA, 0, fd, &evp, sizeof evp); ramqueue_remove_envelope(&env->sc_rqueue, rq_evp); - free(rq_evp); env->stats->mda.sessions_active++; env->stats->mda.sessions++; @@ -477,7 +475,6 @@ runner_process_batch(struct ramqueue_envelope *rq_evp, time_t curtm) IMSG_BATCH_APPEND, PROC_MTA, 0, -1, &evp, sizeof evp); ramqueue_remove_envelope(&env->sc_rqueue, rq_evp); - free(rq_evp); env->stats->runner.active++; SET_IF_GREATER(env->stats->runner.active, env->stats->runner.maxactive); @@ -495,25 +492,14 @@ runner_process_batch(struct ramqueue_envelope *rq_evp, time_t curtm) fatalx("runner_process_batchqueue: unknown type"); } - if (ramqueue_message_is_empty(rq_msg)) { + if (ramqueue_message_is_empty(rq_msg)) ramqueue_remove_message(&env->sc_rqueue, rq_msg); - free(rq_msg); - env->stats->ramqueue.messages--; - - } - if (ramqueue_batch_is_empty(rq_batch)) { + if (ramqueue_batch_is_empty(rq_batch)) ramqueue_remove_batch(rq_host, rq_batch); - free(rq_batch); - env->stats->ramqueue.batches--; - - } - if (ramqueue_host_is_empty(rq_host)) { + if (ramqueue_host_is_empty(rq_host)) ramqueue_remove_host(&env->sc_rqueue, rq_host); - free(rq_host); - env->stats->ramqueue.hosts--; - } } /* XXX - temporary solution */ @@ -740,5 +726,4 @@ runner_remove_envelope(struct ramqueue *rq, struct ramqueue_envelope *rq_evp) queue_envelope_delete(Q_QUEUE, &evp); ramqueue_remove_envelope(rq, rq_evp); - free(rq_evp); } |