Merge lp:~sergei.glushchenko/percona-server/ST30462-bug925343-5.6 into lp:percona-server/5.6

Proposed by Sergei Glushchenko on 2013-04-03
Status: Merged
Approved by: Stewart Smith on 2013-04-04
Approved revision: no longer in the source branch.
Merged at revision: 331
Proposed branch: lp:~sergei.glushchenko/percona-server/ST30462-bug925343-5.6
Merge into: lp:percona-server/5.6
Diff against target: 66 lines (+7/-16)
1 file modified
Percona-Server/client/mysql.cc (+7/-16)
To merge this branch: bzr merge lp:~sergei.glushchenko/percona-server/ST30462-bug925343-5.6
Reviewer Review Type Date Requested Status
Stewart Smith (community) 2013-04-03 Approve on 2013-04-04
Review via email: mp+156862@code.launchpad.net

Description of the change

Bug 925343: mysql client aborts connection on terminal resize.
Fix for upstream bug #26780 "patch to add auto vertical output
option to the cli" introduced SIGWINCH handling by mysql cli.
This leads to EINTR to be returned by read call on socket.
On most systems there is a possibility for read call
to be automatically restarted if SA_RESTART flag is set for
the signal. Hovewer this is not the case, as read timeout on
socket has been set. Linux manual page for signal(7) tells that
there is no chance for read to be restarted if timeout has
been set on socket. It doesn't matter whether SA_RESTART has
been used for signal or not.
So the only portable solution would be to block signal for the
time when client communicates with server. This however would
require a lot of carefull code reading to spot all the point
of such communication in source code and wrap them with
block/unblock signal.
That is why option to completely disable SIGWINCH handling
has been choosen. The only purpose of SIGWINCH handler was to
determine new width of terminal window. The only place where
this width is used is to print output from the server.
Handling of SIGWINCH has been replaced with explicit invocation
of ioctl to get terminal width just before print of result set
is started.

http://jenkins.percona.com/view/PS%205.6/job/percona-server-5.6-param/74/

To post a comment you must log in.
Stewart Smith (stewart) :
review: Approve
326. By Sergei Glushchenko on 2013-04-04

Merge fix for 925343 from 5.5 series

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'Percona-Server/client/mysql.cc'
2--- Percona-Server/client/mysql.cc 2013-03-05 12:46:43 +0000
3+++ Percona-Server/client/mysql.cc 2013-04-04 09:42:24 +0000
4@@ -202,7 +202,6 @@
5 static uint prompt_counter;
6 static char delimiter[16]= DEFAULT_DELIMITER;
7 static uint delimiter_length= 1;
8-unsigned short terminal_width= 80;
9
10 #ifdef HAVE_SMEM
11 static char *shared_memory_base_name=0;
12@@ -1128,9 +1127,7 @@
13 static void nice_time(double sec,char *buff,bool part_second);
14 extern "C" sig_handler mysql_end(int sig);
15 extern "C" sig_handler handle_kill_signal(int sig);
16-#if defined(HAVE_TERMIOS_H) && defined(GWINSZ_IN_SYS_IOCTL)
17-static sig_handler window_resize(int sig);
18-#endif
19+static unsigned short get_terminal_width();
20
21 const char DELIMITER_NAME[]= "delimiter";
22 const uint DELIMITER_NAME_LEN= sizeof(DELIMITER_NAME) - 1;
23@@ -1305,13 +1302,6 @@
24 #endif
25
26
27-#if defined(HAVE_TERMIOS_H) && defined(GWINSZ_IN_SYS_IOCTL)
28- /* Readline will call this if it installs a handler */
29- signal(SIGWINCH, window_resize);
30- /* call the SIGWINCH handler to get the default term width */
31- window_resize(0);
32-#endif
33-
34 put_info("Welcome to the MySQL monitor. Commands end with ; or \\g.",
35 INFO_INFO);
36 sprintf((char*) glob_buffer.ptr(),
37@@ -1515,15 +1505,16 @@
38 }
39
40
41+unsigned short get_terminal_width()
42+{
43 #if defined(HAVE_TERMIOS_H) && defined(GWINSZ_IN_SYS_IOCTL)
44-sig_handler window_resize(int sig)
45-{
46 struct winsize window_size;
47
48 if (ioctl(fileno(stdin), TIOCGWINSZ, &window_size) == 0)
49- terminal_width= window_size.ws_col;
50+ return window_size.ws_col;
51+#endif
52+ return 80;
53 }
54-#endif
55
56 static struct my_option my_long_options[] =
57 {
58@@ -3435,7 +3426,7 @@
59 print_table_data_html(result);
60 else if (opt_xml)
61 print_table_data_xml(result);
62- else if (vertical || (auto_vertical_output && (terminal_width < get_result_width(result))))
63+ else if (vertical || (auto_vertical_output && (get_terminal_width() < get_result_width(result))))
64 print_table_data_vertically(result);
65 else if (opt_silent && verbose <= 2 && !output_tables)
66 print_tab_data(result);

Subscribers

People subscribed via source and target branches