diff --git a/criu/cr-restore.c b/criu/cr-restore.c index 23be81140..bf85ab04b 100644 --- a/criu/cr-restore.c +++ b/criu/cr-restore.c @@ -2353,6 +2353,9 @@ int cr_restore_tasks(void) if (vdso_init_restore()) goto err; + if (tty_init_restore()) + goto err; + if (opts.cpu_cap & CPU_CAP_IMAGE) { if (cpu_validate_cpuinfo()) goto err; diff --git a/criu/include/tty.h b/criu/include/tty.h index 95ced8396..8419593e5 100644 --- a/criu/include/tty.h +++ b/criu/include/tty.h @@ -32,6 +32,7 @@ struct mount_info; extern int devpts_restore(struct mount_info *pm); extern int tty_prep_fds(void); +extern int tty_init_restore(void); extern int devpts_check_bindmount(struct mount_info *m); diff --git a/criu/tty.c b/criu/tty.c index e9a28897c..dee8d46bf 100644 --- a/criu/tty.c +++ b/criu/tty.c @@ -349,11 +349,8 @@ static mutex_t *tty_mutex; static bool tty_is_master(struct tty_info *info); -static int init_tty_mutex(void) +int tty_init_restore(void) { - if (tty_mutex) - return 0; - tty_mutex = shmalloc(sizeof(*tty_mutex)); if (!tty_mutex) { pr_err("Can't create ptmx index mutex\n"); @@ -600,9 +597,6 @@ static int __pty_open_ptmx_index(int index, int flags, memset(fds, 0xff, sizeof(fds)); - if (init_tty_mutex()) - return -1; - mutex_lock(tty_mutex); for (i = 0; i < ARRAY_SIZE(fds); i++) { @@ -1792,13 +1786,6 @@ static int tty_info_setup(struct tty_info *info) add_post_prepare_cb_once(&prep_tty_restore); - /* - * Call it explicitly. Post-callbacks will be called after - * namespaces preparation, while the latter needs this mutex. - */ - if (init_tty_mutex()) - return -1; - info->fdstore_id = -1; return file_desc_add(&info->d, info->tfe->id, &tty_desc_ops); }