cURL / Mailing Lists / curl-library / Single Mail

curl-library

PATCH: A fix to allow OpenVMS to (HTTP) POST data larger than 64K...

From: Tim Sneddon, Systems Programmer, BSD, Infomedia Ltd <tsneddon_at_bsd.infomedia.com.au>
Date: Thu, 10 Jun 2004 10:33:05 +0800

Recently it was discovered by one of our customers that they were
unable to (HTTP) POST more than 64K of data. After a bit of messing
around, and a call to HP it was discovered that the BSD sockets
library avaiable with OpenVMS 7.3-1 and TCP/IP V5.4 and below were
limited by the $QIO maximum buffer size.

It made sense to me that the CRTL should handle the dividing up
of the input buffer as the manual states it should be able to send
up to 2GB of data. This however, is not the case.

According to HP the CRTL in OpenVMS V7.3-2 is fixed, but it requires
TCP/IP V5.5 to take effect.

The patch I have provided includes changes to the following source
modules:

    o. lib/sendf.c - This is the code changed to allow buffers
                          larger than 64K to be sent. It basically
                          splits the buffer up using a 64K window and
                          sends it piece by piece.

                          The code is #ifdef'd :-( using
                          HAVE_VMS_64K_LIMIT. Didn't really want to
                          break anyone else's system.

    o. packages/vms/config-vms.*
                        - I have modified these two header files to
                          define HAVE_VMS_64K_LIMIT.

    o. src/getpass.c - When building the updated source I found
                          that this module would not build because
                          of the "struct _iosb iosb" declaration that
                          had been left behind.

These changes have been tested on OpenVMS Alpha and VAX. The code
builds on I64, but it is a DECnet only system at present. We have
been too busy setting up other things to bother with IP at present.

Regards, Tim.

PS. The patch was generated in the GNV environment so it is relatively
UN*X friendly :-)

-- 
Tim Sneddon                                tsneddon[at]infomedia.com.au
Systems Programmer                  Infomedia Business Systems Division
                         Level 3, 823 Wellington St, West Perth WA 6005
                          Phone: +61 8 9217 5000   Fax: +61 8 9217 5055

diff -u3r ../curl/lib/sendf.c ./lib/sendf.c
--- ../curl/lib/sendf.c Wed Jun 9 10:47:35 2004
+++ ./lib/sendf.c Thu Jun 10 08:18:50 2004
@@ -231,7 +231,7 @@
                     size_t len,
                     ssize_t *written)
 {
- ssize_t bytes_written;
+ ssize_t bytes_written = 0;
   CURLcode retcode;
 
 #ifdef USE_SSLEAY
@@ -288,7 +288,39 @@
     else
 #endif /* HAVE_KRB4 */
     {
+#ifdef HAVE_VMS_64K_LIMIT
+ /* This code allows data buffers larger than 64K to be sent on OpenVMS
+ systems by breaking them up into manageable pieces of 64K and less.
+ For some reason the sockets interface does not attempt to handle
+ large buffers and restricts the caller to the $QIO maximum
+ buffer size. This is not a problem for OpenVMS V7.3-2 with TCP/IP
+ V5.5 and above. */
+ int offset = 0;
+ char *memptr = 0;
+ int memptrlen = 0;
+ ssize_t swrite_result = 0;
+
+ while (offset < len) {
+ memptr = (char *)mem+offset;
+
+ memptrlen = len - offset;
+ if (memptrlen > USHRT_MAX) {
+ memptrlen = USHRT_MAX;
+ }
+
+ swrite_result = send(sockfd, memptr, memptrlen, 0);
+ if (swrite_result < 0) {
+ bytes_written = swrite_result;
+ break;
+ }
+
+ bytes_written += swrite_result;
+
+ offset += memptrlen;
+ }
+#else
       bytes_written = (ssize_t)swrite(sockfd, mem, len);
+#endif /* HAVE_VMS_64K_LIMIT */
     }
     if(-1 == bytes_written) {
       int err = Curl_ourerrno();
diff -u3r ../curl/packages/vms/config-vms.h_with_ssl ./packages/vms/config-vms.h_with_ssl
--- ../curl/packages/vms/config-vms.h_with_ssl Wed Jun 9 10:48:27 2004
+++ ./packages/vms/config-vms.h_with_ssl Thu Jun 10 08:19:26 2004
@@ -262,3 +262,9 @@
 
 /* Somewhere around 7.12.0 HAVE_INET_NTOP was introduced. */
 #define HAVE_INET_NTOP 1
+
+/* Define if you have OpenVMS V7.3-1 and below and TCP/IP V5.5 and below.
+ This handles an issue where the sockets interface cannot handle buffers
+ larger than 64K. This may also be necessary for TCPware, Multinet and other
+ third-party IP stacks. */
+#define HAVE_VMS_64K_LIMIT 1
diff -u3r ../curl/packages/vms/config-vms.h_without_ssl ./packages/vms/config-vms.h_without_ssl
--- ../curl/packages/vms/config-vms.h_without_ssl Wed Jun 9 10:48:27 2004
+++ ./packages/vms/config-vms.h_without_ssl Thu Jun 10 08:19:26 2004
@@ -262,3 +262,9 @@
 
 /* Somewhere around 7.12.0 HAVE_INET_NTOP was introduced. */
 #define HAVE_INET_NTOP 1
+
+/* Define if you have OpenVMS V7.3-1 and below and TCP/IP V5.5 and below.
+ This handles an issue where the sockets interface cannot handle buffers
+ larger than 64K. This may also be necessary for TCPware, Multinet and other
+ third-party IP stacks. */
+#define HAVE_VMS_64K_LIMIT 1
diff -u3r ../curl/src/getpass.c ./src/getpass.c
--- ../curl/src/getpass.c Wed Jun 9 10:49:00 2004
+++ ./src/getpass.c Thu Jun 10 08:18:34 2004
@@ -50,7 +50,6 @@
 {
   long sts;
   short chan;
- struct _iosb iosb;
   /* MSK, 23-JAN-2004, iosbdef.h wasn't in VAX V7.2 or CC 6.4 */
   /* distribution so I created this. May revert back later to */
   /* struct _iosb iosb; */
Received on 2004-06-10