matrix-gui-e: bump PR for init file fixes
[openembedded.git] / recipes / glibc / glibc-2.3.2 / syslog-backrev.patch
bloba3bed2e302799cc4bf88e1720f1c606a3af05b72
1 --- misc/syslog.c 2003-07-17 22:14:44.000000000 +0000
2 +++ /skole/tjener/home0/jbailey/cvstree/libc/misc/syslog.c 2003-07-17 22:05:59.000000000 +0000
3 @@ -41,7 +41,6 @@
4 #include <fcntl.h>
5 #include <paths.h>
6 #include <stdio.h>
7 -#include <stdio_ext.h>
8 #include <string.h>
9 #include <time.h>
10 #include <unistd.h>
11 @@ -75,27 +74,9 @@
12 static void openlog_internal(const char *, int, int) internal_function;
13 static void closelog_internal(void);
14 static void sigpipe_handler (int);
17 -struct cleanup_arg
19 - void *buf;
20 - struct sigaction *oldaction;
21 -};
23 -static void
24 -cancel_handler (void *ptr)
26 - /* Restore the old signal handler. */
27 - struct cleanup_arg *clarg = (struct cleanup_arg *) ptr;
29 - if (clarg != NULL && clarg->oldaction != NULL)
30 - __sigaction (SIGPIPE, clarg->oldaction, NULL);
32 - /* Free the lock. */
33 - __libc_lock_unlock (syslog_lock);
36 +#ifdef _LIBC_REENTRANT
37 +static void cancel_handler (void *);
38 +#endif
41 * syslog, vsyslog --
42 @@ -137,6 +118,7 @@
43 size_t bufsize = 0;
44 size_t prioff, msgoff;
45 struct sigaction action, oldaction;
46 + struct sigaction *oldaction_ptr = NULL;
47 int sigpipe;
48 int saved_errno = errno;
49 char failbuf[3 * sizeof (pid_t) + sizeof "out of memory []"];
50 @@ -183,7 +165,6 @@
52 else
54 - __fsetlocking (f, FSETLOCKING_BYCALLER);
55 prioff = fprintf (f, "<%d>", pri);
56 (void) time (&now);
57 #ifdef USE_IN_LIBIO
58 @@ -201,12 +182,9 @@
59 if (LogTag != NULL)
60 fputs_unlocked (LogTag, f);
61 if (LogStat & LOG_PID)
62 - fprintf (f, "[%d]", (int) __getpid ());
63 + fprintf (f, "[%d]", __getpid ());
64 if (LogTag != NULL)
65 - {
66 - putc_unlocked (':', f);
67 - putc_unlocked (' ', f);
68 - }
69 + putc_unlocked (':', f), putc_unlocked (' ', f);
71 /* Restore errno for %m format. */
72 __set_errno (saved_errno);
73 @@ -234,22 +212,16 @@
74 v->iov_base = (char *) "\n";
75 v->iov_len = 1;
78 - __libc_cleanup_push (free, buf);
80 - /* writev is a cancellation point. */
81 (void)__writev(STDERR_FILENO, iov, v - iov + 1);
83 - __libc_cleanup_pop (0);
86 +#ifdef _LIBC_REENTRANT
87 /* Prepare for multiple users. We have to take care: open and
88 write are cancellation points. */
89 - struct cleanup_arg clarg;
90 - clarg.buf = buf;
91 - clarg.oldaction = NULL;
92 - __libc_cleanup_push (cancel_handler, &clarg);
93 + __libc_cleanup_region_start (1, (void (*) (void *)) cancel_handler,
94 + &oldaction_ptr);
95 __libc_lock_lock (syslog_lock);
96 +#endif
98 /* Prepare for a broken connection. */
99 memset (&action, 0, sizeof (action));
100 @@ -257,7 +229,7 @@
101 sigemptyset (&action.sa_mask);
102 sigpipe = __sigaction (SIGPIPE, &action, &oldaction);
103 if (sigpipe == 0)
104 - clarg.oldaction = &oldaction;
105 + oldaction_ptr = &oldaction;
107 /* Get connected, output the message to the local logger. */
108 if (!connected)
109 @@ -299,9 +271,11 @@
110 if (sigpipe == 0)
111 __sigaction (SIGPIPE, &oldaction, (struct sigaction *) NULL);
113 +#ifdef _LIBC_REENTRANT
114 /* End of critical section. */
115 - __libc_cleanup_pop (0);
116 + __libc_cleanup_region_end (0);
117 __libc_lock_unlock (syslog_lock);
118 +#endif
120 free (buf);
122 @@ -309,7 +283,6 @@
124 static struct sockaddr SyslogAddr; /* AF_UNIX address of local logger */
127 static void
128 internal_function
129 openlog_internal(const char *ident, int logstat, int logfac)
130 @@ -339,9 +312,8 @@
131 == -1)
133 int saved_errno = errno;
134 - int fd = LogFile;
135 + (void)__close(LogFile);
136 LogFile = -1;
137 - (void)__close(fd);
138 if (LogType == SOCK_DGRAM
139 && saved_errno == EPROTOTYPE)
141 @@ -357,16 +329,28 @@
146 +static void
147 +log_cleanup (void *arg)
149 + __libc_lock_unlock (syslog_lock);
152 void
153 openlog (const char *ident, int logstat, int logfac)
155 - /* Protect against multiple users and cancellation. */
156 - __libc_cleanup_push (cancel_handler, NULL);
157 +#ifdef _LIBC_REENTRANT
158 + /* Protect against multiple users. */
159 + __libc_cleanup_region_start (1, log_cleanup, NULL);
160 __libc_lock_lock (syslog_lock);
161 +#endif
163 openlog_internal (ident, logstat, logfac);
165 - __libc_cleanup_pop (1);
166 +#ifdef _LIBC_REENTRANT
167 + /* Free the lock. */
168 + __libc_cleanup_region_end (1);
169 +#endif
172 static void
173 @@ -389,17 +373,36 @@
174 void
175 closelog ()
177 - /* Protect against multiple users and cancellation. */
178 - __libc_cleanup_push (cancel_handler, NULL);
179 +#ifdef _LIBC_REENTRANT
180 + /* Protect against multiple users. */
181 + __libc_cleanup_region_start (1, log_cleanup, NULL);
182 __libc_lock_lock (syslog_lock);
183 +#endif
185 closelog_internal ();
186 LogTag = NULL;
187 LogType = SOCK_DGRAM; /* this is the default */
189 +#ifdef _LIBC_REENTRANT
190 + /* Free the lock. */
191 + __libc_cleanup_region_end (1);
192 +#endif
195 +#ifdef _LIBC_REENTRANT
196 +static void
197 +cancel_handler (void *ptr)
199 + /* Restore the old signal handler. */
200 + struct sigaction *oldaction = *((struct sigaction **) ptr);
202 + if (oldaction != (struct sigaction *) NULL)
203 + __sigaction (SIGPIPE, oldaction, (struct sigaction *) NULL);
205 /* Free the lock. */
206 - __libc_cleanup_pop (1);
207 + __libc_lock_unlock (syslog_lock);
209 +#endif
211 /* setlogmask -- set the log mask level */