mariadb/vio/viosocket.c
unknown a821703912 Merge with 4.0
BitKeeper/etc/ignore:
  auto-union
BitKeeper/etc/logging_ok:
  auto-union
BitKeeper/deleted/.del-compile-netware-standard:
  Delete: netware/BUILD/compile-netware-standard
BitKeeper/deleted/.del-mwenv:
  Delete: netware/BUILD/mwenv
BitKeeper/deleted/.del-nwbootstrap:
  Delete: netware/BUILD/nwbootstrap
BitKeeper/deleted/.del-compile-AUTOTOOLS:
  Delete: netware/BUILD/compile-AUTOTOOLS
BitKeeper/deleted/.del-compile-linux-tools:
  Delete: netware/BUILD/compile-linux-tools
BitKeeper/deleted/.del-compile-netware-END:
  Delete: netware/BUILD/compile-netware-END
BitKeeper/deleted/.del-compile-netware-START:
  Delete: netware/BUILD/compile-netware-START
BitKeeper/deleted/.del-compile-netware-all:
  Delete: netware/BUILD/compile-netware-all
BitKeeper/deleted/.del-compile-netware-debug:
  Delete: netware/BUILD/compile-netware-debug
BitKeeper/deleted/.del-mwasmnlm~bc5746809d67feb5:
  Auto merged
BitKeeper/deleted/.del-mwenv~35c8b56062f4b6aa:
  Auto merged
BitKeeper/deleted/.del-mwccnlm~be63afd25a14c3f:
  Auto merged
BitKeeper/deleted/.del-mwldnlm~efb26c57cba3c980:
  Auto merged
BitKeeper/deleted/.del-netware.patch~f70a3a965f54d9ee:
  Auto merged
Docs/internals.texi:
  Auto merged
VC++Files/bdb/bdb.dsp:
  Auto merged
VC++Files/bdb/build_win32/Berkeley_DB.dsw:
  Auto merged
VC++Files/bdb/build_win32/db_archive.dsp:
  Auto merged
VC++Files/bdb/build_win32/db_buildall.dsp:
  Auto merged
VC++Files/bdb/build_win32/db_checkpoint.dsp:
  Auto merged
VC++Files/bdb/build_win32/db_deadlock.dsp:
  Auto merged
VC++Files/bdb/build_win32/db_dll.dsp:
  Auto merged
VC++Files/bdb/build_win32/db_dump.dsp:
  Auto merged
VC++Files/bdb/build_win32/db_java.dsp:
  Auto merged
VC++Files/bdb/build_win32/db_load.dsp:
  Auto merged
VC++Files/bdb/build_win32/db_printlog.dsp:
  Auto merged
VC++Files/bdb/build_win32/db_recover.dsp:
  Auto merged
VC++Files/bdb/build_win32/db_stat.dsp:
  Auto merged
VC++Files/bdb/build_win32/db_static.dsp:
  Auto merged
VC++Files/bdb/build_win32/db_static1.dsp:
  Auto merged
VC++Files/bdb/build_win32/db_tcl.dsp:
  Auto merged
VC++Files/bdb/build_win32/db_test.dsp:
  Auto merged
VC++Files/bdb/build_win32/db_upgrade.dsp:
  Auto merged
VC++Files/bdb/build_win32/db_verify.dsp:
  Auto merged
VC++Files/bdb/build_win32/ex_access.dsp:
  Auto merged
VC++Files/bdb/build_win32/ex_btrec.dsp:
  Auto merged
VC++Files/bdb/build_win32/ex_env.dsp:
  Auto merged
VC++Files/bdb/build_win32/ex_lock.dsp:
  Auto merged
VC++Files/bdb/build_win32/ex_mpool.dsp:
  Auto merged
VC++Files/bdb/build_win32/ex_tpcb.dsp:
  Auto merged
VC++Files/bdb/build_win32/excxx_access.dsp:
  Auto merged
VC++Files/bdb/build_win32/excxx_btrec.dsp:
  Auto merged
VC++Files/bdb/build_win32/excxx_env.dsp:
  Auto merged
VC++Files/bdb/build_win32/excxx_lock.dsp:
  Auto merged
VC++Files/bdb/build_win32/excxx_mpool.dsp:
  Auto merged
