Update.
2000-06-14 Ulrich Drepper <drepper@redhat.com> * misc/syslog.c (vsyslog): Allow open_memstream to fail without crashing the application. Emit some simple error message. Reported by mju@panasas.com [PR libc/1769].
This commit is contained in:
parent
38161ac76e
commit
594cee6c49
|
@ -1,3 +1,9 @@
|
||||||
|
2000-06-14 Ulrich Drepper <drepper@redhat.com>
|
||||||
|
|
||||||
|
* misc/syslog.c (vsyslog): Allow open_memstream to fail without
|
||||||
|
crashing the application. Emit some simple error message.
|
||||||
|
Reported by mju@panasas.com [PR libc/1769].
|
||||||
|
|
||||||
2000-06-13 Ulrich Drepper <drepper@redhat.com>
|
2000-06-13 Ulrich Drepper <drepper@redhat.com>
|
||||||
|
|
||||||
* malloc/Makefile (distribute): Add memprof.sh and memprofstat.c.
|
* malloc/Makefile (distribute): Add memprof.sh and memprofstat.c.
|
||||||
|
|
6
NEWS
6
NEWS
|
@ -47,6 +47,12 @@ Version 2.2
|
||||||
* A port to Hitachi SH3 and SH4 has been contributed by Kazumoto Kojima
|
* A port to Hitachi SH3 and SH4 has been contributed by Kazumoto Kojima
|
||||||
and Yutaka Niibe.
|
and Yutaka Niibe.
|
||||||
|
|
||||||
|
* POSIX clocks and timers implemented by Kaz Kylheku and Ulrich Drepper.
|
||||||
|
|
||||||
|
* POSIX spawn function family implemented by Ulrich Drepper.
|
||||||
|
|
||||||
|
* POSIX spinlocks are now available.
|
||||||
|
|
||||||
|
|
||||||
Version 2.1.3
|
Version 2.1.3
|
||||||
|
|
||||||
|
|
|
@ -120,6 +120,7 @@ vsyslog(pri, fmt, ap)
|
||||||
struct sigaction *oldaction_ptr = NULL;
|
struct sigaction *oldaction_ptr = NULL;
|
||||||
int sigpipe;
|
int sigpipe;
|
||||||
int saved_errno = errno;
|
int saved_errno = errno;
|
||||||
|
char failbuf[3 * sizeof (pid_t) + sizeof "out of memory []"];
|
||||||
|
|
||||||
#define INTERNALLOG LOG_ERR|LOG_CONS|LOG_PERROR|LOG_PID
|
#define INTERNALLOG LOG_ERR|LOG_CONS|LOG_PERROR|LOG_PID
|
||||||
/* Check for invalid bits. */
|
/* Check for invalid bits. */
|
||||||
|
@ -139,36 +140,61 @@ vsyslog(pri, fmt, ap)
|
||||||
|
|
||||||
/* Build the message in a memory-buffer stream. */
|
/* Build the message in a memory-buffer stream. */
|
||||||
f = open_memstream (&buf, &bufsize);
|
f = open_memstream (&buf, &bufsize);
|
||||||
prioff = fprintf (f, "<%d>", pri);
|
if (f == NULL)
|
||||||
(void) time (&now);
|
{
|
||||||
|
/* We cannot get a stream. There is not much we can do but
|
||||||
|
emitting an error messages. */
|
||||||
|
char numbuf[3 * sizeof (pid_t)];
|
||||||
|
char *nump;
|
||||||
|
char *endp = __stpcpy (failbuf, "out of memory [");
|
||||||
|
pid_t pid = __getpid ();
|
||||||
|
|
||||||
|
nump = numbuf + sizeof (numbuf);
|
||||||
|
/* The PID can never be zero. */
|
||||||
|
do
|
||||||
|
*--nump = '0' + pid % 10;
|
||||||
|
while ((pid /= 10) != 0);
|
||||||
|
|
||||||
|
endp = __mempcpy (endp, nump, (nump + sizeof (numbuf)) - nump);
|
||||||
|
*endp++ = ']';
|
||||||
|
*endp = '\0';
|
||||||
|
buf = failbuf;
|
||||||
|
bufsize = endp - failbuf;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
prioff = fprintf (f, "<%d>", pri);
|
||||||
|
(void) time (&now);
|
||||||
#ifdef USE_IN_LIBIO
|
#ifdef USE_IN_LIBIO
|
||||||
f->_IO_write_ptr += strftime (f->_IO_write_ptr,
|
f->_IO_write_ptr += strftime (f->_IO_write_ptr,
|
||||||
f->_IO_write_end - f->_IO_write_ptr,
|
f->_IO_write_end - f->_IO_write_ptr,
|
||||||
"%h %e %T ",
|
"%h %e %T ",
|
||||||
__localtime_r (&now, &now_tm));
|
__localtime_r (&now, &now_tm));
|
||||||
#else
|
#else
|
||||||
f->__bufp += strftime (f->__bufp, f->__put_limit - f->__bufp,
|
f->__bufp += strftime (f->__bufp, f->__put_limit - f->__bufp,
|
||||||
"%h %e %T ", __localtime_r (&now, &now_tm));
|
"%h %e %T ", __localtime_r (&now, &now_tm));
|
||||||
#endif
|
#endif
|
||||||
msgoff = ftell (f);
|
msgoff = ftell (f);
|
||||||
if (LogTag == NULL)
|
if (LogTag == NULL)
|
||||||
LogTag = __progname;
|
LogTag = __progname;
|
||||||
if (LogTag != NULL)
|
if (LogTag != NULL)
|
||||||
fputs_unlocked (LogTag, f);
|
fputs_unlocked (LogTag, f);
|
||||||
if (LogStat & LOG_PID)
|
if (LogStat & LOG_PID)
|
||||||
fprintf (f, "[%d]", __getpid ());
|
fprintf (f, "[%d]", __getpid ());
|
||||||
if (LogTag != NULL)
|
if (LogTag != NULL)
|
||||||
putc_unlocked (':', f), putc_unlocked (' ', f);
|
putc_unlocked (':', f), putc_unlocked (' ', f);
|
||||||
|
|
||||||
/* Restore errno for %m format. */
|
/* Restore errno for %m format. */
|
||||||
__set_errno (saved_errno);
|
__set_errno (saved_errno);
|
||||||
|
|
||||||
/* We have the header. Print the user's format into the buffer. */
|
/* We have the header. Print the user's format into the
|
||||||
vfprintf (f, fmt, ap);
|
buffer. */
|
||||||
|
vfprintf (f, fmt, ap);
|
||||||
|
|
||||||
/* Close the memory stream; this will finalize the data
|
/* Close the memory stream; this will finalize the data
|
||||||
into a malloc'd buffer in BUF. */
|
into a malloc'd buffer in BUF. */
|
||||||
fclose (f);
|
fclose (f);
|
||||||
|
}
|
||||||
|
|
||||||
/* Output to stderr if requested. */
|
/* Output to stderr if requested. */
|
||||||
if (LogStat & LOG_PERROR) {
|
if (LogStat & LOG_PERROR) {
|
||||||
|
@ -326,7 +352,7 @@ closelog ()
|
||||||
closelog_internal ();
|
closelog_internal ();
|
||||||
LogTag = NULL;
|
LogTag = NULL;
|
||||||
LogType = SOCK_DGRAM; /* this is the default */
|
LogType = SOCK_DGRAM; /* this is the default */
|
||||||
|
|
||||||
/* Free the lock. */
|
/* Free the lock. */
|
||||||
__libc_cleanup_region_end (1);
|
__libc_cleanup_region_end (1);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue