Xref: utzoo comp.protocols.tcp-ip:12457 comp.protocols.tcp-ip.domains:293 Path: utzoo!attcan!uunet!bu.edu!rpi!zaphod.mps.ohio-state.edu!samsung!cs.utexas.edu!romp!auschs!awdprime!sandino.austin.ibm.com!jeffe From: jeffe@sandino.austin.ibm.com (Peter Jeffe 512.823.4091) Newsgroups: comp.protocols.tcp-ip,comp.protocols.tcp-ip.domains Subject: bug in BSD tahoe res_send()? Message-ID: <3010@awdprime.UUCP> Date: 2 Aug 90 15:12:47 GMT Sender: news@awdprime.UUCP Followup-To: comp.protocols.tcp-ip Organization: IBM AWD, Austin, TX Lines: 47 I'm not sure if this is a bug, but in BSD tahoe res_send.c (6.21), the following code looks fishy: | for (retry = _res.retry; retry > 0; retry--) { | for (ns = 0; ns < _res.nscount; ns++) { |... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... |#if BSD >= 43 | if (_res.nscount == 1 || retry == _res.retry) { !!!^^^^^^^^^^^^^^^^!!! | /* | * Don't use connect if we might | * still receive a response | * from another server. | */ | if (connected == 0) { | if (connect(s, &_res.nsaddr_list[ns], | sizeof(struct sockaddr)) < 0) { | [ #ifdef DEBUG ] | continue; | } | connected = 1; | } | if (send(s, buf, buflen, 0) != buflen) { | [ #ifdef DEBUG ] | continue; | } | } else { | [ connect() to no_addr (0.0.0.0) and sendto(_res.nsaddr_list[ns]) ] The problem (?) is that while (retry == _res.retry) we only query the first host, since we connect() the first time through, and then keep send()ing to whomever we're connected to, until we decrement retry and fall through to the sendto() call. So if we've got 3 nameservers defined in resolv.conf, and all of them are down, we query in the following order: 1, 1, 1, 1, 2, 3, 1, 2, 3 Now, I don't know if this was intended, but it jes' don't seem right to me. Especially since the virtual-circuit code doesn't act the same. Personally, I'd chuck the connect()/send() stuff and just do the sendto() (or at least do it only on (_res.nscount == 1) if you really think it's more efficient). What say ye all? ------------------------------------------------------------------------------- Peter Jeffe ...uunet!cs.utexas.edu!ibmchs!auschs!sandino.austin.ibm.com!jeffe first they want a disclaimer, then they make you pee in a jar, then they come for you in the night