VC++Files/bdb/build_win32/excxx_tpcb.dsp:
  Auto merged
VC++Files/client/mysql.dsp:
  Auto merged
VC++Files/client/mysqladmin.dsp:
  Auto merged
VC++Files/client/mysqlcheck.dsp:
  Auto merged
VC++Files/client/mysqlclient.dsp:
  Auto merged
VC++Files/client/mysqlclient.dsw:
  Auto merged
VC++Files/client/mysqldump.dsp:
  Auto merged
VC++Files/client/mysqlimport.dsp:
  Auto merged
VC++Files/client/mysqlshow.dsp:
  Auto merged
VC++Files/comp_err/comp_err.dsp:
  Auto merged
VC++Files/contrib/asm386/zlibvc.dsp:
  Auto merged
VC++Files/contrib/asm386/zlibvc.dsw:
  Auto merged
VC++Files/contrib/minizip/zlibvc.dsp:
  Auto merged
VC++Files/contrib/minizip/zlibvc.dsw:
  Auto merged
VC++Files/dbug/dbug.dsp:
  Auto merged
VC++Files/dbug/dbug.dsw:
  Auto merged
VC++Files/heap/heap.dsp:
  Auto merged
VC++Files/innobase/innobase.dsp:
  Auto merged
VC++Files/isam/isam.dsp:
  Auto merged
VC++Files/isam/isam.dsw:
  Auto merged
VC++Files/isamchk/isamchk.dsp:
  Auto merged
VC++Files/libmysql/libmysql.dsp:
  Auto merged
VC++Files/libmysql/libmysql.dsw:
  Auto merged
VC++Files/libmysqld/examples/test_libmysqld.dsp:
  Auto merged
VC++Files/libmysqld/libmysqld.dsp:
  Auto merged
VC++Files/libmysqltest/myTest.dsp:
  Auto merged
VC++Files/libmysqltest/mytest.dsw:
  Auto merged
VC++Files/merge/merge.dsp:
  Auto merged
VC++Files/merge/merge.dsw:
  Auto merged
VC++Files/my_print_defaults/my_print_defaults.dsp:
  Auto merged
VC++Files/myisam/myisam.dsp:
  Auto merged
VC++Files/myisamchk/myisamchk.dsp:
  Auto merged
VC++Files/myisamlog/myisamlog.dsp:
  Auto merged
VC++Files/myisammrg/myisammrg.dsp:
  Auto merged
VC++Files/mysql.dsp:
  Auto merged
VC++Files/mysql.dsw:
  Auto merged
VC++Files/myisampack/myisampack.dsp:
  Auto merged
VC++Files/mysqlbinlog/mysqlbinlog.dsp:
  Auto merged
VC++Files/mysqlcheck/mysqlcheck.dsp:
  Auto merged
VC++Files/mysqldemb/mysqldemb.dsp:
  Auto merged
VC++Files/mysqlmanager/MySqlManager.dsp:
  Auto merged
VC++Files/mysqlmanager/mysqlmanager.dsw:
  Auto merged
VC++Files/mysqlserver/mysqlserver.dsp:
  Auto merged
VC++Files/mysqlshutdown/myshutdown.dsp:
  Auto merged
VC++Files/mysqlshutdown/mysqlshutdown.dsp:
  Auto merged
VC++Files/mysqlwatch/mysqlwatch.dsp:
  Auto merged
VC++Files/mysys/mysys.dsp:
  Auto merged
VC++Files/mysys/mysys.dsw:
  Auto merged
VC++Files/pack_isam/pack_isam.dsp:
  Auto merged
VC++Files/perror/perror.dsp:
  Auto merged
VC++Files/regex/regex.dsp:
  Auto merged
VC++Files/regex/regex.dsw:
  Auto merged
VC++Files/replace/replace.dsp:
  Auto merged
VC++Files/sql/mysqld.dsw:
  Auto merged
VC++Files/sql/mysqldmax.dsp:
  Auto merged
VC++Files/sql/old/mysqld.dsw:
  Auto merged
VC++Files/strings/MASM6x/strings.dsp:
  Auto merged
VC++Files/strings/MASM6x/strings.dsw:
  Auto merged
VC++Files/strings/backup/strings.dsp:
  Auto merged
