mirror of
https://github.com/FirebirdSQL/firebird.git
synced 2025-01-24 10:03:03 +01:00
1. Make work with databases_mutex more consistent (lock\unlock it at the same scope of code).
2. Restore accidentally broken pause when attempt to brute-force login\pwd is detected
This commit is contained in:
parent
510c896971
commit
ac03047011
@ -677,6 +677,11 @@ ISC_STATUS GDS_ATTACH_DATABASE(ISC_STATUS* user_status,
|
|||||||
// Ccheck for correct credentials supplied
|
// Ccheck for correct credentials supplied
|
||||||
getUserInfo(userId, options);
|
getUserInfo(userId, options);
|
||||||
}
|
}
|
||||||
|
catch (const DelayFailedLogin& ex)
|
||||||
|
{
|
||||||
|
ex.sleep();
|
||||||
|
return ex.stuff_exception(user_status);
|
||||||
|
}
|
||||||
catch (const Firebird::Exception& e)
|
catch (const Firebird::Exception& e)
|
||||||
{
|
{
|
||||||
e.stuff_exception(user_status);
|
e.stuff_exception(user_status);
|
||||||
@ -707,6 +712,8 @@ ISC_STATUS GDS_ATTACH_DATABASE(ISC_STATUS* user_status,
|
|||||||
}
|
}
|
||||||
|
|
||||||
Database* dbb = NULL;
|
Database* dbb = NULL;
|
||||||
|
Firebird::MutexEnsureUnlock guardDatabases(databases_mutex);
|
||||||
|
guardDatabases.enter();
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@ -1214,7 +1221,7 @@ ISC_STATUS GDS_ATTACH_DATABASE(ISC_STATUS* user_status,
|
|||||||
|
|
||||||
// if there was an error, the status vector is all set
|
// if there was an error, the status vector is all set
|
||||||
|
|
||||||
databases_mutex->leave();
|
guardDatabases.leave();
|
||||||
|
|
||||||
if (options.dpb_sweep & isc_dpb_records)
|
if (options.dpb_sweep & isc_dpb_records)
|
||||||
{
|
{
|
||||||
@ -1260,18 +1267,12 @@ ISC_STATUS GDS_ATTACH_DATABASE(ISC_STATUS* user_status,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// databases_mutex->leave();
|
// guardDatabases.leave();
|
||||||
|
|
||||||
*handle = attachment;
|
*handle = attachment;
|
||||||
attachment->att_mutex.leave();
|
attachment->att_mutex.leave();
|
||||||
|
|
||||||
} // try
|
} // try
|
||||||
catch (const DelayFailedLogin& ex)
|
|
||||||
{
|
|
||||||
const ISC_STATUS s = unwindAttach(ex, user_status, tdbb, attachment, dbb);
|
|
||||||
ex.sleep();
|
|
||||||
return s;
|
|
||||||
}
|
|
||||||
catch (const Firebird::Exception& ex)
|
catch (const Firebird::Exception& ex)
|
||||||
{
|
{
|
||||||
return unwindAttach(ex, user_status, tdbb, attachment, dbb);
|
return unwindAttach(ex, user_status, tdbb, attachment, dbb);
|
||||||
@ -1657,6 +1658,11 @@ ISC_STATUS GDS_CREATE_DATABASE(ISC_STATUS* user_status,
|
|||||||
// Check for correct credentials supplied
|
// Check for correct credentials supplied
|
||||||
getUserInfo(userId, options);
|
getUserInfo(userId, options);
|
||||||
}
|
}
|
||||||
|
catch (const DelayFailedLogin& ex)
|
||||||
|
{
|
||||||
|
ex.sleep();
|
||||||
|
return ex.stuff_exception(user_status);
|
||||||
|
}
|
||||||
catch (const Firebird::Exception& e)
|
catch (const Firebird::Exception& e)
|
||||||
{
|
{
|
||||||
e.stuff_exception(user_status);
|
e.stuff_exception(user_status);
|
||||||
@ -1687,6 +1693,8 @@ ISC_STATUS GDS_CREATE_DATABASE(ISC_STATUS* user_status,
|
|||||||
}
|
}
|
||||||
|
|
||||||
Database* dbb = NULL;
|
Database* dbb = NULL;
|
||||||
|
Firebird::MutexEnsureUnlock guardDatabases(databases_mutex);
|
||||||
|
guardDatabases.enter();
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@ -1958,18 +1966,12 @@ ISC_STATUS GDS_CREATE_DATABASE(ISC_STATUS* user_status,
|
|||||||
|
|
||||||
dbb->dbb_backup_manager->dbCreating = false;
|
dbb->dbb_backup_manager->dbCreating = false;
|
||||||
|
|
||||||
databases_mutex->leave();
|
guardDatabases.leave();
|
||||||
|
|
||||||
*handle = attachment;
|
*handle = attachment;
|
||||||
attachment->att_mutex.leave();
|
attachment->att_mutex.leave();
|
||||||
|
|
||||||
} // try
|
} // try
|
||||||
catch (const DelayFailedLogin& ex)
|
|
||||||
{
|
|
||||||
const ISC_STATUS s = unwindAttach(ex, user_status, tdbb, attachment, dbb);
|
|
||||||
ex.sleep();
|
|
||||||
return s;
|
|
||||||
}
|
|
||||||
catch (const Firebird::Exception& ex)
|
catch (const Firebird::Exception& ex)
|
||||||
{
|
{
|
||||||
return unwindAttach(ex, user_status, tdbb, attachment, dbb);
|
return unwindAttach(ex, user_status, tdbb, attachment, dbb);
|
||||||
@ -4606,6 +4608,7 @@ static Database* init(thread_db* tdbb,
|
|||||||
* Functional description
|
* Functional description
|
||||||
* Initialize for database access. First call from both CREATE and
|
* Initialize for database access. First call from both CREATE and
|
||||||
* OPEN.
|
* OPEN.
|
||||||
|
* Upon entry mutex databases_mutex must be locked.
|
||||||
*
|
*
|
||||||
**************************************/
|
**************************************/
|
||||||
SET_TDBB(tdbb);
|
SET_TDBB(tdbb);
|
||||||
@ -4623,12 +4626,8 @@ static Database* init(thread_db* tdbb,
|
|||||||
|
|
||||||
engineStartup.init();
|
engineStartup.init();
|
||||||
|
|
||||||
databases_mutex->enter();
|
|
||||||
|
|
||||||
Database* dbb = NULL;
|
Database* dbb = NULL;
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
// Check to see if the database is already actively attached
|
// Check to see if the database is already actively attached
|
||||||
|
|
||||||
#ifdef SUPERSERVER
|
#ifdef SUPERSERVER
|
||||||
@ -4715,12 +4714,6 @@ static Database* init(thread_db* tdbb,
|
|||||||
}
|
}
|
||||||
|
|
||||||
INTL_init(tdbb);
|
INTL_init(tdbb);
|
||||||
}
|
|
||||||
catch (const Firebird::Exception&)
|
|
||||||
{
|
|
||||||
databases_mutex->leave();
|
|
||||||
throw;
|
|
||||||
}
|
|
||||||
|
|
||||||
return dbb;
|
return dbb;
|
||||||
}
|
}
|
||||||
@ -5800,8 +5793,6 @@ static ISC_STATUS unwindAttach(const Firebird::Exception& ex,
|
|||||||
Attachment* attachment,
|
Attachment* attachment,
|
||||||
Database* dbb)
|
Database* dbb)
|
||||||
{
|
{
|
||||||
try
|
|
||||||
{
|
|
||||||
ThreadStatusGuard temp_status(tdbb);
|
ThreadStatusGuard temp_status(tdbb);
|
||||||
|
|
||||||
dbb->dbb_flags &= ~DBB_being_opened;
|
dbb->dbb_flags &= ~DBB_being_opened;
|
||||||
@ -5818,13 +5809,6 @@ static ISC_STATUS unwindAttach(const Firebird::Exception& ex,
|
|||||||
shutdown_database(dbb, true);
|
shutdown_database(dbb, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
catch (const Firebird::Exception&)
|
|
||||||
{
|
|
||||||
// no-op
|
|
||||||
}
|
|
||||||
|
|
||||||
databases_mutex->leave();
|
|
||||||
|
|
||||||
Firebird::stuff_exception(userStatus, ex);
|
Firebird::stuff_exception(userStatus, ex);
|
||||||
return userStatus[1];
|
return userStatus[1];
|
||||||
|
Loading…
Reference in New Issue
Block a user