The initialization status may be set in child process
when the parent process has called the wd_alg_init.
So need to register the callback for child process
to clear the status.
Signed-off-by: Yang Shen <shenyang39(a)huawei.com>
---
wd_aead.c | 7 +++++++
wd_cipher.c | 7 +++++++
wd_comp.c | 9 +++++++++
wd_dh.c | 7 +++++++
wd_digest.c | 7 +++++++
wd_ecc.c | 7 +++++++
wd_rsa.c | 7 +++++++
7 files changed, 51 insertions(+)
diff --git a/wd_aead.c b/wd_aead.c
index 471cb65..7f0347c 100644
--- a/wd_aead.c
+++ b/wd_aead.c
@@ -389,12 +389,19 @@ static int wd_aead_param_check(struct wd_aead_sess *sess,
return 0;
}
+static void wd_aead_clear_status()
+{
+ wd_alg_clear_init(&wd_aead_setting.status);
+}
+
int wd_aead_init(struct wd_ctx_config *config, struct wd_sched *sched)
{
void *priv;
bool flag;
int ret;
+ pthread_atfork(NULL, NULL, wd_aead_clear_status);
+
flag = wd_alg_try_init(&wd_aead_setting.status);
if (!flag)
return 0;
diff --git a/wd_cipher.c b/wd_cipher.c
index b627c0d..2eabb43 100644
--- a/wd_cipher.c
+++ b/wd_cipher.c
@@ -228,12 +228,19 @@ void wd_cipher_free_sess(handle_t h_sess)
free(sess);
}
+static void wd_cipher_clear_status()
+{
+ wd_alg_clear_init(&wd_cipher_setting.status);
+}
+
int wd_cipher_init(struct wd_ctx_config *config, struct wd_sched *sched)
{
void *priv;
bool flag;
int ret;
+ pthread_atfork(NULL, NULL, wd_cipher_clear_status);
+
flag = wd_alg_try_init(&wd_cipher_setting.status);
if (!flag)
return 0;
diff --git a/wd_comp.c b/wd_comp.c
index b9c39f1..0e89304 100644
--- a/wd_comp.c
+++ b/wd_comp.c
@@ -94,6 +94,11 @@ void wd_comp_set_driver(struct wd_comp_driver *drv)
wd_comp_setting.driver = drv;
}
+static void wd_comp_clear_status()
+{
+ wd_alg_clear_init(&wd_comp_setting.status);
+}
+
static int wd_comp_init_nolock(struct wd_ctx_config *config, struct wd_sched *sched)
{
void *priv;
@@ -187,6 +192,8 @@ int wd_comp_init(struct wd_ctx_config *config, struct wd_sched *sched)
bool flag;
int ret;
+ pthread_atfork(NULL, NULL, wd_comp_clear_status);
+
flag = wd_alg_try_init(&wd_comp_setting.status);
if (!flag)
return 0;
@@ -214,6 +221,8 @@ int wd_comp_init2_(char *alg, __u32 sched_type, int task_type, struct wd_ctx_par
bool flag;
int ret;
+ pthread_atfork(NULL, NULL, wd_comp_clear_status);
+
flag = wd_alg_try_init(&wd_comp_setting.status);
if (!flag)
return 0;
diff --git a/wd_dh.c b/wd_dh.c
index 74dbca0..7a96253 100644
--- a/wd_dh.c
+++ b/wd_dh.c
@@ -74,12 +74,19 @@ void wd_dh_set_driver(struct wd_dh_driver *drv)
wd_dh_setting.driver = drv;
}
+static void wd_dh_clear_status()
+{
+ wd_alg_clear_init(&wd_dh_setting.status);
+}
+
int wd_dh_init(struct wd_ctx_config *config, struct wd_sched *sched)
{
void *priv;
bool flag;
int ret;
+ pthread_atfork(NULL, NULL, wd_dh_clear_status);
+
flag = wd_alg_try_init(&wd_dh_setting.status);
if (!flag)
return 0;
diff --git a/wd_digest.c b/wd_digest.c
index ceecb6a..04ac142 100644
--- a/wd_digest.c
+++ b/wd_digest.c
@@ -183,12 +183,19 @@ void wd_digest_free_sess(handle_t h_sess)
free(sess);
}
+static void wd_digest_clear_status()
+{
+ wd_alg_clear_init(&wd_digest_setting.status);
+}
+
int wd_digest_init(struct wd_ctx_config *config, struct wd_sched *sched)
{
void *priv;
bool flag;
int ret;
+ pthread_atfork(NULL, NULL, wd_digest_clear_status);
+
flag = wd_alg_try_init(&wd_digest_setting.status);
if (!flag)
return 0;
diff --git a/wd_ecc.c b/wd_ecc.c
index 7fd632e..7b5654a 100644
--- a/wd_ecc.c
+++ b/wd_ecc.c
@@ -130,12 +130,19 @@ void wd_ecc_set_driver(struct wd_ecc_driver *drv)
wd_ecc_setting.driver = drv;
}
+static void wd_ecc_clear_status()
+{
+ wd_alg_clear_init(&wd_ecc_setting.status);
+}
+
int wd_ecc_init(struct wd_ctx_config *config, struct wd_sched *sched)
{
void *priv;
bool flag;
int ret;
+ pthread_atfork(NULL, NULL, wd_ecc_clear_status);
+
flag = wd_alg_try_init(&wd_ecc_setting.status);
if (!flag)
return 0;
diff --git a/wd_rsa.c b/wd_rsa.c
index a3b856a..288b86f 100644
--- a/wd_rsa.c
+++ b/wd_rsa.c
@@ -115,12 +115,19 @@ void wd_rsa_set_driver(struct wd_rsa_driver *drv)
wd_rsa_setting.driver = drv;
}
+static void wd_rsa_clear_status()
+{
+ wd_alg_clear_init(&wd_rsa_setting.status);
+}
+
int wd_rsa_init(struct wd_ctx_config *config, struct wd_sched *sched)
{
void *priv;
bool flag;
int ret;
+ pthread_atfork(NULL, NULL, wd_rsa_clear_status);
+
flag = wd_alg_try_init(&wd_rsa_setting.status);
if (!flag)
return 0;
--
2.24.0