Bug #10397 Connection timeout is ignored on Windows
| Submitted: | 5 May 2005 19:27 | Modified: | 7 May 2005 19:55 |
|---|---|---|---|
| Reporter: | Rob Laveaux | Email Updates: | |
| Status: | Can't repeat | Impact on me: | |
| Category: | MySQL Server | Severity: | S3 (Non-critical) |
| Version: | 4.1.10 | OS: | Windows (Windows XP) |
| Assigned to: | CPU Architecture: | Any |
[5 May 2005 19:27]
Rob Laveaux
[7 May 2005 19:55]
MySQL Verification Team
In the Manual: "connect-timeout Connect timeout in seconds. On Linux this timeout is also used for waiting for the first answer from the server." I got the below output using the code at the bottom: C:\temp>bug10397 Error: Can't connect to MySQL server on '192.168.1.123' (10061) Time: (0.02 sec) #include <stdio.h> #include <string.h> #include <my_global.h> #include <m_ctype.h> #include <m_string.h> #include <mysql.h> static ulong start_timer(void) { return clock(); } static void nice_time(double sec,char *buff,bool part_second) { ulong tmp; if (sec >= 3600.0*24) { tmp=(ulong) floor(sec/(3600.0*24)); sec-=3600.0*24*tmp; buff=int10_to_str((long) tmp, buff, 10); buff=strmov(buff,tmp > 1 ? " days " : " day "); } if (sec >= 3600.0) { tmp=(ulong) floor(sec/3600.0); sec-=3600.0*tmp; buff=int10_to_str((long) tmp, buff, 10); buff=strmov(buff,tmp > 1 ? " hours " : " hour "); } if (sec >= 60.0) { tmp=(ulong) floor(sec/60.0); sec-=60.0*tmp; buff=int10_to_str((long) tmp, buff, 10); buff=strmov(buff," min "); } if (part_second) sprintf(buff,"%.2f sec",sec); else sprintf(buff,"%d sec",(int) sec); } static void end_timer(ulong start_time,char *buff) { nice_time((double) (start_timer() - start_time) / CLOCKS_PER_SEC,buff,1); } static void mysql_end_timer(ulong start_time,char *buff) { buff[0]=' '; buff[1]='('; end_timer(start_time,buff+2); strmov(strend(buff),")"); } char buff[160],time_buff[32]; ulong timer; void main() { MYSQL mysql; unsigned int timeout = 5; mysql_init(&mysql); mysql_options(&mysql,MYSQL_OPT_CONNECT_TIMEOUT, (char*) &timeout); timer=start_timer(); if (!mysql_real_connect(&mysql,"192.168.1.123", "scott", "tiger", "testdb",0, NULL, 0 )) { fprintf(stderr, "Error: %s\n",mysql_error(&mysql)); } mysql_end_timer(timer,time_buff); printf("Time: %s\n",time_buff); mysql_close(&mysql); }
[8 Jul 2011 12:03]
Kristian Nielsen
Ehem... Windows error 10061 is "connection refused. Test program would work better if there was actually a server running at the other end ... The reporter is correct. The code in sql-common/client.c has an #ifdef for Windows that ignores the connection timeout (up to and including 5.5). This is fixed in 5.6.
Portions of this website are copyright © 2001, 2002 The PHP Group
Page generated in 0.040 sec. using MySQL 8.4.7-u6-cloud
Timestamp references displayed by the system are UTC.
Content reproduced on this site is the property of the
respective copyright holders.
It is not reviewed in advance
by Oracle and does not necessarily represent the opinion of
Oracle or any other party.