Commit be227009 authored by monty@narttu.mysql.fi's avatar monty@narttu.mysql.fi

Fix for UNIXWARE 7

Remove unaligned warnings on Ia64 from client library when using --host
Fix for replication when using many file descriptors 
parent 27f6a6c4
...@@ -43,6 +43,10 @@ ...@@ -43,6 +43,10 @@
#define HAVE_ERRNO_AS_DEFINE #define HAVE_ERRNO_AS_DEFINE
#endif /* __CYGWIN__ */ #endif /* __CYGWIN__ */
#if defined(i386) && !defined(__i386__)
#define __i386__
#endif
/* Macros to make switching between C and C++ mode easier */ /* Macros to make switching between C and C++ mode easier */
#ifdef __cplusplus #ifdef __cplusplus
#define C_MODE_START extern "C" { #define C_MODE_START extern "C" {
...@@ -145,6 +149,10 @@ double my_ulonglong2double(unsigned long long A); ...@@ -145,6 +149,10 @@ double my_ulonglong2double(unsigned long long A);
C_MODE_END C_MODE_END
#endif /* _AIX */ #endif /* _AIX */
#ifdef UNIXWARE_7
#define pthread_attr_setstacksize(A,B) /* setting stack breaks things */
#endif
#ifdef HAVE_BROKEN_SNPRINTF /* HPUX 10.20 don't have this defined */ #ifdef HAVE_BROKEN_SNPRINTF /* HPUX 10.20 don't have this defined */
#undef HAVE_SNPRINTF #undef HAVE_SNPRINTF
#endif #endif
......
...@@ -1595,6 +1595,18 @@ mysql_connect(MYSQL *mysql,const char *host, ...@@ -1595,6 +1595,18 @@ mysql_connect(MYSQL *mysql,const char *host,
#endif #endif
/*
The following union is used to force a struct to be double allgined.
This is to avoid warings with gethostname_r() on Linux itanium systems
*/
typedef union
{
double tmp;
char buff[GETHOSTBYNAME_BUFF_SIZE];
} gethostbyname_buff;
/* /*
Note that the mysql argument must be initialized with mysql_init() Note that the mysql argument must be initialized with mysql_init()
before calling mysql_real_connect ! before calling mysql_real_connect !
...@@ -1766,8 +1778,8 @@ mysql_real_connect(MYSQL *mysql,const char *host, const char *user, ...@@ -1766,8 +1778,8 @@ mysql_real_connect(MYSQL *mysql,const char *host, const char *user,
{ {
int tmp_errno; int tmp_errno;
struct hostent tmp_hostent,*hp; struct hostent tmp_hostent,*hp;
char buff2[GETHOSTBYNAME_BUFF_SIZE]; gethostbyname_buff buff2;
hp = my_gethostbyname_r(host,&tmp_hostent,buff2,sizeof(buff2), hp = my_gethostbyname_r(host,&tmp_hostent,buff2.buff,sizeof(buff2),
&tmp_errno); &tmp_errno);
if (!hp) if (!hp)
{ {
......
drop table if exists t1,t2,t7,t8,t9; drop table if exists t1,t2,t7,t8,t9;
drop database if exists mysqltest;
create table t1 (a int not null auto_increment, b char(16) not null, primary key (a)); create table t1 (a int not null auto_increment, b char(16) not null, primary key (a));
create table t2 (a int not null auto_increment, b char(16) not null, primary key (a)); create table t2 (a int not null auto_increment, b char(16) not null, primary key (a));
insert into t1 (b) values ("test"),("test1"),("test2"),("test3"); insert into t1 (b) values ("test"),("test1"),("test2"),("test3");
...@@ -49,11 +50,11 @@ Got one of the listed errors ...@@ -49,11 +50,11 @@ Got one of the listed errors
Got one of the listed errors Got one of the listed errors
Got one of the listed errors Got one of the listed errors
Got one of the listed errors Got one of the listed errors
alter table t9 rename test_mysqltest.t9; alter table t9 rename mysqltest.t9;
select count(*) from test_mysqltest.t9; select count(*) from mysqltest.t9;
count(*) count(*)
16724 16724
show create table test_mysqltest.t9; show create table mysqltest.t9;
Table Create Table Table Create Table
t9 CREATE TABLE `t9` ( t9 CREATE TABLE `t9` (
`a` int(11) NOT NULL auto_increment, `a` int(11) NOT NULL auto_increment,
...@@ -62,4 +63,4 @@ t9 CREATE TABLE `t9` ( ...@@ -62,4 +63,4 @@ t9 CREATE TABLE `t9` (
`d` int(11) NOT NULL default '0', `d` int(11) NOT NULL default '0',
PRIMARY KEY (`a`) PRIMARY KEY (`a`)
) TYPE=MyISAM ) TYPE=MyISAM
drop database test_mysqltest; drop database mysqltest;
...@@ -83,7 +83,9 @@ static int mc_read_one_row(MYSQL *mysql,uint fields,MYSQL_ROW row, ...@@ -83,7 +83,9 @@ static int mc_read_one_row(MYSQL *mysql,uint fields,MYSQL_ROW row,
ulong *lengths); ulong *lengths);
static MYSQL_DATA *mc_read_rows(MYSQL *mysql,MYSQL_FIELD *mysql_fields, static MYSQL_DATA *mc_read_rows(MYSQL *mysql,MYSQL_FIELD *mysql_fields,
uint fields); uint fields);
#if !(defined(__WIN__) || defined(OS2) || defined(__NETWARE__))
static int wait_for_data(my_socket fd, uint timeout);
#endif
#define CLIENT_CAPABILITIES (CLIENT_LONG_PASSWORD | CLIENT_LONG_FLAG | CLIENT_LOCAL_FILES) #define CLIENT_CAPABILITIES (CLIENT_LONG_PASSWORD | CLIENT_LONG_FLAG | CLIENT_LOCAL_FILES)
...@@ -232,93 +234,150 @@ static void mc_free_old_query(MYSQL *mysql) ...@@ -232,93 +234,150 @@ static void mc_free_old_query(MYSQL *mysql)
/**************************************************************************** /****************************************************************************
* A modified version of connect(). mc_sock_connect() allows you to specify A modified version of connect(). my_connect() allows you to specify
* a timeout value, in seconds, that we should wait until we a timeout value, in seconds, that we should wait until we
* derermine we can't connect to a particular host. If timeout is 0, derermine we can't connect to a particular host. If timeout is 0,
* mc_sock_connect() will behave exactly like connect(). my_connect() will behave exactly like connect().
*
* Base version coded by Steve Bernacki, Jr. <steve@navinet.net> Base version coded by Steve Bernacki, Jr. <steve@navinet.net>
*****************************************************************************/ *****************************************************************************/
static int mc_sock_connect(my_socket s, const struct sockaddr *name, static int mc_sock_connect(my_socket fd, const struct sockaddr *name,
uint namelen, uint to) uint namelen, uint timeout)
{ {
#if defined(__WIN__) || defined(OS2) || defined(__NETWARE__) #if defined(__WIN__) || defined(OS2) || defined(__NETWARE__)
return connect(s, (struct sockaddr*) name, namelen); return connect(fd, (struct sockaddr*) name, namelen);
#else #else
int flags, res, s_err; int flags, res, s_err;
SOCKOPT_OPTLEN_TYPE s_err_size = sizeof(uint);
fd_set sfds;
struct timeval tv;
/* 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 (to == 0) if (timeout == 0)
return connect(s, (struct sockaddr*) name, namelen); return connect(fd, (struct sockaddr*) name, namelen);
flags = fcntl(s, F_GETFL, 0); /* Set socket to not block */ flags = fcntl(fd, F_GETFL, 0); /* Set socket to not block */
#ifdef O_NONBLOCK #ifdef O_NONBLOCK
fcntl(s, F_SETFL, flags | O_NONBLOCK); /* and save the flags.. */ fcntl(fd, F_SETFL, flags | O_NONBLOCK); /* and save the flags.. */
#endif #endif
res = connect(s, (struct sockaddr*) name, namelen); res= connect(fd, (struct sockaddr*) name, namelen);
s_err = errno; /* Save the error... */ s_err= errno; /* Save the error... */
fcntl(s, F_SETFL, flags); fcntl(fd, F_SETFL, flags);
if ((res != 0) && (s_err != EINPROGRESS)) if ((res != 0) && (s_err != EINPROGRESS))
{ {
errno = s_err; /* Restore it */ errno= s_err; /* Restore it */
return(-1); return(-1);
} }
if (res == 0) /* Connected quickly! */ if (res == 0) /* Connected quickly! */
return(0); return(0);
return wait_for_data(fd, timeout);
#endif
}
/* 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); Wait up to timeout seconds for a connection to be established.
tv.tv_sec = (long) to;
tv.tv_usec = 0; We prefer to do this with poll() as there is no limitations with this.
#ifdef HPUX10 If not, we will use select()
res = select(s+1, NULL, (int*) &sfds, NULL, &tv); */
#if !(defined(__WIN__) || defined(OS2) || defined(__NETWARE__))
static int wait_for_data(my_socket fd, uint timeout)
{
#ifdef HAVE_POLL
struct pollfd ufds;
int res;
ufds.fd= fd;
ufds.events= POLLIN | POLLPRI;
if (!(res= poll(&ufds, 1, (int) timeout*1000)))
{
errno= EINTR;
return -1;
}
if (res < 0 || !(ufds.revents & (POLLIN | POLLPRI)))
return -1;
return 0;
#else #else
res = select(s+1, NULL, &sfds, NULL, &tv); SOCKOPT_OPTLEN_TYPE s_err_size = sizeof(uint);
#endif /* HPUX10 */ fd_set sfds;
if (res <= 0) /* Never became writable */ struct timeval tv;
return(-1); time_t start_time, now_time;
int res, s_err;
/* select() returned something more interesting than zero, let's if (fd >= FD_SETSIZE) /* Check if wrong error */
* see if we have any errors. If the next two statements pass, return 0; /* Can't use timeout */
* we've got an open socket!
/*
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(fd, &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 defined(HPUX10) && defined(THREAD)
if ((res = select(fd+1, NULL, (int*) &sfds, NULL, &tv)) > 0)
break;
#else
if ((res = select(fd+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!
*/
s_err=0; s_err=0;
if (getsockopt(s, SOL_SOCKET, SO_ERROR, (char*) &s_err, &s_err_size) != 0) if (getsockopt(fd, SOL_SOCKET, SO_ERROR, (char*) &s_err, &s_err_size) != 0)
return(-1); return(-1);
if (s_err) if (s_err)
{ // getsockopt() could succeed { /* getsockopt could succeed */
errno = s_err; errno = s_err;
return(-1); // but return an error... return(-1); /* but return an error... */
} }
return(0); /* It's all good! */ return (0); /* ok */
#endif #endif /* HAVE_POLL */
} }
#endif /* defined(__WIN__) || defined(OS2) || defined(__NETWARE__) */
/***************************************************************************** /*****************************************************************************
** read a packet from server. Give error message if socket was down ** read a packet from server. Give error message if socket was down
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment