Skip to content
This repository was archived by the owner on Mar 1, 2026. It is now read-only.

Commit 23aee32

Browse files
hermanleefacebook-github-bot
authored andcommitted
Skip checking vio state during COM_QUIT
Summary: Skip checking the ERR during COM_QUIT to work around a library clean-up issue on debug builds. Differential Revision: D58419387 fbshipit-source-id: 1c94051
1 parent 6100181 commit 23aee32

4 files changed

Lines changed: 20 additions & 1 deletion

File tree

‎include/violite.h‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,7 @@ int vio_io_wait(MYSQL_VIO vio, enum enum_vio_io_event event, timeout_t timeout);
197197
bool vio_is_connected(MYSQL_VIO vio);
198198
#ifndef NDEBUG
199199
ssize_t vio_pending(MYSQL_VIO vio);
200+
void vio_set_quit(MYSQL_VIO vio);
200201
#endif
201202
/* Set timeout for a network operation. */
202203
int vio_timeout(MYSQL_VIO vio, uint which, timeout_t timeout);
@@ -456,6 +457,10 @@ struct Vio {
456457
/* Indicates whether socket or SSL based communication is blocking or not. */
457458
bool is_blocking_flag = {true};
458459

460+
#ifndef NDEBUG
461+
bool is_quit = {false};
462+
#endif /* NDEBUG */
463+
459464
private:
460465
friend Vio *internal_vio_create(uint flags);
461466
friend void internal_vio_delete(Vio *vio);

‎sql-common/client.cc‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1437,6 +1437,10 @@ bool cli_advanced_command(MYSQL *mysql, enum enum_server_command command,
14371437
assert(mysql->net.vio != nullptr);
14381438
}
14391439

1440+
#ifndef NDEBUG
1441+
if (command == COM_QUIT) vio_set_quit(mysql->net.vio);
1442+
#endif /* NDEBUG */
1443+
14401444
/* turn off non blocking operations */
14411445
if (!vio_is_blocking(mysql->net.vio))
14421446
vio_set_blocking_flag(mysql->net.vio, true);
@@ -1615,6 +1619,11 @@ net_async_status cli_advanced_command_nonblocking(
16151619
set_mysql_error(mysql, CR_SERVER_GONE_ERROR, unknown_sqlstate);
16161620
goto end;
16171621
}
1622+
1623+
#ifndef NDEBUG
1624+
if (command == COM_QUIT) vio_set_quit(mysql->net.vio);
1625+
#endif /* NDEBUG */
1626+
16181627
/**
16191628
When non blocking API execution is pending and did not complete then
16201629
it can result in async context to be null. In such case if user executes

‎vio/viosocket.cc‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1234,6 +1234,11 @@ ssize_t vio_pending(Vio *vio) {
12341234
return (ssize_t)bytes;
12351235
}
12361236

1237+
/**
1238+
Set when sending the quit packet and skip certain state checks
1239+
*/
1240+
void vio_set_quit(Vio *vio) { vio->is_quit = true; }
1241+
12371242
#endif
12381243

12391244
/**

‎vio/viossl.cc‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,7 @@ size_t vio_ssl_write(Vio *vio, const uchar *buf, size_t size) {
323323
SSL_write() returns an error from the error queue, when SSL_write() failed
324324
because it would block.
325325
*/
326-
assert(ERR_peek_error() == 0);
326+
assert(ERR_peek_error() == 0 || vio->is_quit);
327327

328328
ret = SSL_write(ssl, buf, (int)size);
329329

0 commit comments

Comments
 (0)