1
0
mirror of https://github.com/apache/httpd.git synced 2025-08-08 15:02:10 +03:00

The pool and db object to be used should be created before trying to acquire a driver handle.

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1432892 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Daniel Gruno
2013-01-14 12:04:38 +00:00
parent 05bcfb46bb
commit 234523fdca

View File

@@ -757,15 +757,16 @@ AP_LUA_DECLARE(int) lua_db_acquire(lua_State *L)
}
apr_pool_tag(pool, "lua_dbd_pool");
apr_dbd_init(pool);
rc = apr_dbd_get_driver(r->server->process->pool, type, &db->driver);
dbdhandle = apr_pcalloc(pool, sizeof(ap_dbd_t));
rc = apr_dbd_get_driver(pool, type, &dbdhandle->driver);
if (rc == APR_SUCCESS) {
luaL_checktype(L, 3, LUA_TSTRING);
arguments = lua_tostring(L, 3);
lua_settop(L, 0);
if (strlen(arguments)) {
rc = apr_dbd_open_ex(db->driver, r->server->process->pool,
arguments, &db->handle, &error);
rc = apr_dbd_open_ex(dbdhandle->driver, pool,
arguments, &dbdhandle->handle, &error);
if (rc == APR_SUCCESS) {
db = lua_push_db_handle(L, r, LUA_DBTYPE_APR_DBD, pool);
db->driver = dbdhandle->driver;
@@ -787,6 +788,7 @@ AP_LUA_DECLARE(int) lua_db_acquire(lua_State *L)
lua_pushnil(L);
lua_pushliteral(L,
"No database connection string was specified.");
apr_pool_destroy(pool);
return (2);
}
else {
@@ -809,6 +811,7 @@ AP_LUA_DECLARE(int) lua_db_acquire(lua_State *L)
"mod_lua not compatible with APR in get_driver");
}
lua_pushinteger(L, rc);
apr_pool_destroy(pool);
return 3;
}
}