Skip to content

Commit

Permalink
QATAPP-25872: Add return value QZ_DUPLICATE for qzSetupSession
Browse files Browse the repository at this point in the history
if *sess includes an existing HW session or SW session,
then the QZ_DUPLTCATE will be returned without modifying the existing session

Change-Id: If6faa4d7be793bd3ca3f132af4cc6d67fa6b2651
Signed-off-by: Chengfei Zhu <[email protected]>
  • Loading branch information
cfzhu authored and XingHongChenIntel committed Nov 3, 2022
1 parent 8996cca commit a073390
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/qatzip.c
Original file line number Diff line number Diff line change
Expand Up @@ -1049,6 +1049,8 @@ int qzSetupSession(QzSession_T *sess, QzSessionParams_T *params)
sess->hw_session_stat = QZ_NOSW_LOW_MEM;
return QZ_NOSW_LOW_MEM;
}
} else {
return QZ_DUPLICATE;
}

qz_sess = (QzSess_T *)sess->internal;
Expand Down Expand Up @@ -1090,6 +1092,8 @@ int qzSetupSessionDeflate(QzSession_T *sess, QzSessionParamsDeflate_T *params)
sess->hw_session_stat = QZ_NOSW_LOW_MEM;
return QZ_NOSW_LOW_MEM;
}
} else {
return QZ_DUPLICATE;
}

qz_sess = (QzSess_T *)sess->internal;
Expand Down Expand Up @@ -1132,6 +1136,8 @@ int qzSetupSessionLZ4(QzSession_T *sess, QzSessionParamsLZ4_T *params)
sess->hw_session_stat = QZ_NOSW_LOW_MEM;
return QZ_NOSW_LOW_MEM;
}
} else {
return QZ_DUPLICATE;
}

qz_sess = (QzSess_T *)sess->internal;
Expand Down Expand Up @@ -1173,6 +1179,8 @@ int qzSetupSessionLZ4S(QzSession_T *sess, QzSessionParamsLZ4S_T *params)
sess->hw_session_stat = QZ_NOSW_LOW_MEM;
return QZ_NOSW_LOW_MEM;
}
} else {
return QZ_DUPLICATE;
}

qz_sess = (QzSess_T *)sess->internal;
Expand Down
2 changes: 2 additions & 0 deletions test/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -3137,6 +3137,8 @@ int qzDecompressForceSW(void)
consume = hdr->extra.qz_e.src_sz;
produce = hdr->extra.qz_e.dest_sz;

qzTeardownSession(&sess);

/*Scenario1: produce > DEST_SZ(params.hw_buff_sz)*/
/*set minimum hw size 2K*/
params.hw_buff_sz = 2 * 1024;
Expand Down

0 comments on commit a073390

Please sign in to comment.