~mdw
/
secnet
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
test-example: Reorder a config to better test CHILDPERSIST
[secnet]
/
util.c
diff --git
a/util.c
b/util.c
index
0215f25
..
d843859
100644
(file)
--- a/
util.c
+++ b/
util.c
@@
-204,7
+204,8
@@
static const char *phases[NR_PHASES]={
"PHASE_GETRESOURCES",
"PHASE_DROPPRIV",
"PHASE_RUN",
"PHASE_GETRESOURCES",
"PHASE_DROPPRIV",
"PHASE_RUN",
- "PHASE_SHUTDOWN"
+ "PHASE_SHUTDOWN",
+ "PHASE_CHILDPERSIST"
};
void enter_phase(uint32_t new_phase)
};
void enter_phase(uint32_t new_phase)
@@
-227,6
+228,14
@@
void phase_hooks_init(void)
LIST_INIT(&hooks[i]);
}
LIST_INIT(&hooks[i]);
}
+void clear_phase_hooks(uint32_t phase)
+{
+ struct phase_hook *h, *htmp;
+ LIST_FOREACH_SAFE(h, &hooks[phase], entry, htmp)
+ free(h);
+ LIST_INIT(&hooks[phase]);
+}
+
bool_t add_hook(uint32_t phase, hook_fn *fn, void *state)
{
struct phase_hook *h;
bool_t add_hook(uint32_t phase, hook_fn *fn, void *state)
{
struct phase_hook *h;
@@
-613,6
+622,17
@@
int iaddr_socklen(const union iaddr *ia)
}
}
}
}
+const char *pollbadbit(int revents)
+{
+#define BADBIT(b) \
+ if ((revents & b)) return #b
+ BADBIT(POLLERR);
+ BADBIT(POLLHUP);
+ /* POLLNVAL is handled by the event loop - see afterpoll_fn comment */
+#undef BADBIT
+ return 0;
+}
+
enum async_linebuf_result
async_linebuf_read(struct pollfd *pfd, struct buffer_if *buf,
const char **emsg_out)
enum async_linebuf_result
async_linebuf_read(struct pollfd *pfd, struct buffer_if *buf,
const char **emsg_out)
@@
-620,12
+640,9
@@
async_linebuf_read(struct pollfd *pfd, struct buffer_if *buf,
int revents=pfd->revents;
#define BAD(m) do{ *emsg_out=(m); return async_linebuf_broken; }while(0)
int revents=pfd->revents;
#define BAD(m) do{ *emsg_out=(m); return async_linebuf_broken; }while(0)
-#define BADBIT(b) \
- if (!(revents & b)) ; else BAD(#b)
- BADBIT(POLLERR);
- BADBIT(POLLHUP);
- /* POLLNVAL is handled by the event loop - see afterpoll_fn comment */
-#undef BADBIT
+
+ const char *badbit=pollbadbit(revents);
+ if (badbit) BAD(badbit);
if (!(revents & POLLIN))
return async_linebuf_nothing;
if (!(revents & POLLIN))
return async_linebuf_nothing;