From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 18789 invoked by alias); 2 Apr 2004 09:23:27 -0000 Mailing-List: contact libc-hacker-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-hacker-owner@sources.redhat.com Received: (qmail 18773 invoked from network); 2 Apr 2004 09:23:26 -0000 Received: from unknown (HELO Cantor.suse.de) (195.135.220.2) by sources.redhat.com with SMTP; 2 Apr 2004 09:23:26 -0000 Received: from hermes.suse.de (Hermes.suse.de [195.135.221.8]) (using TLSv1 with cipher EDH-RSA-DES-CBC3-SHA (168/168 bits)) (No client certificate requested) by Cantor.suse.de (Postfix) with ESMTP id BDEF53CEF20 for ; Fri, 2 Apr 2004 11:20:40 +0200 (CEST) Date: Fri, 02 Apr 2004 09:23:00 -0000 From: Thorsten Kukuk To: Glibc hackers Subject: Re: [PATCH] Avoid downloading whole NIS services.by{,service}name for getservby{name,port}{,_r} (, NULL) Message-ID: <20040402092040.GA23511@suse.de> References: <20040329210123.GC28220@sunsite.ms.mff.cuni.cz> <20040330073247.GA12333@suse.de> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="vkogqOf2sHV7VnPd" Content-Disposition: inline In-Reply-To: <20040330073247.GA12333@suse.de> User-Agent: Mutt/1.4i Organization: SuSE Linux AG, Nuernberg, Germany X-SW-Source: 2004-04/txt/msg00009.txt.bz2 --vkogqOf2sHV7VnPd Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-length: 1399 On Tue, Mar 30, Thorsten Kukuk wrote: > On Mon, Mar 29, Jakub Jelinek wrote: > > > Hi! > > > > Only lightly tested so far. > > It is not neccessary to download, allocate and copy whole services > > map and then search through it. > > Instead, we can search already in the foreach callback and if we find > > something tell the caller we don't need further input. > > > > BTW: __xdr_ypresp_all uses the foreach callback return value as > > 0 -> need further data, != 0 break the loop. > > But saveit callbacks I see return 0 when further data should be > > examined and YP_FALSE (== 0) on error (e.g. memory failures). > > This certainly doesn't sound right. > > There are two wrong checks: > > if (instatus != YP_TRUE) > return instatus; > > and > > if (newp == NULL) > return YP_FALSE; /* We have no error code for out of memory */ > > > are both wrong. I will look later at it and try to fix it. > Seems I mixed the instatus and with the return value of the foreach > function. Attached is a patch to solve the problem. In error case, return value should always be "1". Thorsten -- Thorsten Kukuk http://www.suse.de/~kukuk/ kukuk@suse.de SuSE Linux AG Maxfeldstr. 5 D-90409 Nuernberg -------------------------------------------------------------------- Key fingerprint = A368 676B 5E1B 3E46 CFCE 2D97 F8FD 4E23 56C6 FB4B --vkogqOf2sHV7VnPd Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="glibc-2.3.3-nss_nis-return-code.diff" Content-length: 3102 2004-04-02 Thorsten Kukuk * nis/nss_nis/nis-ethers.c (saveit): Fix return codes in error case. * nis/nss_nis/nis-initgroups.c (saveit): Likewise. * nis/nss_nis/nis-proto.c (saveit): Likewise. * nis/nss_nis/nis-rpc.c (saveit): Likewise. * nis/nss_nis/nis-service.c (saveit): Likewise. --- nis/nss_nis/nis-ethers.c +++ nis/nss_nis/nis-ethers.c 2004/04/02 08:26:51 @@ -52,13 +52,13 @@ int invallen, char *indata) { if (instatus != YP_TRUE) - return instatus; + return 1; if (inkey && inkeylen > 0 && inval && invallen > 0) { struct response *newp = malloc (sizeof (struct response) + invallen + 1); if (newp == NULL) - return YP_FALSE; /* We have no error code for out of memory */ + return 1; /* We have no error code for out of memory */ if (start == NULL) start = newp; --- nis/nss_nis/nis-initgroups.c +++ nis/nss_nis/nis-initgroups.c 2004/04/02 08:33:11 @@ -59,14 +59,14 @@ intern_t *intern = (intern_t *) indata; if (instatus != YP_TRUE) - return instatus; + return 1; if (inkey && inkeylen > 0 && inval && invallen > 0) { struct response_t *newp = malloc (sizeof (struct response_t) + invallen + 1); if (newp == NULL) - return YP_FALSE; /* We have no error code for out of memory */ + return 1; /* We have no error code for out of memory */ if (intern->start == NULL) intern->start = newp; --- nis/nss_nis/nis-proto.c +++ nis/nss_nis/nis-proto.c 2004/04/02 08:33:26 @@ -49,13 +49,13 @@ int invallen, char *indata) { if (instatus != YP_TRUE) - return instatus; + return 1; if (inkey && inkeylen > 0 && inval && invallen > 0) { struct response *newp = malloc (sizeof (struct response) + invallen + 1); if (newp == NULL) - return YP_FALSE; /* We have no error code for out of memory */ + return 1; /* We have no error code for out of memory */ if (start == NULL) start = newp; --- nis/nss_nis/nis-rpc.c +++ nis/nss_nis/nis-rpc.c 2004/04/02 08:33:40 @@ -57,14 +57,14 @@ intern_t *intern = (intern_t *)indata; if (instatus != YP_TRUE) - return instatus; + return 1; if (inkey && inkeylen > 0 && inval && invallen > 0) { struct response_t *newp = malloc (sizeof (struct response_t) + invallen + 1); if (newp == NULL) - return YP_FALSE; /* We have no error code for out of memory */ + return 1; /* We have no error code for out of memory */ if (intern->start == NULL) intern->start = newp; --- nis/nss_nis/nis-service.c +++ nis/nss_nis/nis-service.c 2004/04/02 08:34:14 @@ -70,14 +70,14 @@ intern_t *intern = (intern_t *) indata; if (instatus != YP_TRUE) - return instatus; + return 1; if (inkey && inkeylen > 0 && inval && invallen > 0) { struct response_t *newp = malloc (sizeof (struct response_t) + invallen + 1); if (newp == NULL) - return YP_FALSE; /* We have no error code for out of memory */ + return 1; /* We have no error code for out of memory */ if (intern->start == NULL) intern->start = newp; --vkogqOf2sHV7VnPd--