diff options
author | Colin Watson <cjwatson@debian.org> | 2004-03-01 02:25:32 +0000 |
---|---|---|
committer | Colin Watson <cjwatson@debian.org> | 2004-03-01 02:25:32 +0000 |
commit | ea8116a11e3de70036dbc665ccb0d486cf89cac9 (patch) | |
tree | d73ccdff78d8608e156465af42e6a1b3527fb2d6 /log.c | |
parent | e39b311381a5609cc05acf298c42fba196dc524b (diff) | |
parent | f5bda272678ec6dccaa5f29379cf60cb855018e8 (diff) |
Merge 3.8p1 to the trunk. This builds and runs, but I haven't tested it
extensively yet.
ProtocolKeepAlives is now just a compatibility alias for
ServerAliveInterval.
Diffstat (limited to 'log.c')
-rw-r--r-- | log.c | 83 |
1 files changed, 3 insertions, 80 deletions
@@ -34,7 +34,7 @@ | |||
34 | */ | 34 | */ |
35 | 35 | ||
36 | #include "includes.h" | 36 | #include "includes.h" |
37 | RCSID("$OpenBSD: log.c,v 1.28 2003/05/24 09:02:22 djm Exp $"); | 37 | RCSID("$OpenBSD: log.c,v 1.29 2003/09/23 20:17:11 markus Exp $"); |
38 | 38 | ||
39 | #include "log.h" | 39 | #include "log.h" |
40 | #include "xmalloc.h" | 40 | #include "xmalloc.h" |
@@ -184,83 +184,6 @@ debug3(const char *fmt,...) | |||
184 | va_end(args); | 184 | va_end(args); |
185 | } | 185 | } |
186 | 186 | ||
187 | /* Fatal cleanup */ | ||
188 | |||
189 | struct fatal_cleanup { | ||
190 | struct fatal_cleanup *next; | ||
191 | void (*proc) (void *); | ||
192 | void *context; | ||
193 | }; | ||
194 | |||
195 | static struct fatal_cleanup *fatal_cleanups = NULL; | ||
196 | |||
197 | /* Registers a cleanup function to be called by fatal() before exiting. */ | ||
198 | |||
199 | void | ||
200 | fatal_add_cleanup(void (*proc) (void *), void *context) | ||
201 | { | ||
202 | struct fatal_cleanup *cu; | ||
203 | |||
204 | cu = xmalloc(sizeof(*cu)); | ||
205 | cu->proc = proc; | ||
206 | cu->context = context; | ||
207 | cu->next = fatal_cleanups; | ||
208 | fatal_cleanups = cu; | ||
209 | } | ||
210 | |||
211 | /* Removes a cleanup frunction to be called at fatal(). */ | ||
212 | |||
213 | void | ||
214 | fatal_remove_cleanup(void (*proc) (void *context), void *context) | ||
215 | { | ||
216 | struct fatal_cleanup **cup, *cu; | ||
217 | |||
218 | for (cup = &fatal_cleanups; *cup; cup = &cu->next) { | ||
219 | cu = *cup; | ||
220 | if (cu->proc == proc && cu->context == context) { | ||
221 | *cup = cu->next; | ||
222 | xfree(cu); | ||
223 | return; | ||
224 | } | ||
225 | } | ||
226 | fatal("fatal_remove_cleanup: no such cleanup function: 0x%lx 0x%lx", | ||
227 | (u_long) proc, (u_long) context); | ||
228 | } | ||
229 | |||
230 | /* Remove all cleanups, to be called after fork() */ | ||
231 | void | ||
232 | fatal_remove_all_cleanups(void) | ||
233 | { | ||
234 | struct fatal_cleanup *cu, *next_cu; | ||
235 | |||
236 | for (cu = fatal_cleanups; cu; cu = next_cu) { | ||
237 | next_cu = cu->next; | ||
238 | xfree(cu); | ||
239 | } | ||
240 | fatal_cleanups = NULL; | ||
241 | } | ||
242 | |||
243 | /* Cleanup and exit */ | ||
244 | void | ||
245 | fatal_cleanup(void) | ||
246 | { | ||
247 | struct fatal_cleanup *cu, *next_cu; | ||
248 | static int called = 0; | ||
249 | |||
250 | if (called) | ||
251 | exit(255); | ||
252 | called = 1; | ||
253 | /* Call cleanup functions. */ | ||
254 | for (cu = fatal_cleanups; cu; cu = next_cu) { | ||
255 | next_cu = cu->next; | ||
256 | debug("Calling cleanup 0x%lx(0x%lx)", | ||
257 | (u_long) cu->proc, (u_long) cu->context); | ||
258 | (*cu->proc) (cu->context); | ||
259 | } | ||
260 | exit(255); | ||
261 | } | ||
262 | |||
263 | |||
264 | /* | 187 | /* |
265 | * Initialize the log. | 188 | * Initialize the log. |
266 | */ | 189 | */ |
@@ -344,7 +267,7 @@ log_init(char *av0, LogLevel level, SyslogFacility facility, int on_stderr) | |||
344 | void | 267 | void |
345 | do_log(LogLevel level, const char *fmt, va_list args) | 268 | do_log(LogLevel level, const char *fmt, va_list args) |
346 | { | 269 | { |
347 | #ifdef OPENLOG_R | 270 | #if defined(HAVE_OPENLOG_R) && defined(SYSLOG_DATA_INIT) |
348 | struct syslog_data sdata = SYSLOG_DATA_INIT; | 271 | struct syslog_data sdata = SYSLOG_DATA_INIT; |
349 | #endif | 272 | #endif |
350 | char msgbuf[MSGBUFSIZ]; | 273 | char msgbuf[MSGBUFSIZ]; |
@@ -400,7 +323,7 @@ do_log(LogLevel level, const char *fmt, va_list args) | |||
400 | snprintf(msgbuf, sizeof msgbuf, "%s\r\n", fmtbuf); | 323 | snprintf(msgbuf, sizeof msgbuf, "%s\r\n", fmtbuf); |
401 | write(STDERR_FILENO, msgbuf, strlen(msgbuf)); | 324 | write(STDERR_FILENO, msgbuf, strlen(msgbuf)); |
402 | } else { | 325 | } else { |
403 | #ifdef OPENLOG_R | 326 | #if defined(HAVE_OPENLOG_R) && defined(SYSLOG_DATA_INIT) |
404 | openlog_r(argv0 ? argv0 : __progname, LOG_PID, log_facility, &sdata); | 327 | openlog_r(argv0 ? argv0 : __progname, LOG_PID, log_facility, &sdata); |
405 | syslog_r(pri, &sdata, "%.500s", fmtbuf); | 328 | syslog_r(pri, &sdata, "%.500s", fmtbuf); |
406 | closelog_r(&sdata); | 329 | closelog_r(&sdata); |