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 14, 2023
1 parent 8c5ec3d commit c8bfa56
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 @@ -441,6 +441,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 @@ -529,9 +531,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 c8bfa56

Please sign in to comment.