mysql: Don't release the connection if transactions are still using it
authorTobias Brunner <tobias@strongswan.org>
Wed, 3 Oct 2018 07:34:02 +0000 (09:34 +0200)
committerTobias Brunner <tobias@strongswan.org>
Fri, 26 Oct 2018 09:18:43 +0000 (11:18 +0200)
Fixes #2779.

src/libstrongswan/plugins/mysql/mysql_database.c

index d7e35d9..90f8185 100644 (file)
@@ -131,9 +131,13 @@ typedef struct {
  */
 static void conn_release(private_mysql_database_t *this, conn_t *conn)
 {
-       this->mutex->lock(this->mutex);
-       conn->in_use = FALSE;
-       this->mutex->unlock(this->mutex);
+       /* do not release the connection while transactions are using it */
+       if (!this->transaction->get(this->transaction))
+       {
+               this->mutex->lock(this->mutex);
+               conn->in_use = FALSE;
+               this->mutex->unlock(this->mutex);
+       }
 }
 
 /**