VC++Files/strings/backup/strings.dsw:
  Auto merged
VC++Files/strings/noMASM/strings.dsp:
  Auto merged
VC++Files/strings/noMASM/strings.dsw:
  Auto merged
VC++Files/strings/strings.dsw:
  Auto merged
VC++Files/test1/test1.dsp:
  Auto merged
VC++Files/thr_insert_test/thr_insert_test.dsp:
  Auto merged
VC++Files/thr_test/thr_test.dsp:
  Auto merged
VC++Files/vio/vio.dsp:
  Auto merged
VC++Files/zlib/zlib.dsp:
  Auto merged
client/mysqlbinlog.cc:
  Auto merged
client/mysqlshow.c:
  Auto merged
include/my_global.h:
  Auto merged
include/my_sys.h:
  Auto merged
include/myisam.h:
  Auto merged
include/thr_lock.h:
  Auto merged
include/violite.h:
  Auto merged
innobase/buf/buf0buf.c:
  Auto merged
innobase/os/os0file.c:
  Auto merged
innobase/row/row0sel.c:
  Auto merged
innobase/srv/srv0start.c:
  Auto merged
innobase/trx/trx0sys.c:
  Auto merged
libmysqld/lib_vio.c:
  Auto merged
myisam/mi_create.c:
  Auto merged
mysql-test/Makefile.am:
  Auto merged
mysql-test/r/create.result:
  Auto merged
mysql-test/r/group_by.result:
  Auto merged
mysql-test/r/innodb.result:
  Auto merged
mysql-test/r/join.result:
  Auto merged
mysql-test/r/rpl000001.result:
  Auto merged
mysql-test/r/select.result:
  Auto merged
mysql-test/t/auto_increment.test:
  Auto merged
mysql-test/t/create.test:
  Auto merged
mysql-test/t/func_like.test:
  Auto merged
mysql-test/t/group_by.test:
  Auto merged
mysql-test/t/innodb.test:
  Auto merged
mysql-test/t/join.test:
  Auto merged
mysql-test/t/type_datetime.test:
  Auto merged
mysql-test/t/type_timestamp.test:
  Auto merged
mysys/default.c:
  Auto merged
mysys/thr_lock.c:
  Auto merged
scripts/make_binary_distribution.sh:
  Auto merged
scripts/mysqld_safe.sh:
  Auto merged
sql/filesort.cc:
  Auto merged
sql/ha_innodb.h:
  Auto merged
sql/ha_myisam.cc:
  Auto merged
sql/handler.cc:
  Auto merged
sql/handler.h:
  Auto merged
sql/item.cc:
  Auto merged
sql/item_cmpfunc.cc:
  Auto merged
sql/item_func.cc:
  Auto merged
sql/lock.cc:
  Auto merged
sql/log.cc:
  Auto merged
sql/log_event.h:
  Auto merged
sql/mf_iocache.cc:
  Auto merged
sql/mysql_priv.h:
  Auto merged
sql/net_serv.cc:
  Auto merged
sql/opt_range.cc:
  Auto merged
sql/repl_failsafe.cc:
  Auto merged
sql/repl_failsafe.h:
  Auto merged
sql/slave.cc:
  Auto merged
sql/slave.h:
  Auto merged
sql/sql_analyse.cc:
  Auto merged
sql/sql_base.cc:
  Auto merged
sql-bench/crash-me.sh:
  Auto merged
sql/share/polish/errmsg.txt:
  Auto merged
sql/sql_class.h:
  Auto merged
sql/sql_rename.cc:
  Auto merged
sql/sql_repl.cc:
  Auto merged
sql/sql_repl.h:
  Auto merged
sql/sql_update.cc:
  Auto merged
sql/stacktrace.c:
  Auto merged
sql/table.cc:
  Auto merged
sql/unireg.h:
  Auto merged
strings/ctype-tis620.c:
  Auto merged
strings/t_ctype.h:
  Auto merged
support-files/mysql.spec.sh:
  Auto merged
tests/grant.res:
  Auto merged
vio/viosocket.c:
  Auto merged
2003-03-16 19:17:54 +02:00

462 lines
11 KiB
C

