Skip to content

Commit

Permalink
remove if validation failed
Browse files Browse the repository at this point in the history
  • Loading branch information
chronolaw committed Jul 4, 2023
1 parent 0a02e19 commit cdfb0d7
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion src/ngx_lua_resty_lmdb_module.c
Original file line number Diff line number Diff line change
Expand Up @@ -613,6 +613,8 @@ ngx_lua_resty_lmdb_validate(ngx_cycle_t *cycle,
mdb_strerror(rc));
}

failed:

mdb_txn_abort(txn);
return NGX_ERROR;
}
Expand Down Expand Up @@ -701,9 +703,26 @@ static ngx_int_t ngx_lua_resty_lmdb_init(ngx_cycle_t *cycle)
return NGX_ERROR;
}

/* check lmdb validation tag */

if (ngx_lua_resty_lmdb_validate(cycle, lcf) != NGX_OK) {
ngx_lua_resty_lmdb_close_file(cycle, lcf);
return NGX_ERROR;

/* remove lmdb files to clear data */
if (ngx_lua_resty_lmdb_remove_files(cycle, lcf->env_path) != NGX_OK) {
return NGX_ERROR;
}

/* open lmdb file again */
if (ngx_lua_resty_lmdb_open_file(cycle, lcf, 1) != NGX_OK) {
return NGX_ERROR;
}

/* write tag into lmdb */
if (ngx_lua_resty_lmdb_write_tag(cycle, lcf) != NGX_OK) {
ngx_lua_resty_lmdb_close_file(cycle, lcf);
return NGX_ERROR;
}
}

if (ngx_lua_resty_lmdb_close_file(cycle, lcf) != NGX_OK) {
Expand Down

0 comments on commit cdfb0d7

Please sign in to comment.