... | ... |
@@ -102,7 +102,7 @@ DEFS+= -DNAME='"$(NAME)"' -DVERSION='"$(RELEASE)"' -DARCH='"$(ARCH)"' \ |
102 | 102 |
-DSHM_MEM -DSHM_MMAP \ |
103 | 103 |
-DADAPTIVE_WAIT -DADAPTIVE_WAIT_LOOPS=1024 \ |
104 | 104 |
-DUSE_IPV6 \ |
105 |
- -DF_MALLOC \ |
|
105 |
+ # -DF_MALLOC \ |
|
106 | 106 |
#-DEXTRA_DEBUG \ |
107 | 107 |
#-DDBG_QM_MALLOC \ |
108 | 108 |
#-DVQ_MALLOC |
... | ... |
@@ -191,20 +191,21 @@ struct rdata* get_record(char* name, int type) |
191 | 191 |
unsigned int ttl; |
192 | 192 |
struct rdata* head; |
193 | 193 |
struct rdata** crt; |
194 |
+ struct rdata** last; |
|
194 | 195 |
struct rdata* rd; |
195 | 196 |
struct srv_rdata* srv_rd; |
196 | 197 |
struct srv_rdata* crt_srv; |
197 | 198 |
|
198 | 199 |
|
199 | 200 |
|
200 |
- head=rd=0; |
|
201 |
- crt=&head; |
|
202 | 201 |
size=res_search(name, C_IN, type, buff.buff, sizeof(buff)); |
203 | 202 |
if (size<0) { |
204 |
- LOG(L_ERR, "ERROR: get_record: size<0\n"); |
|
205 |
- goto error; |
|
203 |
+ DBG("get_record: lookup(%s, %d) failed\n", name, type); |
|
204 |
+ goto not_found; |
|
206 | 205 |
} |
207 | 206 |
else if (size > sizeof(buff)) size=sizeof(buff); |
207 |
+ head=rd=0; |
|
208 |
+ last=crt=&head; |
|
208 | 209 |
|
209 | 210 |
p=buff.buff+DNS_HDR_SIZE; |
210 | 211 |
end=buff.buff+size; |
... | ... |
@@ -284,17 +285,18 @@ struct rdata* get_record(char* name, int type) |
284 | 285 |
rd->rdata=(void*)srv_rd; |
285 | 286 |
if (srv_rd==0) goto error_parse; |
286 | 287 |
|
287 |
- /* insert sorted into the list |
|
288 |
- * crt reused */ |
|
288 |
+ /* insert sorted into the list */ |
|
289 | 289 |
for (crt=&head; *crt; crt= &((*crt)->next)){ |
290 | 290 |
crt_srv=(struct srv_rdata*)(*crt)->rdata; |
291 | 291 |
if ((srv_rd->priority < crt_srv->priority) || |
292 | 292 |
( (srv_rd->priority == crt_srv->priority) && |
293 | 293 |
(srv_rd->weight > crt_srv->weight) ) ){ |
294 | 294 |
/* insert here */ |
295 |
- break; |
|
295 |
+ goto skip; |
|
296 | 296 |
} |
297 | 297 |
} |
298 |
+ last=&(rd->next); /*end of for => this will be the last elem*/ |
|
299 |
+ skip: |
|
298 | 300 |
/* insert here */ |
299 | 301 |
rd->next=*crt; |
300 | 302 |
*crt=rd; |
... | ... |
@@ -303,26 +305,26 @@ struct rdata* get_record(char* name, int type) |
303 | 305 |
case T_A: |
304 | 306 |
rd->rdata=(void*) dns_a_parser(p,end); |
305 | 307 |
if (rd->rdata==0) goto error_parse; |
306 |
- *crt=rd; /* crt points to the last "next" or the list head*/ |
|
307 |
- crt=&(rd->next); |
|
308 |
+ *last=rd; /* last points to the last "next" or the list head*/ |
|
309 |
+ last=&(rd->next); |
|
308 | 310 |
break; |
309 | 311 |
case T_AAAA: |
310 | 312 |
rd->rdata=(void*) dns_aaaa_parser(p,end); |
311 | 313 |
if (rd->rdata==0) goto error_parse; |
312 |
- *crt=rd; |
|
313 |
- crt=&(rd->next); |
|
314 |
+ *last=rd; |
|
315 |
+ last=&(rd->next); |
|
314 | 316 |
break; |
315 | 317 |
case T_CNAME: |
316 | 318 |
rd->rdata=(void*) dns_cname_parser(buff.buff, end, p); |
317 | 319 |
if(rd->rdata==0) goto error_parse; |
318 |
- *crt=rd; |
|
319 |
- crt=&(rd->next); |
|
320 |
+ *last=rd; |
|
321 |
+ last=&(rd->next); |
|
320 | 322 |
break; |
321 | 323 |
default: |
322 | 324 |
LOG(L_ERR, "WARNING: get_record: unknown type %d\n", rtype); |
323 | 325 |
rd->rdata=0; |
324 |
- *crt=rd; |
|
325 |
- crt=&(rd->next); |
|
326 |
+ *last=rd; |
|
327 |
+ last=&(rd->next); |
|
326 | 328 |
} |
327 | 329 |
|
328 | 330 |
p+=rdlength; |
... | ... |
@@ -339,6 +341,7 @@ error_parse: |
339 | 341 |
error: |
340 | 342 |
LOG(L_ERR, "ERROR: get_record \n"); |
341 | 343 |
if (head) free_rdata_list(head); |
344 |
+not_found: |
|
342 | 345 |
return 0; |
343 | 346 |
} |
344 | 347 |
|
... | ... |
@@ -216,7 +216,8 @@ int udp_rcv_loop() |
216 | 216 |
if (len==-1){ |
217 | 217 |
LOG(L_ERR, "ERROR: udp_rcv_loop:recvfrom:[%d] %s\n", |
218 | 218 |
errno, strerror(errno)); |
219 |
- if ((errno==EINTR)||(errno==EAGAIN)||(errno==EWOULDBLOCK)) |
|
219 |
+ if ((errno==EINTR)||(errno==EAGAIN)||(errno==EWOULDBLOCK)|| |
|
220 |
+ (errno==ECONNREFUSED)) |
|
220 | 221 |
continue; /* goto skip;*/ |
221 | 222 |
else goto error; |
222 | 223 |
} |