/* Copyright (C) 2000 MySQL AB
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
/*
Note that we can't have assertion on file descriptors; The reason for
this is that during mysql shutdown, another thread can close a file
we are working on. In this case we should just return read errors from
the file descriptior.
*/
#define DONT_MAP_VIO
#include <my_global.h>
#include <mysql_com.h>
#include <errno.h>
#include <violite.h>
#include <my_sys.h>
#include <my_net.h>
#include <m_string.h>
#ifndef __WIN__
#define HANDLE void *
#endif
int vio_errno(Vio *vio __attribute__((unused)))
{
return socket_errno; /* On Win32 this mapped to WSAGetLastError() */
}
int vio_read(Vio * vio, gptr buf, int size)
{
int r;
DBUG_ENTER("vio_read");
DBUG_PRINT("enter", ("sd=%d, buf=%p, size=%d", vio->sd, buf, size));
#ifdef __WIN__
r = recv(vio->sd, buf, size,0);
#else
errno=0; /* For linux */
r = read(vio->sd, buf, size);
#endif /* __WIN__ */
#ifndef DBUG_OFF
if (r < 0)
{
DBUG_PRINT("vio_error", ("Got error %d during read",errno));
}
#endif /* DBUG_OFF */
DBUG_PRINT("exit", ("%d", r));
DBUG_RETURN(r);
}
int vio_write(Vio * vio, const gptr buf, int size)
{
int r;
DBUG_ENTER("vio_write");
DBUG_PRINT("enter", ("sd=%d, buf=%p, size=%d", vio->sd, buf, size));
#ifdef __WIN__
r = send(vio->sd, buf, size,0);
#else
r = write(vio->sd, buf, size);
#endif /* __WIN__ */
#ifndef DBUG_OFF
if (r < 0)
{
DBUG_PRINT("vio_error", ("Got error on write: %d",socket_errno));
}
#endif /* DBUG_OFF */
DBUG_PRINT("exit", ("%d", r));
DBUG_RETURN(r);
}
int vio_blocking(Vio * vio __attribute__((unused)), my_bool set_blocking_mode,
my_bool *old_mode)
{
int r=0;
DBUG_ENTER("vio_blocking");
*old_mode= test(!(vio->fcntl_mode & O_NONBLOCK));
DBUG_PRINT("enter", ("set_blocking_mode: %d old_mode: %d",
(int) set_blocking_mode, (int) *old_mode));
#if !defined(___WIN__) && !defined(__EMX__)
#if !defined(NO_FCNTL_NONBLOCK)
if (vio->sd >= 0)
{
int old_fcntl=vio->fcntl_mode;
if (set_blocking_mode)
vio->fcntl_mode &= ~O_NONBLOCK; /* clear bit */
else
vio->fcntl_mode |= O_NONBLOCK; /* set bit */
if (old_fcntl != vio->fcntl_mode)
r = fcntl(vio->sd, F_SETFL, vio->fcntl_mode);
}
#else
r= set_blocking_mode ? 0 : 1;
#endif /* !defined(NO_FCNTL_NONBLOCK) */
#else /* !defined(__WIN__) && !defined(__EMX__) */
#ifndef __EMX__
if (vio->type != VIO_TYPE_NAMEDPIPE)
#endif
{
ulong arg;
int old_fcntl=vio->fcntl_mode;
if (set_blocking_mode)
{
arg = 0;
vio->fcntl_mode &= ~O_NONBLOCK; /* clear bit */
}
else
{
arg = 1;
vio->fcntl_mode |= O_NONBLOCK; /* set bit */
}
if (old_fcntl != vio->fcntl_mode)
r = ioctlsocket(vio->sd,FIONBIO,(void*) &arg, sizeof(arg));
}
#ifndef __EMX__
else
r= test(!(vio->fcntl_mode & O_NONBLOCK)) != set_blocking_mode;
#endif /* __EMX__ */
#endif /* !defined(__WIN__) && !defined(__EMX__) */
DBUG_PRINT("exit", ("%d", r));
DBUG_RETURN(r);
}
my_bool
vio_is_blocking(Vio * vio)
{
my_bool r;
DBUG_ENTER("vio_is_blocking");
r = !(vio->fcntl_mode & O_NONBLOCK);
DBUG_PRINT("exit", ("%d", (int) r));
DBUG_RETURN(r);
}
int vio_fastsend(Vio * vio __attribute__((unused)))
{
int r=0;
DBUG_ENTER("vio_fastsend");
#ifdef IPTOS_THROUGHPUT
{
#ifndef __EMX__
int tos = IPTOS_THROUGHPUT;
if (!setsockopt(vio->sd, IPPROTO_IP, IP_TOS, (void *) &tos, sizeof(tos)))
#endif /* !__EMX__ */
{
int nodelay = 1;
if (setsockopt(vio->sd, IPPROTO_TCP, TCP_NODELAY, (void *) &nodelay,
sizeof(nodelay))) {
DBUG_PRINT("warning",
("Couldn't set socket option for fast send"));
r= -1;
}
}
}
#endif /* IPTOS_THROUGHPUT */
DBUG_PRINT("exit", ("%d", r));
DBUG_RETURN(r);
}
int vio_keepalive(Vio* vio, my_bool set_keep_alive)
{
int r=0;
uint opt = 0;
DBUG_ENTER("vio_keepalive");
DBUG_PRINT("enter", ("sd=%d, set_keep_alive=%d", vio->sd, (int)
set_keep_alive));
if (vio->type != VIO_TYPE_NAMEDPIPE)
{
if (set_keep_alive)
opt = 1;
r = setsockopt(vio->sd, SOL_SOCKET, SO_KEEPALIVE, (char *) &opt,
sizeof(opt));
}
DBUG_RETURN(r);
}
my_bool
vio_should_retry(Vio * vio __attribute__((unused)))
{
int en = socket_errno;
return (en == SOCKET_EAGAIN || en == SOCKET_EINTR ||
en == SOCKET_EWOULDBLOCK);
}
int vio_close(Vio * vio)
{
int r;
DBUG_ENTER("vio_close");
#ifdef __WIN__
if (vio->type == VIO_TYPE_NAMEDPIPE)
{
#if defined(__NT__) && defined(MYSQL_SERVER)
CancelIo(vio->hPipe);
DisconnectNamedPipe(vio->hPipe);
#endif
r=CloseHandle(vio->hPipe);
}
else if (vio->type != VIO_CLOSED)
#endif /* __WIN__ */
{
r=0;
if (shutdown(vio->sd,2))
r= -1;
if (closesocket(vio->sd))
r= -1;
}
if (r)
{
DBUG_PRINT("vio_error", ("close() failed, error: %d",socket_errno));
/* FIXME: error handling (not critical for MySQL) */
}
vio->type= VIO_CLOSED;
vio->sd= -1;
DBUG_RETURN(r);
}
const char *vio_description(Vio * vio)
{
return vio->desc;
}
enum enum_vio_type vio_type(Vio* vio)
{
return vio->type;
}
my_socket vio_fd(Vio* vio)
{
return vio->sd;
}
my_bool vio_peer_addr(Vio * vio, char *buf, uint16 *port)
{
DBUG_ENTER("vio_peer_addr");
DBUG_PRINT("enter", ("sd: %d", vio->sd));
if (vio->localhost)
{
strmov(buf,"127.0.0.1");
*port= 0;
}
else
{
size_socket addrLen = sizeof(struct sockaddr);
if (getpeername(vio->sd, (struct sockaddr *) (& (vio->remote)),
&addrLen) != 0)
{
DBUG_PRINT("exit", ("getpeername gave error: %d", socket_errno));
DBUG_RETURN(1);
}
my_inet_ntoa(vio->remote.sin_addr,buf);
*port= ntohs(vio->remote.sin_port);
}
DBUG_PRINT("exit", ("addr: %s", buf));
DBUG_RETURN(0);
}
void vio_in_addr(Vio *vio, struct in_addr *in)
{
DBUG_ENTER("vio_in_addr");
if (vio->localhost)
bzero((char*) in, sizeof(*in)); /* This should never be executed */
else
*in=vio->remote.sin_addr;
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
}
#ifdef __WIN__
int vio_read_pipe(Vio * vio, gptr buf, int size)
{
DWORD length;
DBUG_ENTER("vio_read_pipe");
DBUG_PRINT("enter", ("sd=%d, buf=%p, size=%d", vio->sd, buf, size));
if (!ReadFile(vio->hPipe, buf, size, &length, NULL))
DBUG_RETURN(-1);
DBUG_PRINT("exit", ("%d", length));
DBUG_RETURN(length);
}
int vio_write_pipe(Vio * vio, const gptr buf, int size)
{
DWORD length;
DBUG_ENTER("vio_write_pipe");
DBUG_PRINT("enter", ("sd=%d, buf=%p, size=%d", vio->sd, buf, size));
if (!WriteFile(vio->hPipe, (char*) buf, size, &length, NULL))
DBUG_RETURN(-1);
DBUG_PRINT("exit", ("%d", length));
DBUG_RETURN(length);
}
int vio_close_pipe(Vio * vio)
{
int r;
DBUG_ENTER("vio_close_pipe");
#if defined(__NT__) && defined(MYSQL_SERVER)
CancelIo(vio->hPipe);
DisconnectNamedPipe(vio->hPipe);
#endif
r=CloseHandle(vio->hPipe);
if (r)
{
DBUG_PRINT("vio_error", ("close() failed, error: %d",GetLastError()));
/* FIXME: error handling (not critical for MySQL) */
}
vio->type= VIO_CLOSED;
vio->sd= -1;
DBUG_RETURN(r);
}
#ifdef HAVE_SMEM
int vio_read_shared_memory(Vio * vio, gptr buf, int size)
{
int length;
int remain_local;
char *current_postion;
DBUG_ENTER("vio_read_shared_memory");
DBUG_PRINT("enter", ("sd=%d, buf=%p, size=%d", vio->sd, buf, size));
remain_local = size;
current_postion=buf;
do
{
if (vio->shared_memory_remain == 0)
{
if (WaitForSingleObject(vio->event_server_wrote,vio->net->read_timeout*1000) != WAIT_OBJECT_0)
{
DBUG_RETURN(-1);
};
vio->shared_memory_pos = vio->handle_map;
vio->shared_memory_remain = uint4korr((ulong*)vio->shared_memory_pos);
vio->shared_memory_pos+=4;
}
length = size;
if (vio->shared_memory_remain < length)
length = vio->shared_memory_remain;
if (length > remain_local)
length = remain_local;
memcpy(current_postion,vio->shared_memory_pos,length);
vio->shared_memory_remain-=length;
vio->shared_memory_pos+=length;
current_postion+=length;
remain_local-=length;
if (!vio->shared_memory_remain)
if (!SetEvent(vio->event_client_read)) DBUG_RETURN(-1);
} while (remain_local);
length = size;
DBUG_PRINT("exit", ("%d", length));
DBUG_RETURN(length);
}
int vio_write_shared_memory(Vio * vio, const gptr buf, int size)
{
int length;
uint remain;
HANDLE pos;
int sz;
char *current_postion;
DBUG_ENTER("vio_write_shared_memory");
DBUG_PRINT("enter", ("sd=%d, buf=%p, size=%d", vio->sd, buf, size));
remain = size;
current_postion = buf;
while (remain != 0)
{
if (WaitForSingleObject(vio->event_server_read,vio->net->write_timeout*1000) != WAIT_OBJECT_0)
{
DBUG_RETURN(-1);
};
sz = remain > shared_memory_buffer_length ? shared_memory_buffer_length: remain;
int4store(vio->handle_map,sz);
pos = vio->handle_map + 4;
memcpy(pos,current_postion,sz);
remain-=sz;
current_postion+=sz;
if (!SetEvent(vio->event_client_wrote)) DBUG_RETURN(-1);
}
length = size;
DBUG_PRINT("exit", ("%d", length));
DBUG_RETURN(length);
}
int vio_close_shared_memory(Vio * vio)
{
int r;
DBUG_ENTER("vio_close_shared_memory");
r=UnmapViewOfFile(vio->handle_map) || CloseHandle(vio->event_server_wrote) ||
CloseHandle(vio->event_server_read) || CloseHandle(vio->event_client_wrote) ||
CloseHandle(vio->event_client_read) || CloseHandle(vio->handle_file_map);
if (r)
{
DBUG_PRINT("vio_error", ("close() failed, error: %d",r));
/* FIXME: error handling (not critical for MySQL) */
}
vio->type= VIO_CLOSED;
vio->sd= -1;
DBUG_RETURN(r);
}
#endif
#endif