mirror of
https://git.wownero.com/wownero/wownero-puddle.git
synced 2024-08-15 01:03:20 +00:00
wait on DB resize whilst client(s) are being read
This catches a missed case of the trusted thread (i.e. downstream client) reading.
This commit is contained in:
parent
ff323609b9
commit
08fa5c12fb
1 changed files with 7 additions and 0 deletions
|
@ -470,6 +470,9 @@ database_resize(void)
|
|||
log_warn("Cannot cannot acquire lock");
|
||||
return rc;
|
||||
}
|
||||
pthread_mutex_lock(&mutex_clients);
|
||||
while (clients_reading)
|
||||
pthread_cond_wait(&cond_clients, &mutex_clients);
|
||||
if ((rc = mdb_env_set_mapsize(env, DB_INIT_SIZE)) != 0)
|
||||
{
|
||||
err = mdb_strerror(rc);
|
||||
|
@ -492,6 +495,9 @@ database_resize(void)
|
|||
log_warn("Cannot cannot acquire lock");
|
||||
return rc;
|
||||
}
|
||||
pthread_mutex_lock(&mutex_clients);
|
||||
while (clients_reading)
|
||||
pthread_cond_wait(&cond_clients, &mutex_clients);
|
||||
if ((rc = mdb_env_set_mapsize(env, ns)) != 0)
|
||||
{
|
||||
err = mdb_strerror(rc);
|
||||
|
@ -503,6 +509,7 @@ database_resize(void)
|
|||
}
|
||||
return 0;
|
||||
unlock:
|
||||
pthread_mutex_unlock(&mutex_clients);
|
||||
pthread_rwlock_unlock(&rwlock_tx);
|
||||
return rc;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue