summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorJonathan Bastien-Filiatrault <joe@x2a.org>2009-08-06 20:36:35 -0400
committerNikos Mavrogiannopoulos <nmav@gnutls.org>2010-06-03 19:36:35 +0200
commit6b5b3c0db249855c768aeef1325e6be265f2f7cb (patch)
tree2c5f5cf40db477ede0ed3765db722c2a1fff6dc2 /lib
parent74c2bcd1cd9d46efac5a146aef3048e33aa557b8 (diff)
downloadgnutls-6b5b3c0db249855c768aeef1325e6be265f2f7cb.tar.gz
Extract a simple_write function from _gnutls_io_write_buffered.
Diffstat (limited to 'lib')
-rw-r--r--lib/gnutls_buffers.c53
1 files changed, 53 insertions, 0 deletions
diff --git a/lib/gnutls_buffers.c b/lib/gnutls_buffers.c
index 65723251de..4ac986eaf7 100644
--- a/lib/gnutls_buffers.c
+++ b/lib/gnutls_buffers.c
@@ -356,7 +356,60 @@ finish:
return (sizeOfPtr - left);
}
+static ssize_t
+_gnutls_simple_write (gnutls_session_t session, void *iptr,
+ size_t sizeOfPtr)
+{
+ int i;
+ gnutls_transport_ptr_t fd = session->internals.transport_send_ptr;
+
+ session->internals.errnum = 0;
+ if (session->internals._gnutls_push_func == NULL)
+ {
+ i = send (GNUTLS_POINTER_TO_INT (fd), iptr, sizeOfPtr, 0);
+#if HAVE_WINSOCK2_H
+ if (i < 0)
+ {
+ int tmperr = WSAGetLastError ();
+ switch (tmperr)
+ {
+ case WSAEWOULDBLOCK:
+ session->internals.errnum = EAGAIN;
+ break;
+
+ case WSAEINTR:
+ session->internals.errnum = EINTR;
+ break;
+
+ default:
+ session->internals.errnum = EIO;
+ break;
+ }
+ WSASetLastError (tmperr);
+ }
+#endif
+ }
+ else
+ i = session->internals._gnutls_push_func (fd, iptr, sizeOfPtr);
+
+ if (i == -1)
+ {
+ int err = session->internals.errnum ? session->internals.errnum
+ : errno;
+
+ if (err == EAGAIN)
+ return GNUTLS_E_AGAIN;
+ else if (err == EINTR)
+ return GNUTLS_E_INTERRUPTED;
+ else
+ {
+ gnutls_assert ();
+ return GNUTLS_E_PUSH_ERROR;
+ }
+ }
+ return i;
+}
#define RCVLOWAT session->internals.lowat
/* This function is only used with berkeley style sockets.