svn commit: trunk/uClibc/libc/inet
vda at uclibc.org
vda at uclibc.org
Fri Jun 6 07:23:49 UTC 2008
Author: vda
Date: 2008-06-06 00:23:47 -0700 (Fri, 06 Jun 2008)
New Revision: 22243
Log:
Fix failure in test/inet/gethost_r-align:
we were closing a FILE, but did not record that fact by setting
a variable to NULL, and then we used it for reading!
While at it, small reduction in bss.
Run tested.
text data bss dec hex filename
- 210 0 12 222 de libc/inet/gethostent.o
+ 230 0 9 239 ef libc/inet/gethostent.o
Modified:
trunk/uClibc/libc/inet/resolv.c
Changeset:
Modified: trunk/uClibc/libc/inet/resolv.c
===================================================================
--- trunk/uClibc/libc/inet/resolv.c 2008-06-06 03:24:45 UTC (rev 22242)
+++ trunk/uClibc/libc/inet/resolv.c 2008-06-06 07:23:47 UTC (rev 22243)
@@ -1721,22 +1721,24 @@
#ifdef L_gethostent
__UCLIBC_MUTEX_STATIC(mylock, PTHREAD_MUTEX_INITIALIZER);
-static int __stay_open;
+static smallint __stay_open;
static FILE * __gethostent_fp;
void endhostent(void)
{
__UCLIBC_MUTEX_LOCK(mylock);
__stay_open = 0;
- if (__gethostent_fp)
+ if (__gethostent_fp) {
fclose(__gethostent_fp);
+ __gethostent_fp = NULL;
+ }
__UCLIBC_MUTEX_UNLOCK(mylock);
}
void sethostent(int stay_open)
{
__UCLIBC_MUTEX_LOCK(mylock);
- __stay_open = stay_open;
+ __stay_open = (stay_open != 0);
__UCLIBC_MUTEX_UNLOCK(mylock);
}
@@ -1757,8 +1759,10 @@
ret = __read_etc_hosts_r(__gethostent_fp, NULL, AF_INET, GETHOSTENT,
result_buf, buf, buflen, result, h_errnop);
- if (__stay_open == 0)
+ if (__stay_open == 0) {
fclose(__gethostent_fp);
+ __gethostent_fp = NULL;
+ }
DONE:
__UCLIBC_MUTEX_UNLOCK(mylock);
return ret;
More information about the uClibc-cvs
mailing list