From c06a49c551ebfc7f320a05546b5a013714ac82e5 Mon Sep 17 00:00:00 2001 From: Ulrich Drepper Date: Tue, 28 Aug 2001 04:52:25 +0000 Subject: [PATCH] Update. 2001-08-27 Ulrich Drepper * misc/syslog.c (vsyslog): Try a bit harder to use syslogd. If the connection went down after we first used it try to connect again and resend the message before printing to the console. Reported by Coserea Gh. Tudor . 2001-08-27 Jakub Jelinek * string/tst-strlen.c (main): Test strnlen (, -1) too. * sysdeps/generic/strnlen.c (__strnlen): Fix for maxlens with top bit set. 2001-08-27 Ulrich Drepper * iconv/strtab.c (searchstring): Use correct length for comparison. (strtabadd): Account total size correct if new string has old string as substring. --- ChangeLog | 20 +++++++++++++++++ iconv/strtab.c | 5 ++--- linuxthreads/ChangeLog | 5 +++++ linuxthreads/sysdeps/pthread/bits/libc-lock.h | 6 ++++- misc/syslog.c | 32 ++++++++++++++++++--------- string/tst-strlen.c | 3 ++- sysdeps/generic/strnlen.c | 3 +++ 7 files changed, 59 insertions(+), 15 deletions(-) diff --git a/ChangeLog b/ChangeLog index a4abdeb..1d21662 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,23 @@ +2001-08-27 Ulrich Drepper + + * misc/syslog.c (vsyslog): Try a bit harder to use syslogd. If + the connection went down after we first used it try to connect + again and resend the message before printing to the console. + Reported by Coserea Gh. Tudor . + +2001-08-27 Jakub Jelinek + + * string/tst-strlen.c (main): Test strnlen (, -1) too. + * sysdeps/generic/strnlen.c (__strnlen): Fix for maxlens with top + bit set. + +2001-08-27 Ulrich Drepper + + * iconv/strtab.c (searchstring): Use correct length for + comparison. + (strtabadd): Account total size correct if new string has old string as + substring. + 2001-08-27 Jakub Jelinek * elf/rtld.c (dl_main): Update call to _dl_lookup_symbol. diff --git a/iconv/strtab.c b/iconv/strtab.c index d567f57..4189f97 100644 --- a/iconv/strtab.c +++ b/iconv/strtab.c @@ -193,7 +193,7 @@ searchstring (struct Strent **sep, struct Strent *newstr) /* Compare the strings. */ cmpres = memcmp ((*sep)->reverse, newstr->reverse, - MIN ((*sep)->len, newstr->len)); + MIN ((*sep)->len, newstr->len) - 1); if (cmpres == 0) /* We found a matching string. */ return sep; @@ -236,10 +236,9 @@ strtabadd (struct Strtab *st, const char *str, size_t len) /* When we get here it means that the string we are about to add has a common prefix with a string we already have but it is longer. In this case we have to put it first. */ + st->total += newstr->len - (*sep)->len; newstr->next = *sep; *sep = newstr; - - st->total += newstr->len - (*sep)->len; } else { diff --git a/linuxthreads/ChangeLog b/linuxthreads/ChangeLog index 5cbf827..1ce5a23 100644 --- a/linuxthreads/ChangeLog +++ b/linuxthreads/ChangeLog @@ -1,3 +1,8 @@ +2001-08-27 Jakub Jelinek + + * sysdeps/pthread/bits/libc-lock.h (__libc_rwlock_t): Only define to + non-opaque type if __USE_UNIX98. + 2001-08-26 Jakub Jelinek * sysdeps/pthread/bits/libc-lock.h (__libc_lock_t): Define diff --git a/linuxthreads/sysdeps/pthread/bits/libc-lock.h b/linuxthreads/sysdeps/pthread/bits/libc-lock.h index 02dfc91..2c1d162 100644 --- a/linuxthreads/sysdeps/pthread/bits/libc-lock.h +++ b/linuxthreads/sysdeps/pthread/bits/libc-lock.h @@ -25,8 +25,12 @@ /* Mutex type. */ #if defined(_LIBC) || defined(_IO_MTSAFE_IO) typedef pthread_mutex_t __libc_lock_t; -typedef pthread_rwlock_t __libc_rwlock_t; typedef struct { pthread_mutex_t mutex; } __libc_lock_recursive_t; +# ifdef __USE_UNIX98 +typedef pthread_rwlock_t __libc_rwlock_t; +# else +typedef struct __libc_rwlock_opaque__ __libc_rwlock_t; +# endif #else typedef struct __libc_lock_opaque__ __libc_lock_t; typedef struct __libc_lock_recursive_opaque__ __libc_lock_recursive_t; diff --git a/misc/syslog.c b/misc/syslog.c index 9553c29..58f8199 100644 --- a/misc/syslog.c +++ b/misc/syslog.c @@ -239,17 +239,29 @@ vsyslog(pri, fmt, ap) if (!connected || __send(LogFile, buf, bufsize, 0) < 0) { - closelog_internal (); /* attempt re-open next time */ - /* - * Output the message to the console; don't worry about blocking, - * if console blocks everything will. Make sure the error reported - * is the one from the syslogd failure. - */ - if (LogStat & LOG_CONS && - (fd = __open(_PATH_CONSOLE, O_WRONLY|O_NOCTTY, 0)) >= 0) + if (connected) { - dprintf (fd, "%s\r\n", buf + msgoff); - (void)__close(fd); + /* Try to reopen the syslog connection. Maybe it went + down. */ + closelog_internal (); + openlog_internal(LogTag, LogStat | LOG_NDELAY, 0); + } + + if (!connect || __send(LogFile, buf, bufsize, 0) < 0) + { + closelog_internal (); /* attempt re-open next time */ + /* + * Output the message to the console; don't worry + * about blocking, if console blocks everything will. + * Make sure the error reported is the one from the + * syslogd failure. + */ + if (LogStat & LOG_CONS && + (fd = __open(_PATH_CONSOLE, O_WRONLY|O_NOCTTY, 0)) >= 0) + { + dprintf (fd, "%s\r\n", buf + msgoff); + (void)__close(fd); + } } } diff --git a/string/tst-strlen.c b/string/tst-strlen.c index 1b1f834..a1e1159 100644 --- a/string/tst-strlen.c +++ b/string/tst-strlen.c @@ -31,7 +31,8 @@ main(int argc, char *argv[]) buf[words * 4 + 3] = (last & 8) != 0 ? 'e' : '\0'; buf[words * 4 + 4] = '\0'; - if (strlen (buf) != words * 4 + lens[last]) + if (strlen (buf) != words * 4 + lens[last] + || strnlen (buf, -1) != words * 4 + lens[last]) { printf ("failed for base=%Zu, words=%Zu, and last=%Zu\n", base, words, last); diff --git a/sysdeps/generic/strnlen.c b/sysdeps/generic/strnlen.c index f1b6760..1386acf 100644 --- a/sysdeps/generic/strnlen.c +++ b/sysdeps/generic/strnlen.c @@ -36,6 +36,9 @@ __strnlen (const char *str, size_t maxlen) if (maxlen == 0) return 0; + if (__builtin_expect (end_ptr < str, 0)) + end_ptr = (const char *) ~0UL; + /* Handle the first few characters by reading one character at a time. Do this until CHAR_PTR is aligned on a longword boundary. */ for (char_ptr = str; ((unsigned long int) char_ptr -- 2.7.4