Browse code

- removed an error msg (transformed it into a DBG) - get_record mutliple type response fix - don't exist udp_rcv_loop on ECONNREFUSED

Andrei Pelinescu-Onciul authored on 05/09/2002 15:35:44
Showing 3 changed files
... ...
@@ -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 284
 				rd->rdata=(void*)srv_rd;
285 285
 				if (srv_rd==0) goto error_parse;
286 286
 				
287
-				/* insert sorted into the list
288
-				 * crt reused */
287
+				/* insert sorted into the list */
289 288
 				for (crt=&head; *crt; crt= &((*crt)->next)){
290 289
 					crt_srv=(struct srv_rdata*)(*crt)->rdata;
291 290
 					if ((srv_rd->priority <  crt_srv->priority) ||
292 291
 					   ( (srv_rd->priority == crt_srv->priority) && 
293 292
 							 (srv_rd->weight > crt_srv->weight) ) ){
294 293
 						/* insert here */
295
-						break;
294
+						goto skip;
296 295
 					}
297 296
 				}
297
+				last=&(rd->next); /*end of for => this will be the last elem*/
298
+			skip:
298 299
 				/* insert here */
299 300
 				rd->next=*crt;
300 301
 				*crt=rd;
... ...
@@ -303,26 +305,26 @@ struct rdata* get_record(char* name, int type)
303 303
 			case T_A:
304 304
 				rd->rdata=(void*) dns_a_parser(p,end);
305 305
 				if (rd->rdata==0) goto error_parse;
306
-				*crt=rd; /* crt points to the last "next" or the list head*/
307
-				crt=&(rd->next);
306
+				*last=rd; /* last points to the last "next" or the list head*/
307
+				last=&(rd->next);
308 308
 				break;
309 309
 			case T_AAAA:
310 310
 				rd->rdata=(void*) dns_aaaa_parser(p,end);
311 311
 				if (rd->rdata==0) goto error_parse;
312
-				*crt=rd;
313
-				crt=&(rd->next);
312
+				*last=rd;
313
+				last=&(rd->next);
314 314
 				break;
315 315
 			case T_CNAME:
316 316
 				rd->rdata=(void*) dns_cname_parser(buff.buff, end, p);
317 317
 				if(rd->rdata==0) goto error_parse;
318
-				*crt=rd;
319
-				crt=&(rd->next);
318
+				*last=rd;
319
+				last=&(rd->next);
320 320
 				break;
321 321
 			default:
322 322
 				LOG(L_ERR, "WARNING: get_record: unknown type %d\n", rtype);
323 323
 				rd->rdata=0;
324
-				*crt=rd;
325
-				crt=&(rd->next);
324
+				*last=rd;
325
+				last=&(rd->next);
326 326
 		}
327 327
 		
328 328
 		p+=rdlength;
... ...
@@ -339,6 +341,7 @@ error_parse:
339 339
 error:
340 340
 		LOG(L_ERR, "ERROR: get_record \n");
341 341
 		if (head) free_rdata_list(head);
342
+not_found:
342 343
 	return 0;
343 344
 }
344 345
 
... ...
@@ -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
 		}