Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 4f9d95b

Browse filesBrowse files
committed
Merge branch 'jensch-master' into MySQLdb-1.2
2 parents 4e6c7c0 + 417088a commit 4f9d95b
Copy full SHA for 4f9d95b

File tree

Expand file treeCollapse file tree

1 file changed

+30
-2
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+30
-2
lines changed

‎_mysql.c

Copy file name to clipboardExpand all lines: _mysql.c
+30-2Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,12 @@ static int _mysql_server_init_done = 0;
118118
#define HAVE_OPENSSL 1
119119
#endif
120120

121+
/* According to https://dev.mysql.com/doc/refman/5.1/en/mysql-options.html
122+
The MYSQL_OPT_READ_TIMEOUT apear in the version 5.1.12 */
123+
#if MYSQL_VERSION_ID > 50112
124+
#define HAVE_MYSQL_OPT_READ_TIMEOUT 1
125+
#endif
126+
121127
PyObject *
122128
_mysql_Exception(_mysql_ConnectionObject *c)
123129
{
@@ -557,8 +563,14 @@ _mysql_ConnectionObject_Initialize(
557563
"read_default_file", "read_default_group",
558564
"client_flag", "ssl",
559565
"local_infile",
566+
#ifdef HAVE_MYSQL_OPT_READ_TIMEOUT
567+
"read_timeout",
568+
#endif
560569
NULL } ;
561570
int connect_timeout = 0;
571+
#ifdef HAVE_MYSQL_OPT_READ_TIMEOUT
572+
int read_timeout = 0;
573+
#endif
562574
int compress = -1, named_pipe = -1, local_infile = -1;
563575
char *init_command=NULL,
564576
*read_default_file=NULL,
@@ -567,7 +579,13 @@ _mysql_ConnectionObject_Initialize(
567579
self->converter = NULL;
568580
self->open = 0;
569581
check_server_init(-1);
570-
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|ssssisOiiisssiOi:connect",
582+
583+
if (!PyArg_ParseTupleAndKeywords(args, kwargs,
584+
#ifdef HAVE_MYSQL_OPT_READ_TIMEOUT
585+
"|ssssisOiiisssiOii:connect",
586+
#else
587+
"|ssssisOiiisssiOi:connect",
588+
#endif
571589
kwlist,
572590
&host, &user, &passwd, &db,
573591
&port, &unix_socket, &conv,
@@ -576,8 +594,11 @@ _mysql_ConnectionObject_Initialize(
576594
&init_command, &read_default_file,
577595
&read_default_group,
578596
&client_flag, &ssl,
579-
&local_infile /* DO NOT PATCH FOR RECONNECT, IDIOTS
597+
&local_infile, /* DO NOT PATCH FOR RECONNECT, IDIOTS
580598
IF YOU DO THIS, I WILL NOT SUPPORT YOUR PACKAGES. */
599+
#ifdef HAVE_MYSQL_OPT_READ_TIMEOUT
600+
&read_timeout
601+
#endif
581602
))
582603
return -1;
583604

@@ -613,6 +634,13 @@ _mysql_ConnectionObject_Initialize(
613634
mysql_options(&(self->connection), MYSQL_OPT_CONNECT_TIMEOUT,
614635
(char *)&timeout);
615636
}
637+
#ifdef HAVE_MYSQL_OPT_READ_TIMEOUT
638+
if (read_timeout) {
639+
unsigned int timeout = read_timeout;
640+
mysql_options(&(self->connection), MYSQL_OPT_READ_TIMEOUT,
641+
(char *)&timeout);
642+
}
643+
#endif
616644
if (compress != -1) {
617645
mysql_options(&(self->connection), MYSQL_OPT_COMPRESS, 0);
618646
client_flag |= CLIENT_COMPRESS;

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.