summaryrefslogtreecommitdiffstats
path: root/source/libsmb
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>1998-11-06 18:40:51 +0000
committerJeremy Allison <jra@samba.org>1998-11-06 18:40:51 +0000
commitb5981c0149ad8c6f13ea87db450080616538b5d5 (patch)
tree14d0b867ac3230a6dfdd8cf7214381aa75ce9eb0 /source/libsmb
parent222829885cba9ccb8af0e9df232fd5d614cec1ad (diff)
downloadsamba-b5981c0149ad8c6f13ea87db450080616538b5d5.tar.gz
samba-b5981c0149ad8c6f13ea87db450080616538b5d5.tar.xz
samba-b5981c0149ad8c6f13ea87db450080616538b5d5.zip
lib/charcnv.c: Improved debug comment.
libsmb/namequery.c: Fix to remove 2 second wait is we are doing a unicast and got a reply. smbd/dfree.c: smbd/noquotas.c: smbd/quotas.c: Fixes from Dejan Ilic <svedja@lysator.liu.se> for the quota code. utils/smbpasswd.c: Fixes to allow smbpasswd to be called from swat. Jeremy.
Diffstat (limited to 'source/libsmb')
-rw-r--r--source/libsmb/namequery.c117
1 files changed, 69 insertions, 48 deletions
diff --git a/source/libsmb/namequery.c b/source/libsmb/namequery.c
index e95302fcd0c..0e92e6b5dd8 100644
--- a/source/libsmb/namequery.c
+++ b/source/libsmb/namequery.c
@@ -247,60 +247,81 @@ struct in_addr *name_query(int fd,char *name,int name_type, BOOL bcast,BOOL recu
retries--;
while (1)
+ {
+ struct timeval tval2;
+ GetTimeOfDay(&tval2);
+ if (TvalDiff(&tval,&tval2) > retry_time)
{
- struct timeval tval2;
- GetTimeOfDay(&tval2);
- if (TvalDiff(&tval,&tval2) > retry_time) {
- if (!retries) break;
- if (!found && !send_packet(&p))
- return NULL;
- GetTimeOfDay(&tval);
- retries--;
- }
+ if (!retries)
+ break;
+ if (!found && !send_packet(&p))
+ return NULL;
+ GetTimeOfDay(&tval);
+ retries--;
+ }
- if ((p2=receive_packet(fd,NMB_PACKET,90)))
- {
- struct nmb_packet *nmb2 = &p2->packet.nmb;
- debug_nmb_packet(p2);
+ if ((p2=receive_packet(fd,NMB_PACKET,90)))
+ {
+ struct nmb_packet *nmb2 = &p2->packet.nmb;
+ debug_nmb_packet(p2);
- if (nmb->header.name_trn_id != nmb2->header.name_trn_id ||
- !nmb2->header.response) {
- /* its not for us - maybe deal with it later
- (put it on the queue?) */
- if (fn)
- fn(p2);
- else
- free_packet(p2);
- continue;
- }
+ if (nmb->header.name_trn_id != nmb2->header.name_trn_id ||
+ !nmb2->header.response)
+ {
+ /*
+ * Its not for us - maybe deal with it later
+ * (put it on the queue?).
+ */
+ if (fn)
+ fn(p2);
+ else
+ free_packet(p2);
+ continue;
+ }
- if (nmb2->header.opcode != 0 ||
- nmb2->header.nm_flags.bcast ||
- nmb2->header.rcode ||
- !nmb2->header.ancount) {
- /* XXXX what do we do with this? could be a redirect, but
- we'll discard it for the moment */
- free_packet(p2);
- continue;
- }
+ if (nmb2->header.opcode != 0 ||
+ nmb2->header.nm_flags.bcast ||
+ nmb2->header.rcode ||
+ !nmb2->header.ancount)
+ {
+ /*
+ * XXXX what do we do with this? Could be a redirect, but
+ * we'll discard it for the moment.
+ */
+ free_packet(p2);
+ continue;
+ }
- ip_list = (struct in_addr *)Realloc(ip_list, sizeof(ip_list[0]) *
- ((*count)+nmb2->answers->rdlength/6));
- if (ip_list) {
- DEBUG(fn?3:2,("Got a positive name query response from %s ( ",
- inet_ntoa(p2->ip)));
- for (i=0;i<nmb2->answers->rdlength/6;i++) {
- putip((char *)&ip_list[(*count)],&nmb2->answers->rdata[2+i*6]);
- DEBUG(fn?3:2,("%s ",inet_ntoa(ip_list[(*count)])));
- (*count)++;
- }
- DEBUG(fn?3:2,(")\n"));
- }
- found=True; retries=0;
- free_packet(p2);
- if (fn) break;
- }
+ ip_list = (struct in_addr *)Realloc(ip_list, sizeof(ip_list[0]) *
+ ((*count)+nmb2->answers->rdlength/6));
+ if (ip_list)
+ {
+ DEBUG(fn?3:2,("Got a positive name query response from %s ( ",
+ inet_ntoa(p2->ip)));
+ for (i=0;i<nmb2->answers->rdlength/6;i++)
+ {
+ putip((char *)&ip_list[(*count)],&nmb2->answers->rdata[2+i*6]);
+ DEBUG(fn?3:2,("%s ",inet_ntoa(ip_list[(*count)])));
+ (*count)++;
+ }
+ DEBUG(fn?3:2,(")\n"));
+ }
+
+ found=True;
+ retries=0;
+ free_packet(p2);
+ if (fn)
+ break;
+
+ /*
+ * If we're doing a unicast lookup we only
+ * expect one reply. Don't wait the full 2
+ * seconds if we got one. JRA.
+ */
+ if(!bcast && found)
+ break;
}
+ }
return ip_list;
}