3
3
This program is free software; you can redistribute it and/or modify
4
4
it under the terms of the GNU General Public License as published by
5
the Free Software Foundation; either version 2 of the License, or
6
(at your option) any later version.
5
the Free Software Foundation; version 2 of the License.
8
7
This program is distributed in the hope that it will be useful,
9
8
but WITHOUT ANY WARRANTY; without even the implied warranty of
128
135
if (Ndb_getInAddr(&m_servaddr.sin_addr, m_server_name))
129
136
return NDB_INVALID_SOCKET;
132
const int r = ::connect(m_sockfd, (struct sockaddr*) &m_servaddr, sizeof(m_servaddr));
134
NDB_CLOSE_SOCKET(m_sockfd);
135
m_sockfd= NDB_INVALID_SOCKET;
136
return NDB_INVALID_SOCKET;
139
flags= fcntl(m_sockfd, F_GETFL, 0);
140
fcntl(m_sockfd, F_SETFL, flags | O_NONBLOCK);
142
r= ::connect(m_sockfd, (struct sockaddr*) &m_servaddr, sizeof(m_servaddr));
145
goto done; // connected immediately.
147
if (r < 0 && (errno != EINPROGRESS)) {
148
NDB_CLOSE_SOCKET(m_sockfd);
149
m_sockfd= NDB_INVALID_SOCKET;
150
return NDB_INVALID_SOCKET;
154
FD_SET(m_sockfd, &rset);
156
tval.tv_sec= m_connect_timeout_sec;
158
use_timeout= m_connect_timeout_sec;
160
if ((r= select(m_sockfd+1, &rset, &wset, NULL,
161
use_timeout? &tval : NULL)) == 0)
163
NDB_CLOSE_SOCKET(m_sockfd);
164
m_sockfd= NDB_INVALID_SOCKET;
165
return NDB_INVALID_SOCKET;
168
if (FD_ISSET(m_sockfd, &rset) || FD_ISSET(m_sockfd, &wset))
171
if (getsockopt(m_sockfd, SOL_SOCKET, SO_ERROR, &r, &len) < 0 || r)
173
// Solaris got an error... different than others
174
NDB_CLOSE_SOCKET(m_sockfd);
175
m_sockfd= NDB_INVALID_SOCKET;
176
return NDB_INVALID_SOCKET;
181
// select error, probably m_sockfd not set.
182
NDB_CLOSE_SOCKET(m_sockfd);
183
m_sockfd= NDB_INVALID_SOCKET;
184
return NDB_INVALID_SOCKET;
188
fcntl(m_sockfd, F_SETFL, flags);
140
191
if (!m_auth->client_authenticate(m_sockfd))