mirror of
https://github.com/MariaDB/server.git
synced 2025-08-08 11:22:35 +03:00
Bug #29469: Client dies if a query is issued after hitting Ctrl + C
The Ctrl-C handler in mysql closes the console while ReadConsole() waits for console input. But the main thread was detecting that ReadConsole() haven't read anything and was processing as if there're data in the buffer. Fixed to handle correctly this error condition. No test case added as the test relies on Ctrl-C sent to the client from its console.
This commit is contained in:
@@ -1086,6 +1086,11 @@ static int read_and_execute(bool interactive)
|
|||||||
something else is still in console input buffer
|
something else is still in console input buffer
|
||||||
*/
|
*/
|
||||||
} while (tmpbuf.alloced_length() <= clen);
|
} while (tmpbuf.alloced_length() <= clen);
|
||||||
|
/*
|
||||||
|
An empty line is returned from my_cgets when there's error reading :
|
||||||
|
Ctrl-c for example
|
||||||
|
*/
|
||||||
|
if (line)
|
||||||
line= buffer.c_ptr();
|
line= buffer.c_ptr();
|
||||||
#else /* OS2 */
|
#else /* OS2 */
|
||||||
buffer.length(0);
|
buffer.length(0);
|
||||||
|
@@ -184,16 +184,19 @@ char* my_cgets(char *buffer, unsigned long clen, unsigned long* plen)
|
|||||||
}
|
}
|
||||||
while (GetLastError() == ERROR_NOT_ENOUGH_MEMORY);
|
while (GetLastError() == ERROR_NOT_ENOUGH_MEMORY);
|
||||||
|
|
||||||
|
/* We go here on error reading the string (Ctrl-C for example) */
|
||||||
|
if (!*plen)
|
||||||
|
result= NULL; /* purecov: inspected */
|
||||||
|
|
||||||
if (result != NULL)
|
if (result != NULL)
|
||||||
{
|
{
|
||||||
if (buffer[*plen - 2] == '\r')
|
if (*plen > 1 && buffer[*plen - 2] == '\r')
|
||||||
{
|
{
|
||||||
*plen= *plen - 2;
|
*plen= *plen - 2;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (buffer[*plen - 1] == '\r')
|
if (*plen > 0 && buffer[*plen - 1] == '\r')
|
||||||
{
|
{
|
||||||
char tmp[3];
|
char tmp[3];
|
||||||
int tmplen= sizeof(tmp);
|
int tmplen= sizeof(tmp);
|
||||||
|
Reference in New Issue
Block a user