28
28
const char *not_error_sqlstate= "00000";
29
29
const char *cant_connect_sqlstate= "08001";
31
const char * drizzleclient_sqlstate_get_unknown(void)
31
const char * sqlstate_get_unknown(void)
33
33
return unknown_sqlstate;
36
const char * drizzleclient_sqlstate_get_not_error(void)
36
const char * sqlstate_get_not_error(void)
38
38
return not_error_sqlstate;
41
const char * drizzleclient_sqlstate_get_cant_connect(void)
41
const char * sqlstate_get_cant_connect(void)
43
43
return cant_connect_sqlstate;
47
Wait up to timeout seconds for a connection to be established.
49
We prefer to do this with poll() as there is no limitations with this.
50
If not, we will use select()
53
static int wait_for_data(int fd, int32_t timeout)
59
ufds.events= POLLIN | POLLPRI;
60
if (!(res= poll(&ufds, 1, (int) timeout*1000)))
65
if (res < 0 || !(ufds.revents & (POLLIN | POLLPRI)) || (ufds.revents & POLLHUP))
69
46
/****************************************************************************
70
A modified version of connect(). drizzleclient_connect_with_timeout() allows you to specify
47
A modified version of connect(). connect_with_timeout() allows you to specify
71
48
a timeout value, in seconds, that we should wait until we
72
49
derermine we can't connect to a particular host. If timeout is 0,
73
drizzleclient_connect_with_timeout() will behave exactly like connect().
50
connect_with_timeout() will behave exactly like connect().
75
52
Base version coded by Steve Bernacki, Jr. <steve@navinet.net>
76
53
*****************************************************************************/
78
int drizzleclient_connect_with_timeout(int fd, const struct sockaddr *name, uint32_t namelen, int32_t timeout)
55
int connect_with_timeout(int fd, const struct sockaddr *name, uint32_t namelen, int32_t timeout)
80
57
int flags, res, s_err;
106
83
return wait_for_data(fd, timeout);
87
Wait up to timeout seconds for a connection to be established.
89
We prefer to do this with poll() as there is no limitations with this.
90
If not, we will use select()
93
int wait_for_data(int fd, int32_t timeout)
99
ufds.events= POLLIN | POLLPRI;
100
if (!(res= poll(&ufds, 1, (int) timeout*1000)))
105
if (res < 0 || !(ufds.revents & (POLLIN | POLLPRI)) || (ufds.revents & POLLHUP))