summaryrefslogtreecommitdiff
path: root/ext/mysql/libmysql/violite.c
diff options
context:
space:
mode:
authorMySQL Team <mysql@php.net>2001-01-23 16:48:50 +0000
committerMySQL Team <mysql@php.net>2001-01-23 16:48:50 +0000
commit800f555b707c696798877c80352ded46289e87c4 (patch)
treec540242b6e6da4e9b99b46797a26b215abef0a64 /ext/mysql/libmysql/violite.c
parentd36858681a0d48414702524ebd16f31289b06fa8 (diff)
downloadphp-git-800f555b707c696798877c80352ded46289e87c4.tar.gz
Upgrade ext/mysql/libmysql to version 3.23.32. One notable bug fix is
that the client can now connect to a server which is using a default charset other than latin1.
Diffstat (limited to 'ext/mysql/libmysql/violite.c')
-rw-r--r--ext/mysql/libmysql/violite.c39
1 files changed, 32 insertions, 7 deletions
diff --git a/ext/mysql/libmysql/violite.c b/ext/mysql/libmysql/violite.c
index 310703684d..e73efb7e8d 100644
--- a/ext/mysql/libmysql/violite.c
+++ b/ext/mysql/libmysql/violite.c
@@ -18,11 +18,13 @@ This file is public domain and comes with NO WARRANTY of any kind */
#include <my_sys.h>
#include <my_net.h>
#include <m_string.h>
+#ifdef HAVE_POLL
+#include <sys/poll.h>
+#endif
#if defined(__EMX__)
#include <sys/ioctl.h>
-#define ioctlsocket(A,B,C) ioctl((A),(B),(void *)(C),sizeof(*(C)))
-#undef HAVE_FCNTL
+#define ioctlsocket ioctl
#endif /* defined(__EMX__) */
#if defined(MSDOS) || defined(__WIN__)
@@ -84,7 +86,9 @@ Vio *vio_new(my_socket sd, enum enum_vio_type type, my_bool localhost)
if ((vio = (Vio*) my_malloc(sizeof(*vio),MYF(MY_WME))))
{
vio_reset(vio, type, sd, 0, localhost);
- sprintf(vio->desc, "socket (%d)", vio->sd);
+ sprintf(vio->desc,
+ (vio->type == VIO_TYPE_SOCKET ? "socket (%d)" : "TCP/IP (%d)"),
+ vio->sd);
#if !defined(___WIN__) && !defined(__EMX__)
#if !defined(NO_FCNTL_NONBLOCK)
vio->fcntl_mode = fcntl(sd, F_GETFL);
@@ -92,7 +96,7 @@ Vio *vio_new(my_socket sd, enum enum_vio_type type, my_bool localhost)
#else /* !defined(__WIN__) && !defined(__EMX__) */
{
/* set to blocking mode by default */
- ulong arg=0;
+ ulong arg=0, r;
r = ioctlsocket(vio->sd,FIONBIO,(void*) &arg, sizeof(arg));
}
#endif
@@ -247,11 +251,10 @@ vio_is_blocking(Vio * vio)
}
-int vio_fastsend(Vio * vio, my_bool onoff)
+int vio_fastsend(Vio * vio __attribute__((unused)))
{
int r=0;
DBUG_ENTER("vio_fastsend");
- DBUG_PRINT("enter", ("onoff:%d", (int) onoff));
#ifdef IPTOS_THROUGHPUT
{
@@ -308,7 +311,7 @@ int vio_close(Vio * vio)
if (vio->type == VIO_TYPE_NAMEDPIPE)
{
#if defined(__NT__) && defined(MYSQL_SERVER)
- CancelIO(vio->hPipe);
+ CancelIo(vio->hPipe);
DisconnectNamedPipe(vio->hPipe);
#endif
r=CloseHandle(vio->hPipe);
@@ -383,4 +386,26 @@ void vio_in_addr(Vio *vio, struct in_addr *in)
DBUG_VOID_RETURN;
}
+
+/* Return 0 if there is data to be read */
+
+my_bool vio_poll_read(Vio *vio,uint timeout)
+{
+#ifndef HAVE_POLL
+ return 0;
+#else
+ struct pollfd fds;
+ int res;
+ DBUG_ENTER("vio_poll");
+ fds.fd=vio->sd;
+ fds.events=POLLIN;
+ fds.revents=0;
+ if ((res=poll(&fds,1,(int) timeout*1000)) <= 0)
+ {
+ DBUG_RETURN(res < 0 ? 0 : 1); /* Don't return 1 on errors */
+ }
+ DBUG_RETURN(fds.revents & POLLIN ? 0 : 1);
+#endif
+}
+
#endif /* HAVE_VIO */