diff options
author | unknown <sasha@mysql.sashanet.com> | 2001-10-04 15:42:25 -0600 |
---|---|---|
committer | unknown <sasha@mysql.sashanet.com> | 2001-10-04 15:42:25 -0600 |
commit | 5ee900d38a1d20247823ab23a441cbb78ac9942a (patch) | |
tree | 52920ad20ad4c024921ea3c2bcf4c346c403290e /libmysqld | |
parent | 07ccd64e7425f3bd09f7de05200835583f206c4a (diff) | |
download | mariadb-git-5ee900d38a1d20247823ab23a441cbb78ac9942a.tar.gz |
changes to make things work in the max version
acinclude.m4:
automatically detect installation paths of OpenSSL instead of hard-coding
automatically enable --with-vio if --with-openssl is enabled
client/mysqltest.c:
fixes for embedded library
libmysqld/Makefile.am:
md5 is now in mysys
libmysqld/libmysqld.c:
added my_connect(), but now can be removed - will do in the next
changeset
mysql-test/include/have_bdb.inc:
disable query log so that result file will not have unneeded
show variables
mysql-test/include/have_gemini.inc:
disable query log so that result file will not have unneeded
show variables
mysql-test/include/have_innodb.inc:
disable query log so that result file will not have unneeded
show variables
mysql-test/include/have_openssl.inc:
disable query log so that result file will not have unneeded
show variables
mysql-test/include/have_openssl_1.inc:
disable query log so that result file will not have unneeded
show variables
mysql-test/include/have_openssl_2.inc:
disable query log so that result file will not have unneeded
show variables
mysql-test/r/bdb.result:
fix for new format
mysql-test/r/have_openssl.require:
ssl->openssl
mysql-test/r/innodb.result:
fix for query logging
Diffstat (limited to 'libmysqld')
-rw-r--r-- | libmysqld/Makefile.am | 4 | ||||
-rw-r--r-- | libmysqld/libmysqld.c | 101 |
2 files changed, 103 insertions, 2 deletions
diff --git a/libmysqld/Makefile.am b/libmysqld/Makefile.am index e39cebff04a..a95a9ba403e 100644 --- a/libmysqld/Makefile.am +++ b/libmysqld/Makefile.am @@ -47,7 +47,7 @@ sqlsources = convert.cc derror.cc field.cc field_conv.cc filesort.cc \ hostname.cc init.cc \ item.cc item_buff.cc item_cmpfunc.cc item_create.cc \ item_func.cc item_strfunc.cc item_sum.cc item_timefunc.cc \ - item_uniq.cc key.cc lock.cc log.cc log_event.cc md5.c \ + item_uniq.cc key.cc lock.cc log.cc log_event.cc \ mini_client.cc net_pkg.cc net_serv.cc opt_ft.cc opt_range.cc \ opt_sum.cc procedure.cc records.cc slave.cc sql_acl.cc \ sql_analyse.cc sql_base.cc sql_cache.cc sql_class.cc \ @@ -65,7 +65,7 @@ sqlobjects = convert.lo derror.lo field.lo field_conv.lo filesort.lo \ hostname.lo init.lo \ item.lo item_buff.lo item_cmpfunc.lo item_create.lo \ item_func.lo item_strfunc.lo item_sum.lo item_timefunc.lo \ - item_uniq.lo key.lo lock.lo log.lo log_event.lo md5.lo \ + item_uniq.lo key.lo lock.lo log.lo log_event.lo \ mini_client.lo net_pkg.lo net_serv.lo opt_ft.lo opt_range.lo \ opt_sum.lo procedure.lo records.lo slave.lo sql_acl.lo \ sql_analyse.lo sql_base.lo sql_cache.lo sql_class.lo \ diff --git a/libmysqld/libmysqld.c b/libmysqld/libmysqld.c index c6860098ed8..d90012b3bb6 100644 --- a/libmysqld/libmysqld.c +++ b/libmysqld/libmysqld.c @@ -1473,6 +1473,107 @@ get_info: DBUG_RETURN(0); } +/**************************************************************************** +* A modified version of connect(). connect2() allows you to specify +* a timeout value, in seconds, that we should wait until we +* derermine we can't connect to a particular host. If timeout is 0, +* my_connect() will behave exactly like connect(). +* +* Base version coded by Steve Bernacki, Jr. <steve@navinet.net> +*****************************************************************************/ + +int my_connect(my_socket s, const struct sockaddr *name, uint namelen, + uint timeout) +{ +#if defined(__WIN__) || defined(OS2) + return connect(s, (struct sockaddr*) name, namelen); +#else + int flags, res, s_err; + SOCKOPT_OPTLEN_TYPE s_err_size = sizeof(uint); + fd_set sfds; + 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 (timeout == 0) + return connect(s, (struct sockaddr*) name, namelen); + + flags = fcntl(s, F_GETFL, 0); /* Set socket to not block */ +#ifdef O_NONBLOCK + fcntl(s, F_SETFL, flags | O_NONBLOCK); /* and save the flags.. */ +#endif + + res = connect(s, (struct sockaddr*) name, namelen); + s_err = errno; /* Save the error... */ + fcntl(s, F_SETFL, flags); + if ((res != 0) && (s_err != EINPROGRESS)) + { + errno = s_err; /* Restore it */ + return(-1); + } + 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. + */ + + 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 + */ + start_time = time(NULL); + for (;;) + { + tv.tv_sec = (long) timeout; + tv.tv_usec = 0; + if ((res = select(s+1, NULL, &sfds, NULL, &tv)) >= 0) + break; + 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! + */ + + s_err=0; + if (getsockopt(s, SOL_SOCKET, SO_ERROR, (char*) &s_err, &s_err_size) != 0) + return(-1); + + if (s_err) + { /* getsockopt could succeed */ + errno = s_err; + return(-1); /* but return an error... */ + } + return(0); /* It's all good! */ +#endif +} + + int STDCALL mysql_real_query(MYSQL *mysql, const char *query, uint length) { |