Commit d9d9686f authored by Pavel Emelyanov's avatar Pavel Emelyanov Committed by Andrei Vagin

restore: Tune up _once stuff

Having ppreh_heads we can simplify the _once helper
by re-using the .next field.
Signed-off-by: 's avatarPavel Emelyanov <xemul@virtuozzo.com>
Signed-off-by: 's avatarAndrei Vagin <avagin@virtuozzo.com>
parent a9001753
......@@ -29,11 +29,16 @@ extern int cr_dedup(void);
extern int check_add_feature(char *arg);
extern void pr_check_features(const char *offset, const char *sep, int width);
#define add_post_prepare_cb_once(phead) do { \
static int __cb_called = 0; \
if (!__cb_called) \
add_post_prepare_cb(phead); \
__cb_called = 1; \
#define PPREP_HEAD_INACTIVE ((struct pprep_head *)-1)
#define add_post_prepare_cb_once(phead) do { \
if ((phead)->next == PPREP_HEAD_INACTIVE)\
add_post_prepare_cb(phead); \
} while (0)
#define MAKE_PPREP_HEAD(name) struct pprep_head name = { \
.next = PPREP_HEAD_INACTIVE, \
.actor = name##_cb, \
}
#endif /* __CR_CRTOOLS_H__ */
......@@ -141,9 +141,7 @@ static int mark_pipe_master_cb(struct pprep_head *ph)
return 0;
}
static struct pprep_head mark_pipe_master = {
.actor = mark_pipe_master_cb,
};
static MAKE_PPREP_HEAD(mark_pipe_master);
static struct pipe_data_rst *pd_hash_pipes[PIPE_DATA_HASH_SIZE];
......
......@@ -1360,9 +1360,7 @@ static void unlink_stale(struct unix_sk_info *ui)
}
static int resolve_unix_peers_cb(struct pprep_head *ph);
static struct pprep_head resolve_unix_peers = {
.actor = resolve_unix_peers_cb,
};
static MAKE_PPREP_HEAD(resolve_unix_peers);
static int collect_one_unixsk(void *o, ProtobufCMessage *base, struct cr_img *i)
{
......
......@@ -1568,10 +1568,7 @@ static int prep_tty_restore_cb(struct pprep_head *ph)
return 0;
}
static struct pprep_head prep_tty_restore = {
.actor = prep_tty_restore_cb,,
};
static MAKE_PPREP_HEAD(prep_tty_restore);
static int collect_one_tty(void *obj, ProtobufCMessage *msg, struct cr_img *i)
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment