Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/winsup
diff options
context:
space:
mode:
authorCorinna Vinschen <corinna@vinschen.de>2011-02-21 20:01:05 +0300
committerCorinna Vinschen <corinna@vinschen.de>2011-02-21 20:01:05 +0300
commit291698e54addbe2824b3f8d05cdbf707798b95a2 (patch)
tree60db7aa67329e83e9f48484a8bf8d690a12df4d5 /winsup
parent05901e6aee8af35b4d4d24bdefe2d307a86398aa (diff)
* fhandler_socket (fhandler_socket::readv): Call recv_internal directly,
rather than recvmsg. (fhandler_socket::writev): Call send_internal directly, rather than sendmsg. * net.cc (cygwin_recv): Call fhandler_socket::recvfrom directly, rather than cygwin_recvfrom. (cygwin_send): Call fhandler_socket::sendto directly, rather than cygwin_sendto.
Diffstat (limited to 'winsup')
-rw-r--r--winsup/cygwin/fhandler_socket.cc44
-rw-r--r--winsup/cygwin/net.cc28
2 files changed, 44 insertions, 28 deletions
diff --git a/winsup/cygwin/fhandler_socket.cc b/winsup/cygwin/fhandler_socket.cc
index 2192921b9..1b4bf2925 100644
--- a/winsup/cygwin/fhandler_socket.cc
+++ b/winsup/cygwin/fhandler_socket.cc
@@ -1368,18 +1368,16 @@ int
fhandler_socket::readv (const struct iovec *const iov, const int iovcnt,
ssize_t tot)
{
- struct msghdr msg =
- {
- msg_name: NULL,
- msg_namelen: 0,
- msg_iov: (struct iovec *) iov, // const_cast
- msg_iovlen: iovcnt,
- msg_control: NULL,
- msg_controllen: 0,
- msg_flags: 0
- };
-
- return recvmsg (&msg, 0);
+ WSABUF wsabuf[iovcnt];
+ WSABUF *wsaptr = wsabuf + iovcnt;
+ const struct iovec *iovptr = iov + iovcnt;
+ while (--wsaptr >= wsabuf)
+ {
+ wsaptr->len = (--iovptr)->iov_len;
+ wsaptr->buf = (char *) iovptr->iov_base;
+ }
+ WSAMSG wsamsg = { NULL, 0, wsabuf, iovcnt, { 0, NULL}, 0 };
+ return recv_internal (&wsamsg);
}
extern "C" {
@@ -1580,18 +1578,16 @@ int
fhandler_socket::writev (const struct iovec *const iov, const int iovcnt,
ssize_t tot)
{
- struct msghdr msg =
- {
- msg_name: NULL,
- msg_namelen: 0,
- msg_iov: (struct iovec *) iov, // const_cast
- msg_iovlen: iovcnt,
- msg_control: NULL,
- msg_controllen: 0,
- msg_flags: 0
- };
-
- return sendmsg (&msg, 0);
+ WSABUF wsabuf[iovcnt];
+ WSABUF *wsaptr = wsabuf;
+ const struct iovec *iovptr = iov;
+ for (int i = 0; i < iovcnt; ++i)
+ {
+ wsaptr->len = iovptr->iov_len;
+ (wsaptr++)->buf = (char *) (iovptr++)->iov_base;
+ }
+ WSAMSG wsamsg = { NULL, 0, wsabuf, iovcnt, { 0, NULL}, 0 };
+ return send_internal (&wsamsg, 0);
}
inline ssize_t
diff --git a/winsup/cygwin/net.cc b/winsup/cygwin/net.cc
index c692f99b7..71423d028 100644
--- a/winsup/cygwin/net.cc
+++ b/winsup/cygwin/net.cc
@@ -643,7 +643,6 @@ cygwin_sendto (int fd, const void *buf, size_t len, int flags,
syscall_printf ("%d = sendto (%d, %p, %d, %x, %p, %d)",
res, fd, buf, len, flags, to, tolen);
-
return res;
}
@@ -664,7 +663,6 @@ cygwin_recvfrom (int fd, void *buf, size_t len, int flags,
syscall_printf ("%d = recvfrom (%d, %p, %d, %x, %p, %p)",
res, fd, buf, len, flags, from, fromlen);
-
return res;
}
@@ -1448,14 +1446,36 @@ cygwin_getpeername (int fd, struct sockaddr *name, socklen_t *len)
extern "C" int
cygwin_recv (int fd, void *buf, size_t len, int flags)
{
- return cygwin_recvfrom (fd, buf, len, flags, NULL, NULL);
+ int res;
+
+ fhandler_socket *fh = get (fd);
+
+ myfault efault;
+ if (efault.faulted (EFAULT) || !fh)
+ res = -1;
+ else if ((res = len) != 0)
+ res = fh->recvfrom (buf, len, flags, NULL, NULL);
+
+ syscall_printf ("%d = recv (%d, %p, %d, %x)", res, fd, buf, len, flags);
+ return res;
}
/* exported as send: standards? */
extern "C" int
cygwin_send (int fd, const void *buf, size_t len, int flags)
{
- return cygwin_sendto (fd, buf, len, flags, NULL, 0);
+ int res;
+
+ fhandler_socket *fh = get (fd);
+
+ myfault efault;
+ if (efault.faulted (EFAULT) || !fh)
+ res = -1;
+ else
+ res = fh->sendto (buf, len, flags, NULL, 0);
+
+ syscall_printf ("%d = send (%d, %p, %d, %x)", res, fd, buf, len, flags);
+ return res;
}
/* getdomainname: standards? */