PERFORCE change 120768 for review
Fredrik Lindberg
fli at FreeBSD.org
Sat Jun 2 11:58:45 UTC 2007
http://perforce.freebsd.org/chv.cgi?CH=120768
Change 120768 by fli at fli_genesis on 2007/06/02 11:58:24
Debugging and style fixes.
Affected files ...
.. //depot/projects/soc2007/fli-mdns_sd/mdnsd/log.c#2 edit
.. //depot/projects/soc2007/fli-mdns_sd/mdnsd/wqueue.c#2 edit
.. //depot/projects/soc2007/fli-mdns_sd/mdnsd/wqueue.h#2 edit
Differences ...
==== //depot/projects/soc2007/fli-mdns_sd/mdnsd/log.c#2 (text+ko) ====
@@ -24,17 +24,17 @@
*
*/
-#include <unistd.h>
-#include <stdlib.h>
+#include <sys/uio.h>
+
+#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include <stdarg.h>
#include <syslog.h>
-#include <sys/uio.h>
#include <unistd.h>
#include "log.h"
+#include "debug.h"
static int _isdaemon = 0;
static const char *_pname = NULL;
==== //depot/projects/soc2007/fli-mdns_sd/mdnsd/wqueue.c#2 (text+ko) ====
@@ -24,19 +24,21 @@
*
*/
+#include <sys/time.h>
+#include <sys/queue.h>
+
+#include <errno.h>
#include <stdlib.h>
-#include <errno.h>
+#include <signal.h>
#include <string.h>
#include <strings.h>
#ifdef HAVE_PTHREAD
#include <pthread.h>
#endif
-#include <sys/time.h>
-#include <sys/queue.h>
-#include <signal.h>
#include "wqueue.h"
#include "log.h"
+#include "debug.h"
#ifdef HAVE_PTHREAD
static void * wq_worker(void *);
@@ -69,6 +71,8 @@
{
struct wq_tag *wqt;
+ MDNS_INIT_ASSERT(wq, wq_magic);
+
if (TAILQ_EMPTY(&wq->wq_free)) {
wqt = malloc(sizeof(struct wq_tag));
bzero(wqt, sizeof(struct wq_tag));
@@ -79,7 +83,7 @@
wqt = TAILQ_FIRST(&wq->wq_free);
TAILQ_REMOVE(&wq->wq_free, wqt, wqt_list);
}
-
+ MDNS_INIT_SET(wqt, wqt_magic);
wq->wq_tags_used++;
dprintf(DEBUG_WQUEUE, "%d tags, used %d", wq->wq_tags, wq->wq_tags_used);
return (wqt);
@@ -99,7 +103,9 @@
{
int i;
+ MDNS_INIT_ASSERT(wq, wq_magic);
TAILQ_INSERT_HEAD(&wq->wq_free, wqt, wqt_list);
+ MDNS_INIT_UNSET(wqt, wqt_magic);
/*
* De-allocate job tags if we have a large share of unused tags
@@ -146,6 +152,7 @@
wq->wq_workers_max = max;
wq->wq_workers_min = min;
+ MDNS_INIT_SET(wq, wq_magic);
return (wq);
}
@@ -161,6 +168,7 @@
{
struct wq_tag *wqt;
+ MDNS_INIT_ASSERT(wq, wq_magic);
WQ_LOCK(wq);
wq->wq_flags |= WQ_FLAGS_DYING;
@@ -197,6 +205,7 @@
pthread_cond_destroy(&wq->wq_cond);
pthread_attr_destroy(&wq->wq_attr);
#endif
+ MDNS_INIT_UNSET(wq, wq_magic);
free(wq);
}
@@ -213,6 +222,7 @@
struct wq_thread *thr;
struct wq_tag *wqt;
+ MDNS_INIT_ASSERT(wq, wq_magic);
if (wq->wq_flags & WQ_FLAGS_DYING)
return (-1);
@@ -262,6 +272,7 @@
struct wq_thread *thr;
int id;
+ MDNS_INIT_ASSERT(wq, wq_magic);
thr = malloc(sizeof(struct wq_thread));
if (thr == NULL)
return (NULL);
@@ -318,7 +329,7 @@
int error;
wq = wqthr->wqthr_wq;
-
+ MDNS_INIT_ASSERT(wq, wq_magic);
WQ_LOCK(wq);
wq->wq_workers_idle++;
for (;;) {
==== //depot/projects/soc2007/fli-mdns_sd/mdnsd/wqueue.h#2 (text+ko) ====
@@ -33,6 +33,8 @@
#include <stdint.h>
#include <sys/queue.h>
+#include "debug.h"
+
struct wq_tag;
struct wq_thread;
@@ -40,6 +42,7 @@
* Thread work queue
*/
struct wqueue {
+ MAGIC(wq_magic);
TAILQ_HEAD(, wq_tag) wq_queue; /* Job queue */
TAILQ_HEAD(, wq_tag) wq_free; /* Free job tags */
int wq_tags; /* Number of allocated tags */
@@ -73,6 +76,7 @@
*/
typedef int (*wq_func)(const wq_arg);
struct wq_tag {
+ MAGIC(wqt_magic);
TAILQ_ENTRY(wq_tag) wqt_list;
wq_func wqt_func;
wq_arg wqt_func_arg;
More information about the p4-projects
mailing list