ReactOS 0.4.15-dev-7788-g1ad9096
check.c
Go to the documentation of this file.
1/*
2 * check.c
3 * - consistency checks
4 */
5/*
6 * This file is
7 * Copyright (C) 1997-1999 Ian Jackson <ian@davenant.greenend.org.uk>
8 *
9 * It is part of adns, which is
10 * Copyright (C) 1997-2000 Ian Jackson <ian@davenant.greenend.org.uk>
11 * Copyright (C) 1999-2000 Tony Finch <dot@dotat.at>
12 *
13 * This program is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License as published by
15 * the Free Software Foundation; either version 2, or (at your option)
16 * any later version.
17 *
18 * This program is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
22 *
23 * You should have received a copy of the GNU General Public License
24 * along with this program; if not, write to the Free Software Foundation,
25 * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
26 */
27
28#include "internal.h"
29
32}
33
34/* The original macro. Too gnuish for other compilers */
35#if 0
36#define DLIST_CHECK(list, nodevar, part, body) \
37 if ((list).head) { \
38 assert(! (list).head->part back); \
39 for ((nodevar)= (list).head; (nodevar); (nodevar)= (nodevar)->part next) { \
40 assert((nodevar)->part next \
41 ? (nodevar) == (nodevar)->part next->part back \
42 : (nodevar) == (list).tail); \
43 body \
44 } \
45 }
46#endif /* 0 */
47
48#define DLIST_CHECK1(list, nodevar, body) \
49 if ((list).head) { \
50 assert(! (list).head->back); \
51 for ((nodevar)= (list).head; (nodevar); (nodevar)= (nodevar)->next) { \
52 assert((nodevar)->next \
53 ? (nodevar) == (nodevar)->next->back \
54 : (nodevar) == (list).tail); \
55 body \
56 } \
57 }
58
59#define DLIST_CHECK2(list, nodevar, part, body) \
60 if ((list).head) { \
61 assert(! (list).head->part.back); \
62 for ((nodevar)= (list).head; (nodevar); (nodevar)= (nodevar)->part.next) { \
63 assert((nodevar)->part.next \
64 ? (nodevar) == (nodevar)->part.next->part.back \
65 : (nodevar) == (list).tail); \
66 body \
67 } \
68 }
69
70#define DLIST_ASSERTON(node, nodevar, list, part) \
71 do { \
72 for ((nodevar)= (list).head; \
73 (nodevar) != (node); \
74 (nodevar)= (nodevar)->part next) { \
75 assert((nodevar)); \
76 } \
77 } while(0)
78
80 allocnode *an;
81
82
83 DLIST_CHECK1(qu->allocations, an, {
84 });
85}
86
89
91 assert(!(qu->udpsent & (~0UL << ads->nservers)));
93 if (qu->parent) DLIST_ASSERTON(qu, child, qu->parent->children, siblings.);
94}
95
100}
101
103 int i;
104
105 assert(ads->udpsocket >= 0);
106
107 for (i=0; i<ads->nsortlist; i++)
108 assert(!(ads->sortlist[i].base.s_addr & ~ads->sortlist[i].mask.s_addr));
109
111
112 switch (ads->tcpstate) {
113 case server_connecting:
114 assert(ads->tcpsocket >= 0);
116 break;
117 case server_disconnected:
118 case server_broken:
119 assert(ads->tcpsocket == -1);
121 break;
122 case server_ok:
123 assert(ads->tcpsocket >= 0);
125 break;
126 default:
127 assert(!"ads->tcpstate value");
128 }
129
131}
132
134 adns_query qu;
135
136 DLIST_CHECK1(ads->udpw, qu, {
137 assert(qu->state==query_tosend);
138 assert(qu->retries <= UDPMAXRETRIES);
139 assert(qu->udpsent);
140 assert(!qu->children.head && !qu->children.tail);
141 checkc_query(ads,qu);
142 checkc_query_alloc(ads,qu);
143 });
144}
145
147 adns_query qu;
148
149 DLIST_CHECK1(ads->tcpw, qu, {
150 assert(qu->state==query_tcpw);
151 assert(!qu->children.head && !qu->children.tail);
152 assert(qu->retries <= ads->nservers+1);
153 checkc_query(ads,qu);
154 checkc_query_alloc(ads,qu);
155 });
156}
157
160
161 DLIST_CHECK1(ads->childw, parent, {
162 assert(parent->state == query_childw);
163 assert(parent->children.head);
164 DLIST_CHECK2(parent->children, child, siblings, {
165 assert(child->parent == parent);
166 assert(child->state != query_done);
167 });
170 });
171}
172
174 adns_query qu;
175
176 DLIST_CHECK1(ads->output, qu, {
177 assert(qu->state == query_done);
178 assert(!qu->children.head && !qu->children.tail);
179 assert(!qu->parent);
180 assert(!qu->allocations.head && !qu->allocations.tail);
181 checkc_query(ads,qu);
182 });
183}
184
187
188 switch (cc) {
189 case cc_user:
190 break;
191 case cc_entex:
192 if (!(ads->iflags & adns_if_checkc_entex)) return;
193 break;
194 case cc_freq:
196 break;
197 default:
198 abort();
199 }
200
206
207 if (qu) {
208 switch (qu->state) {
209 case query_tosend:
210 DLIST_ASSERTON(qu, search, ads->udpw, );
211 break;
212 case query_tcpw:
213 DLIST_ASSERTON(qu, search, ads->tcpw, );
214 break;
215 case query_childw:
216 DLIST_ASSERTON(qu, search, ads->childw, );
217 break;
218 case query_done:
220 break;
221 default:
222 assert(!"specific query state");
223 }
224 }
225}
#define DLIST_ASSERTON(node, nodevar, list, part)
Definition: check.c:70
static void checkc_queue_tcpw(adns_state ads)
Definition: check.c:146
static void checkc_notcpbuf(adns_state ads)
Definition: check.c:96
static void checkc_queue_childw(adns_state ads)
Definition: check.c:158
static void checkc_queue_udpw(adns_state ads)
Definition: check.c:133
static void checkc_query(adns_state ads, adns_query qu)
Definition: check.c:87
#define DLIST_CHECK1(list, nodevar, body)
Definition: check.c:48
static void checkc_query_alloc(adns_state ads, adns_query qu)
Definition: check.c:79
static void checkc_global(adns_state ads)
Definition: check.c:102
static void checkc_queue_output(adns_state ads)
Definition: check.c:173
void adns__consistency(adns_state ads, adns_query qu, consistency_checks cc)
Definition: check.c:185
void adns_checkconsistency(adns_state ads, adns_query qu)
Definition: check.c:30
void query_done(struct query_node *qun, adns_answer *answer)
Definition: adh-query.c:253
adns_state ads
Definition: adh-query.c:35
@ adns_if_checkc_freq
Definition: adns.h:97
@ adns_if_checkc_entex
Definition: adns.h:96
#define assert(x)
Definition: debug.h:53
r parent
Definition: btrfs.c:3010
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define abort()
Definition: i386-dis.c:34
uint32_t cc
Definition: isohybrid.c:75
static HWND child
Definition: cursoricon.c:298
static short search(int val, const short *table, int size)
Definition: msg711.c:255
consistency_checks
Definition: internal.h:84
@ cc_user
Definition: internal.h:85
@ cc_freq
Definition: internal.h:87
@ cc_entex
Definition: internal.h:86
adns_query parent
Definition: internal.h:184
int search_pos
Definition: internal.h:217
struct adns__query::@4223 children
unsigned long udpsent
Definition: internal.h:229
int udpnextserver
Definition: internal.h:228
enum adns__query::@4222 state
struct adns__query::@4225 allocations
int nservers
Definition: internal.h:300
ADNS_SOCKET tcpsocket
Definition: internal.h:298
struct adns__state::sortlist sortlist[MAXSORTLIST]
int tcprecv_skip
Definition: internal.h:300
enum adns__state::adns__tcpstate tcpstate
vbuf tcprecv
Definition: internal.h:299
struct query_queue udpw tcpw childw output
Definition: internal.h:295
ADNS_SOCKET udpsocket
Definition: internal.h:298
int nsearchlist
Definition: internal.h:300
adns_initflags iflags
Definition: internal.h:292
int tcpserver
Definition: internal.h:300
vbuf tcpsend
Definition: internal.h:299
int nsortlist
Definition: internal.h:300
char ** searchlist
Definition: internal.h:322
int used
Definition: internal.h:111
#define UL
Definition: tui.h:165