diff options
Diffstat (limited to 'src/lib/panic.c')
-rw-r--r-- | src/lib/panic.c | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/src/lib/panic.c b/src/lib/panic.c new file mode 100644 index 00000000..f3cfe82d --- /dev/null +++ b/src/lib/panic.c | |||
@@ -0,0 +1,36 @@ | |||
1 | |||
2 | |||
3 | /** | ||
4 | * Handler for fatal errors. | ||
5 | */ | ||
6 | MHD_PanicCallback mhd_panic = NULL; | ||
7 | |||
8 | /** | ||
9 | * Closure argument for #mhd_panic. | ||
10 | */ | ||
11 | void *mhd_panic_cls = NULL; | ||
12 | |||
13 | |||
14 | /** | ||
15 | * Sets the global error handler to a different implementation. @a cb | ||
16 | * will only be called in the case of typically fatal, serious | ||
17 | * internal consistency issues. These issues should only arise in the | ||
18 | * case of serious memory corruption or similar problems with the | ||
19 | * architecture. While @a cb is allowed to return and MHD will then | ||
20 | * try to continue, this is never safe. | ||
21 | * | ||
22 | * The default implementation that is used if no panic function is set | ||
23 | * simply prints an error message and calls `abort()`. Alternative | ||
24 | * implementations might call `exit()` or other similar functions. | ||
25 | * | ||
26 | * @param cb new error handler | ||
27 | * @param cls passed to @a cb | ||
28 | * @ingroup logging | ||
29 | */ | ||
30 | void | ||
31 | MHD_set_panic_func (MHD_PanicCallback cb, | ||
32 | void *cls) | ||
33 | { | ||
34 | mhd_panic = cb; | ||
35 | mhd_panic_cls = cls; | ||
36 | } | ||