diff options
author | unknown <monty@narttu.mysql.fi> | 2003-03-10 12:48:43 +0200 |
---|---|---|
committer | unknown <monty@narttu.mysql.fi> | 2003-03-10 12:48:43 +0200 |
commit | 012ffb5d505cc563ae980bd8cbee9b668f517cac (patch) | |
tree | 8651694def257832c6e225eead2eec4c5a7c9aeb /libmysql | |
parent | 66e8db8241bfcad048d08fa1a24532fae8ee5f0a (diff) | |
parent | 73c2d4ad498890c2ba2cfa9a2c20fae4d37b1859 (diff) | |
download | mariadb-git-012ffb5d505cc563ae980bd8cbee9b668f517cac.tar.gz |
Merge with 3.23 to get fixes for --user and BACKUP TABLE
BitKeeper/etc/ignore:
auto-union
BitKeeper/deleted/.del-delete.result:
Delete: mysql-test/r/delete.result
BitKeeper/deleted/.del-stamp-h.in~4a5d6676232516c5:
Auto merged
client/mysqlbinlog.cc:
Auto merged
include/my_sys.h:
Auto merged
libmysql/libmysql.c:
Auto merged
mysql-test/t/delete.test:
Auto merged
mysql-test/t/join.test:
Auto merged
mysql-test/t/type_datetime.test:
Auto merged
mysys/my_copy.c:
Auto merged
sql/field.h:
Auto merged
sql/opt_range.cc:
Auto merged
sql/share/polish/errmsg.txt:
Auto merged
sql/sql_rename.cc:
Auto merged
sql/sql_select.cc:
Auto merged
mysql-test/mysql-test-run.sh:
merge with 3.23.56
mysql-test/r/backup.result:
merge (needs to be updated)
mysql-test/r/join.result:
merge (needs to be updated)
mysql-test/r/type_datetime.result:
merge (needs to be updated)
mysql-test/t/backup.test:
merge with 3.23
scripts/mysqld_safe.sh:
Only use first --user option
sql/ha_myisam.cc:
Don't let BACKUP TABLE overwrite old files
sql/log_event.h:
merge
sql/mysql_priv.h:
merge
sql/mysqld.cc:
Use first --user option
sql/slave.cc:
use local version
sql/sql_repl.h:
use local version
Diffstat (limited to 'libmysql')
-rw-r--r-- | libmysql/libmysql.c | 66 |
1 files changed, 36 insertions, 30 deletions
diff --git a/libmysql/libmysql.c b/libmysql/libmysql.c index 04d2d9d12e4..af74182eb22 100644 --- a/libmysql/libmysql.c +++ b/libmysql/libmysql.c @@ -170,9 +170,10 @@ int my_connect(my_socket s, const struct sockaddr *name, uint namelen, struct timeval tv; time_t start_time, now_time; - /* If they passed us a timeout of zero, we should behave - * exactly like the normal connect() call does. - */ + /* + If they passed us a timeout of zero, we should behave + exactly like the normal connect() call does. + */ if (timeout == 0) return connect(s, (struct sockaddr*) name, namelen); @@ -193,30 +194,31 @@ int my_connect(my_socket s, const struct sockaddr *name, uint namelen, if (res == 0) /* Connected quickly! */ return(0); - /* Otherwise, our connection is "in progress." We can use - * the select() call to wait up to a specified period of time - * for the connection to suceed. If select() returns 0 - * (after waiting howevermany seconds), our socket never became - * writable (host is probably unreachable.) Otherwise, if - * select() returns 1, then one of two conditions exist: - * - * 1. An error occured. We use getsockopt() to check for this. - * 2. The connection was set up sucessfully: getsockopt() will - * return 0 as an error. - * - * Thanks goes to Andrew Gierth <andrew@erlenstar.demon.co.uk> - * who posted this method of timing out a connect() in - * comp.unix.programmer on August 15th, 1997. - */ + /* + Otherwise, our connection is "in progress." We can use + the select() call to wait up to a specified period of time + for the connection to suceed. If select() returns 0 + (after waiting howevermany seconds), our socket never became + writable (host is probably unreachable.) Otherwise, if + select() returns 1, then one of two conditions exist: + + 1. An error occured. We use getsockopt() to check for this. + 2. The connection was set up sucessfully: getsockopt() will + return 0 as an error. + + Thanks goes to Andrew Gierth <andrew@erlenstar.demon.co.uk> + who posted this method of timing out a connect() in + comp.unix.programmer on August 15th, 1997. + */ FD_ZERO(&sfds); FD_SET(s, &sfds); /* - * select could be interrupted by a signal, and if it is, - * the timeout should be adjusted and the select restarted - * to work around OSes that don't restart select and - * implementations of select that don't adjust tv upon - * failure to reflect the time remaining + select could be interrupted by a signal, and if it is, + the timeout should be adjusted and the select restarted + to work around OSes that don't restart select and + implementations of select that don't adjust tv upon + failure to reflect the time remaining */ start_time = time(NULL); for (;;) @@ -224,22 +226,25 @@ int my_connect(my_socket s, const struct sockaddr *name, uint namelen, tv.tv_sec = (long) timeout; tv.tv_usec = 0; #if defined(HPUX10) && defined(THREAD) - if ((res = select(s+1, NULL, (int*) &sfds, NULL, &tv)) >= 0) + if ((res = select(s+1, NULL, (int*) &sfds, NULL, &tv)) > 0) break; #else - if ((res = select(s+1, NULL, &sfds, NULL, &tv)) >= 0) + if ((res = select(s+1, NULL, &sfds, NULL, &tv)) > 0) break; #endif + if (res == 0) /* timeout */ + return -1; now_time=time(NULL); timeout-= (uint) (now_time - start_time); if (errno != EINTR || (int) timeout <= 0) return -1; } - /* select() returned something more interesting than zero, let's - * see if we have any errors. If the next two statements pass, - * we've got an open socket! - */ + /* + select() returned something more interesting than zero, let's + see if we have any errors. If the next two statements pass, + we've got an open socket! + */ s_err=0; if (getsockopt(s, SOL_SOCKET, SO_ERROR, (char*) &s_err, &s_err_size) != 0) @@ -250,7 +255,8 @@ int my_connect(my_socket s, const struct sockaddr *name, uint namelen, errno = s_err; return(-1); /* but return an error... */ } - return(0); /* It's all good! */ + return (0); /* ok */ + #endif } |