Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion ext/mysqli/mysqli_nonapi.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ void mysqli_common_connect(INTERNAL_FUNCTION_PARAMETERS, bool is_real_connect, b
bool port_is_null = 1;
zend_string *hash_key = NULL;
bool new_connection = false;
bool from_pool = false;
zend_resource *le;
mysqli_plist_entry *plist = NULL;
bool self_alloced = 0;
Expand Down Expand Up @@ -174,6 +175,7 @@ void mysqli_common_connect(INTERNAL_FUNCTION_PARAMETERS, bool is_real_connect, b
#endif
mysqlnd_restart_psession(mysql->mysql);
MyG(num_active_persistent)++;
from_pool = true;

/* clear error */
php_mysqli_set_error(mysql_errno(mysql->mysql), (char *) mysql_error(mysql->mysql));
Expand Down Expand Up @@ -281,7 +283,7 @@ void mysqli_common_connect(INTERNAL_FUNCTION_PARAMETERS, bool is_real_connect, b
mysqli_resource->status = MYSQLI_STATUS_VALID;

/* store persistent connection */
if (persistent && (new_connection || is_real_connect)) {
if (persistent && (new_connection || is_real_connect) && !from_pool) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there really no way to simplify this? This is getting difficult to read already. Also, it would be nice if you could add a test for this.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree, what do you think about just removing the || is_real_connect (and discarding the from_pool flag)? That was my original plan, but after some discussion on 22631 I changed that. I'm not sure though that there is a case where that || is_real_connect is needed: either new_connection should be set (we seem to try and close any existing connections), or we should have gotten a cached one in which case we already incremented the counter.

MyG(num_active_persistent)++;
}

Expand Down
Loading