mirror of
https://github.com/checkpoint-restore/criu
synced 2025-09-04 08:15:37 +00:00
restore: Tune up _once stuff
Having ppreh_heads we can simplify the _once helper by re-using the .next field. Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com> Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
This commit is contained in:
committed by
Andrei Vagin
parent
a9001753c9
commit
d9d9686f38
@@ -29,11 +29,16 @@ extern int cr_dedup(void);
|
|||||||
extern int check_add_feature(char *arg);
|
extern int check_add_feature(char *arg);
|
||||||
extern void pr_check_features(const char *offset, const char *sep, int width);
|
extern void pr_check_features(const char *offset, const char *sep, int width);
|
||||||
|
|
||||||
#define add_post_prepare_cb_once(phead) do { \
|
#define PPREP_HEAD_INACTIVE ((struct pprep_head *)-1)
|
||||||
static int __cb_called = 0; \
|
|
||||||
if (!__cb_called) \
|
#define add_post_prepare_cb_once(phead) do { \
|
||||||
add_post_prepare_cb(phead); \
|
if ((phead)->next == PPREP_HEAD_INACTIVE)\
|
||||||
__cb_called = 1; \
|
add_post_prepare_cb(phead); \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
|
#define MAKE_PPREP_HEAD(name) struct pprep_head name = { \
|
||||||
|
.next = PPREP_HEAD_INACTIVE, \
|
||||||
|
.actor = name##_cb, \
|
||||||
|
}
|
||||||
|
|
||||||
#endif /* __CR_CRTOOLS_H__ */
|
#endif /* __CR_CRTOOLS_H__ */
|
||||||
|
@@ -141,9 +141,7 @@ static int mark_pipe_master_cb(struct pprep_head *ph)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct pprep_head mark_pipe_master = {
|
static MAKE_PPREP_HEAD(mark_pipe_master);
|
||||||
.actor = mark_pipe_master_cb,
|
|
||||||
};
|
|
||||||
|
|
||||||
static struct pipe_data_rst *pd_hash_pipes[PIPE_DATA_HASH_SIZE];
|
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 int resolve_unix_peers_cb(struct pprep_head *ph);
|
||||||
static struct pprep_head resolve_unix_peers = {
|
static MAKE_PPREP_HEAD(resolve_unix_peers);
|
||||||
.actor = resolve_unix_peers_cb,
|
|
||||||
};
|
|
||||||
|
|
||||||
static int collect_one_unixsk(void *o, ProtobufCMessage *base, struct cr_img *i)
|
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;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct pprep_head prep_tty_restore = {
|
static MAKE_PPREP_HEAD(prep_tty_restore);
|
||||||
.actor = prep_tty_restore_cb,,
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
static int collect_one_tty(void *obj, ProtobufCMessage *msg, struct cr_img *i)
|
static int collect_one_tty(void *obj, ProtobufCMessage *msg, struct cr_img *i)
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user