apr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a..@apache.org
Subject cvs commit: apr/network_io/win32 sendrecv.c
Date Wed, 22 Sep 2004 18:21:31 GMT
ake         2004/09/22 11:21:30

  Modified:    os/win32 ap_regkey.c
               server   core.c
               server/mpm/winnt child.c mpm_winnt.c
               file_io/win32 dir.c open.c readwrite.c
               include  apr.hw
               network_io/win32 sendrecv.c
  Log:
  WIN64: first in a series to get Windows IA64 builds clean, this serves pages
  
  Revision  Changes    Path
  1.12      +18 -18    httpd-2.0/os/win32/ap_regkey.c
  
  Index: ap_regkey.c
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/os/win32/ap_regkey.c,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- ap_regkey.c	9 Feb 2004 20:40:49 -0000	1.11
  +++ ap_regkey.c	22 Sep 2004 18:21:29 -0000	1.12
  @@ -185,7 +185,7 @@
        */
       LONG rc;
       DWORD type;
  -    DWORD size = 0;
  +    apr_size_t size = 0;
       
   #if APR_HAS_UNICODE_FS
       IF_WIN_OS_IS_UNICODE 
  @@ -201,7 +201,7 @@
           else if (valuelen)
               return APR_ENAMETOOLONG;
           /* Read to NULL buffer to determine value size */
  -        rc = RegQueryValueExW(key->hkey, wvalname, 0, &type, NULL, &size);
  +        rc = RegQueryValueExW(key->hkey, wvalname, 0, &type, NULL, (DWORD *)&size);
           if (rc != ERROR_SUCCESS) {
               return APR_FROM_OS_ERROR(rc);
           }
  @@ -212,7 +212,7 @@
           wvalue = apr_palloc(pool, size);
           /* Read value based on size query above */
           rc = RegQueryValueExW(key->hkey, wvalname, 0, &type, 
  -                              (LPBYTE)wvalue, &size);
  +                              (LPBYTE)wvalue, (DWORD *)&size);
           if (rc != ERROR_SUCCESS) {
               return APR_FROM_OS_ERROR(rc);
           }
  @@ -223,7 +223,7 @@
                   apr_wchar_t *tmp = wvalue;
                   /* The size returned by ExpandEnvironmentStringsW is wchars */
                   wvalue = apr_palloc(pool, size * 2);
  -                size = ExpandEnvironmentStringsW(tmp, wvalue, size);
  +                size = ExpandEnvironmentStringsW(tmp, wvalue, (DWORD)size);
               }
           }
           else {
  @@ -247,7 +247,7 @@
       ELSE_WIN_OS_IS_ANSI
       {
           /* Read to NULL buffer to determine value size */
  -        rc = RegQueryValueEx(key->hkey, valuename, 0, &type, NULL, &size);
  +        rc = RegQueryValueEx(key->hkey, valuename, 0, &type, NULL, (DWORD *)&size);
           if (rc != ERROR_SUCCESS)
               return APR_FROM_OS_ERROR(rc);
   
  @@ -257,7 +257,7 @@
   
           *result = apr_palloc(pool, size);
           /* Read value based on size query above */
  -        rc = RegQueryValueEx(key->hkey, valuename, 0, &type, *result, &size);
  +        rc = RegQueryValueEx(key->hkey, valuename, 0, &type, *result, (DWORD *)&size);
           if (rc != ERROR_SUCCESS)
               return APR_FROM_OS_ERROR(rc);
   
  @@ -270,7 +270,7 @@
               if (size) {
                   char *tmp = *result;
                   *result = apr_palloc(pool, size);
  -                size = ExpandEnvironmentStrings(tmp, *result, size);
  +                size = ExpandEnvironmentStrings(tmp, *result, (DWORD)size);
               }
           }
       }
  @@ -289,7 +289,7 @@
        * that the system has configured (e.g. %SystemRoot%/someapp.exe)
        */
       LONG rc;
  -    DWORD size = strlen(value) + 1;
  +    apr_size_t size = strlen(value) + 1;
       DWORD type = (flags & AP_REGKEY_EXPAND) ? REG_EXPAND_SZ : REG_SZ;
       
   #if APR_HAS_UNICODE_FS
  @@ -320,7 +320,7 @@
            */
           size = (alloclen - wvallen) * 2;
           rc = RegSetValueExW(key->hkey, wvalname, 0, type, 
  -                            (LPBYTE)wvalue, size);
  +                            (LPBYTE)wvalue, (DWORD)size);
           if (rc != ERROR_SUCCESS)
               return APR_FROM_OS_ERROR(rc);
       }
  @@ -328,7 +328,7 @@
   #if APR_HAS_ANSI_FS
       ELSE_WIN_OS_IS_ANSI
       {
  -        rc = RegSetValueEx(key->hkey, valuename, 0, type, value, size);
  +        rc = RegSetValueEx(key->hkey, valuename, 0, type, value, (DWORD)size);
           if (rc != ERROR_SUCCESS)
               return APR_FROM_OS_ERROR(rc);
       }
  @@ -363,7 +363,7 @@
               return APR_ENAMETOOLONG;
           /* Read to NULL buffer to determine value size */
           rc = RegQueryValueExW(key->hkey, wvalname, 0, resulttype, 
  -                              NULL, resultsize);
  +                              NULL, (LPDWORD)resultsize);
           if (rc != ERROR_SUCCESS) {
               return APR_FROM_OS_ERROR(rc);
           }
  @@ -371,7 +371,7 @@
           /* Read value based on size query above */
           *result = apr_palloc(pool, *resultsize);
           rc = RegQueryValueExW(key->hkey, wvalname, 0, resulttype, 
  -                             (LPBYTE)*result, resultsize);
  +                             (LPBYTE)*result, (LPDWORD)resultsize);
       }
   #endif /* APR_HAS_UNICODE_FS */
   #if APR_HAS_ANSI_FS
  @@ -379,14 +379,14 @@
       {
           /* Read to NULL buffer to determine value size */
           rc = RegQueryValueEx(key->hkey, valuename, 0, resulttype, 
  -                             NULL, resultsize);
  +                             NULL, (LPDWORD)resultsize);
           if (rc != ERROR_SUCCESS)
               return APR_FROM_OS_ERROR(rc);
   
           /* Read value based on size query above */
           *result = apr_palloc(pool, *resultsize);
           rc = RegQueryValueEx(key->hkey, valuename, 0, resulttype, 
  -                             (LPBYTE)*result, resultsize);
  +                             (LPBYTE)*result, (LPDWORD)resultsize);
           if (rc != ERROR_SUCCESS)
               return APR_FROM_OS_ERROR(rc);
       }
  @@ -422,14 +422,14 @@
               return APR_ENAMETOOLONG;
   
           rc = RegSetValueExW(key->hkey, wvalname, 0, valuetype, 
  -                            (LPBYTE)value, valuesize);
  +                            (LPBYTE)value, (DWORD)valuesize);
       }
   #endif /* APR_HAS_UNICODE_FS */
   #if APR_HAS_ANSI_FS
       ELSE_WIN_OS_IS_ANSI
       {
           rc = RegSetValueEx(key->hkey, valuename, 0, valuetype, 
  -                            (LPBYTE)value, valuesize);
  +                            (LPBYTE)value, (DWORD)valuesize);
       }
   #endif
       if (rc != ERROR_SUCCESS) {
  @@ -452,7 +452,7 @@
       char *buf;
       char *tmp;
       DWORD type;
  -    DWORD size = 0;
  +    apr_size_t size = 0;
   
       rv = ap_regkey_value_raw_get(&value, &size, &type, key, valuename, pool);
       if (rv != APR_SUCCESS) {
  @@ -510,7 +510,7 @@
           }
       }
   
  -    *result = apr_array_make(pool, size, sizeof(char *));
  +    *result = apr_array_make(pool, (int)size, sizeof(char *));
       for (tmp = buf; *tmp; ++tmp) {
           char **newelem = (char **) apr_array_push(*result);
           *newelem = tmp;
  
  
  
  1.287     +2 -2      httpd-2.0/server/core.c
  
  Index: core.c
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/server/core.c,v
  retrieving revision 1.286
  retrieving revision 1.287
  diff -u -r1.286 -r1.287
  --- core.c	20 Sep 2004 20:12:20 -0000	1.286
  +++ core.c	22 Sep 2004 18:21:29 -0000	1.287
  @@ -2298,7 +2298,7 @@
       }
   
       cmd->server->path = arg;
  -    cmd->server->pathlen = strlen(arg);
  +    cmd->server->pathlen = (int)strlen(arg);
       return NULL;
   }
   
  @@ -3156,7 +3156,7 @@
                                        apr_size_t length, apr_size_t *nbytes)
   {
       apr_status_t rv = APR_SUCCESS;
  -    apr_int32_t togo;        /* Remaining number of bytes in the file to send */
  +    apr_size_t togo;        /* Remaining number of bytes in the file to send */
       apr_size_t sendlen = 0;
       apr_size_t bytes_sent;
       apr_int32_t i;
  
  
  
  1.38      +11 -6     httpd-2.0/server/mpm/winnt/child.c
  
  Index: child.c
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/server/mpm/winnt/child.c,v
  retrieving revision 1.37
  retrieving revision 1.38
  diff -u -r1.37 -r1.38
  --- child.c	14 Aug 2004 10:57:13 -0000	1.37
  +++ child.c	22 Sep 2004 18:21:30 -0000	1.38
  @@ -684,8 +684,12 @@
   {
       int rc;
       DWORD BytesRead;
  -    DWORD CompKey;
       LPOVERLAPPED pol;
  +#ifdef _WIN64
  +    ULONG_PTR CompKey;
  +#else
  +    DWORD CompKey;
  +#endif
   
       mpm_recycle_completion_context(context);
   
  @@ -728,10 +732,11 @@
    * Main entry point for the worker threads. Worker threads block in 
    * win*_get_connection() awaiting a connection to service.
    */
  -static void worker_main(long thread_num)
  +static void worker_main(long *thread_num_)
   {
       static int requests_this_child = 0;
       PCOMP_CONTEXT context = NULL;
  +    long thread_num = *thread_num_;
       ap_sb_handle_t *sbh;
   
       ap_log_error(APLOG_MARK, APLOG_DEBUG, APR_SUCCESS, ap_server_conf,
  @@ -867,7 +872,7 @@
       HANDLE *child_handles;
       int rv;
       time_t end_time;
  -    int i;
  +    long i;
       int cld;
   
       apr_pool_create(&pchild, pconf);
  @@ -928,7 +933,7 @@
        */
       ap_log_error(APLOG_MARK,APLOG_NOTICE, APR_SUCCESS, ap_server_conf, 
                    "Child %d: Starting %d worker threads.", my_pid, ap_threads_per_child);
  -    child_handles = (HANDLE) apr_pcalloc(pchild, ap_threads_per_child * sizeof(int));
  +    child_handles = (HANDLE) apr_pcalloc(pchild, ap_threads_per_child * sizeof(HANDLE));
       apr_thread_mutex_create(&child_lock, APR_THREAD_MUTEX_DEFAULT, pchild);
   
       while (1) {
  @@ -941,7 +946,7 @@
               ap_update_child_status_from_indexes(0, i, SERVER_STARTING, NULL);
               child_handles[i] = (HANDLE) _beginthreadex(NULL, (unsigned)ap_thread_stacksize,
                                                          (LPTHREAD_START_ROUTINE) worker_main,
  -                                                       (void *) i, 0, &tid);
  +                                                       (void *) &i, 0, &tid);
               if (child_handles[i] == 0) {
                   ap_log_error(APLOG_MARK, APLOG_CRIT, apr_get_os_error(), ap_server_conf,
                                "Child %d: _beginthreadex failed. Unable to create all worker
threads. "
  @@ -1113,7 +1118,7 @@
                    "Child %d: Waiting for %d worker threads to exit.", my_pid, threads_created);
       end_time = time(NULL) + 180;
       while (threads_created) {
  -        rv = wait_for_many_objects(threads_created, child_handles, end_time - time(NULL));
  +        rv = wait_for_many_objects(threads_created, child_handles, (DWORD)(end_time - time(NULL)));
           if (rv != WAIT_TIMEOUT) {
               rv = rv - WAIT_OBJECT_0;
               ap_assert((rv >= 0) && (rv < threads_created));
  
  
  
  1.313     +3 -3      httpd-2.0/server/mpm/winnt/mpm_winnt.c
  
  Index: mpm_winnt.c
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/server/mpm/winnt/mpm_winnt.c,v
  retrieving revision 1.312
  retrieving revision 1.313
  diff -u -r1.312 -r1.313
  --- mpm_winnt.c	25 Aug 2004 14:47:18 -0000	1.312
  +++ mpm_winnt.c	22 Sep 2004 18:21:30 -0000	1.313
  @@ -416,7 +416,7 @@
       HANDLE hDup;
       HANDLE os_start;
       HANDLE hScore;
  -    DWORD BytesWritten;
  +    apr_size_t BytesWritten;
   
       if (!DuplicateHandle(hCurrentProcess, child_ready_event, hProcess, &hDup,
           EVENT_MODIFY_STATE | SYNCHRONIZE, FALSE, 0)) {
  @@ -566,14 +566,14 @@
       int lcnt = 0;
       ap_listen_rec *lr;
       LPWSAPROTOCOL_INFO  lpWSAProtocolInfo;
  -    DWORD BytesWritten;
  +    apr_size_t BytesWritten;
   
       /* Run the chain of open sockets. For each socket, duplicate it 
        * for the target process then send the WSAPROTOCOL_INFO 
        * (returned by dup socket) to the child.
        */
       for (lr = ap_listeners; lr; lr = lr->next, ++lcnt) {
  -        int nsd;
  +        apr_os_sock_t nsd;
           lpWSAProtocolInfo = apr_pcalloc(p, sizeof(WSAPROTOCOL_INFO));
           apr_os_sock_get(&nsd,lr->sd);
           ap_log_error(APLOG_MARK, APLOG_INFO, APR_SUCCESS, ap_server_conf,
  
  
  
  1.72      +2 -2      apr/file_io/win32/dir.c
  
  Index: dir.c
  ===================================================================
  RCS file: /home/cvs/apr/file_io/win32/dir.c,v
  retrieving revision 1.71
  retrieving revision 1.72
  diff -u -r1.71 -r1.72
  --- dir.c	13 Feb 2004 09:38:26 -0000	1.71
  +++ dir.c	22 Sep 2004 18:21:30 -0000	1.72
  @@ -49,7 +49,7 @@
   {
       apr_status_t rv;
   
  -    int len = strlen(dirname);
  +    apr_size_t len = strlen(dirname);
       (*new) = apr_pcalloc(pool, sizeof(apr_dir_t));
       /* Leave room here to add and pop the '*' wildcard for FindFirstFile 
        * and double-null terminate so we have one character to change.
  @@ -243,7 +243,7 @@
   #else
               char fspec[APR_PATH_MAX];
   #endif
  -            int dirlen = strlen(thedir->dirname);
  +            apr_size_t dirlen = strlen(thedir->dirname);
               if (dirlen >= sizeof(fspec))
                   dirlen = sizeof(fspec) - 1;
               apr_cpystrn(fspec, thedir->dirname, sizeof(fspec));
  
  
  
  1.122     +2 -2      apr/file_io/win32/open.c
  
  Index: open.c
  ===================================================================
  RCS file: /home/cvs/apr/file_io/win32/open.c,v
  retrieving revision 1.121
  retrieving revision 1.122
  diff -u -r1.121 -r1.122
  --- open.c	13 Feb 2004 09:38:27 -0000	1.121
  +++ open.c	22 Sep 2004 18:21:30 -0000	1.122
  @@ -47,7 +47,7 @@
        * Note that the \\?\ form only works for local drive paths, and
        * \\?\UNC\ is needed UNC paths.
        */
  -    int srcremains = strlen(srcstr) + 1;
  +    apr_size_t srcremains = strlen(srcstr) + 1;
       apr_wchar_t *t = retstr;
       apr_status_t rv;
   
  @@ -101,7 +101,7 @@
        * then transform \\'s back into /'s since the \\?\ form never
        * allows '/' path seperators, and APR always uses '/'s.
        */
  -    int srcremains = wcslen(srcstr) + 1;
  +    apr_size_t srcremains = wcslen(srcstr) + 1;
       apr_status_t rv;
       char *t = retstr;
       if (srcstr[0] == L'\\' && srcstr[1] == L'\\' && 
  
  
  
  1.81      +37 -14    apr/file_io/win32/readwrite.c
  
  Index: readwrite.c
  ===================================================================
  RCS file: /home/cvs/apr/file_io/win32/readwrite.c,v
  retrieving revision 1.80
  retrieving revision 1.81
  diff -u -r1.80 -r1.81
  --- readwrite.c	13 Feb 2004 09:38:27 -0000	1.80
  +++ readwrite.c	22 Sep 2004 18:21:30 -0000	1.81
  @@ -27,9 +27,10 @@
    * read_with_timeout() 
    * Uses async i/o to emulate unix non-blocking i/o with timeouts.
    */
  -static apr_status_t read_with_timeout(apr_file_t *file, void *buf, apr_size_t len, apr_size_t
*nbytes)
  +static apr_status_t read_with_timeout(apr_file_t *file, void *buf, apr_size_t len_in, apr_size_t
*nbytes)
   {
       apr_status_t rv;
  +    DWORD len = (DWORD)len_in;
       *nbytes = 0;
   
       /* Handle the zero timeout non-blocking case */
  @@ -68,7 +69,8 @@
           file->pOverlapped->OffsetHigh = (DWORD)(file->filePtr >> 32);
       }
   
  -    rv = ReadFile(file->filehand, buf, len, nbytes, file->pOverlapped);
  +    *nbytes = 0;
  +    rv = ReadFile(file->filehand, buf, len, (LPDWORD)nbytes, file->pOverlapped);
   
       if (!rv) {
           rv = apr_get_os_error();
  @@ -85,7 +87,7 @@
               switch (rv) {
               case WAIT_OBJECT_0:
                   GetOverlappedResult(file->filehand, file->pOverlapped, 
  -                                    nbytes, TRUE);
  +                                    (LPDWORD)nbytes, TRUE);
                   rv = APR_SUCCESS;
                   break;
               case WAIT_TIMEOUT:
  @@ -286,7 +288,7 @@
                   thefile->pOverlapped->Offset     = (DWORD)thefile->filePtr;
                   thefile->pOverlapped->OffsetHigh = (DWORD)(thefile->filePtr >>
32);
               }
  -            rv = WriteFile(thefile->filehand, buf, *nbytes, &bwrote,
  +            rv = WriteFile(thefile->filehand, buf, (DWORD)*nbytes, &bwrote,
                              thefile->pOverlapped);
               if (thefile->append) {
                   apr_file_unlock(thefile);
  @@ -294,7 +296,7 @@
               }
           }
           else {
  -            rv = WriteFile(thefile->filehand, buf, *nbytes, &bwrote,
  +            rv = WriteFile(thefile->filehand, buf, (DWORD)*nbytes, &bwrote,
                              thefile->pOverlapped);
           }
           if (rv) {
  @@ -309,7 +311,7 @@
                   rv = WaitForSingleObject(thefile->pOverlapped->hEvent, INFINITE);
                   switch (rv) {
                       case WAIT_OBJECT_0:
  -                        GetOverlappedResult(thefile->filehand, thefile->pOverlapped,
nbytes, TRUE);
  +                        GetOverlappedResult(thefile->filehand, thefile->pOverlapped,
(LPDWORD)nbytes, TRUE);
                           rv = APR_SUCCESS;
                           break;
                       case WAIT_TIMEOUT:
  @@ -343,7 +345,7 @@
   {
       apr_status_t rv = APR_SUCCESS;
       apr_size_t i;
  -    DWORD bwrote = 0;
  +    apr_size_t bwrote = 0;
       char *buf;
   
       *nbytes = 0;
  @@ -361,7 +363,7 @@
   
   APR_DECLARE(apr_status_t) apr_file_putc(char ch, apr_file_t *thefile)
   {
  -    DWORD len = 1;
  +    apr_size_t len = 1;
   
       return apr_file_write(thefile, &ch, &len);
   }
  @@ -375,7 +377,7 @@
   APR_DECLARE(apr_status_t) apr_file_getc(char *ch, apr_file_t *thefile)
   {
       apr_status_t rc;
  -    int bread;
  +    apr_size_t bread;
   
       bread = 1;
       rc = apr_file_read(thefile, ch, &bread);
  @@ -393,7 +395,7 @@
   
   APR_DECLARE(apr_status_t) apr_file_puts(const char *str, apr_file_t *thefile)
   {
  -    DWORD len = strlen(str);
  +    apr_size_t len = strlen(str);
   
       return apr_file_write(thefile, str, &len);
   }
  @@ -431,13 +433,34 @@
   APR_DECLARE(apr_status_t) apr_file_flush(apr_file_t *thefile)
   {
       if (thefile->buffered) {
  -        DWORD written = 0;
  +        DWORD numbytes, written = 0;
           apr_status_t rc = 0;
  +        char *buffer;
  +        apr_size_t bytesleft;
   
           if (thefile->direction == 1 && thefile->bufpos) {
  -            if (!WriteFile(thefile->filehand, thefile->buffer, thefile->bufpos,
&written, NULL))
  -                rc = apr_get_os_error();
  -            thefile->filePtr += written;
  +            buffer = thefile->buffer;
  +            bytesleft = thefile->bufpos;           
  +
  +            do {
  +                if (bytesleft > DWORD_MAX) {
  +                    numbytes = DWORD_MAX;
  +                }
  +                else {
  +                    numbytes = (DWORD)bytesleft;
  +                }
  +
  +                if (!WriteFile(thefile->filehand, buffer, numbytes, &written, NULL))
{
  +                    rc = apr_get_os_error();
  +                    thefile->filePtr += written;
  +                    break;
  +                }
  +
  +                thefile->filePtr += written;
  +                bytesleft -= written;
  +                buffer += written;
  +
  +            } while (bytesleft > 0);
   
               if (rc == 0)
                   thefile->bufpos = 0;
  
  
  
  1.125     +3 -1      apr/include/apr.hw
  
  Index: apr.hw
  ===================================================================
  RCS file: /home/cvs/apr/include/apr.hw,v
  retrieving revision 1.124
  retrieving revision 1.125
  diff -u -r1.124 -r1.125
  --- apr.hw	4 Jun 2004 23:22:00 -0000	1.124
  +++ apr.hw	22 Sep 2004 18:21:30 -0000	1.125
  @@ -342,6 +342,8 @@
   #define APR_SIZEOF_VOIDP   4
   #endif
   
  +#define DWORD_MAX 4294967295
  +
   /* XXX These simply don't belong here, perhaps in apr_portable.h
    * based on some APR_HAVE_PID/GID/UID?
    */
  @@ -363,7 +365,7 @@
   #endif
   
   #ifndef WS2TCPIP_INLINE
  -6:09 PM 11/16/2003#define IN6_IS_ADDR_V4MAPPED(a) \
  +#define IN6_IS_ADDR_V4MAPPED(a) \
       (   (*(const apr_uint64_t *)(const void *)(&(a)->s6_addr[0]) == 0) \
        && (*(const apr_uint32_t *)(const void *)(&(a)->s6_addr[8]) == ntohl(0x0000ffff)))
   #endif
  
  
  
  1.68      +62 -24    apr/network_io/win32/sendrecv.c
  
  Index: sendrecv.c
  ===================================================================
  RCS file: /home/cvs/apr/network_io/win32/sendrecv.c,v
  retrieving revision 1.67
  retrieving revision 1.68
  diff -u -r1.67 -r1.68
  --- sendrecv.c	22 Jul 2004 01:48:34 -0000	1.67
  +++ sendrecv.c	22 Sep 2004 18:21:30 -0000	1.68
  @@ -43,7 +43,7 @@
       int lasterror;
       DWORD dwBytes = 0;
   
  -    wsaData.len = *len;
  +    wsaData.len = (u_long)*len;
       wsaData.buf = (char*) buf;
   
   #ifndef _WIN32_WCE
  @@ -72,7 +72,7 @@
       DWORD dwBytes = 0;
       DWORD flags = 0;
   
  -    wsaData.len = *len;
  +    wsaData.len = (u_long)*len;
       wsaData.buf = (char*) buf;
   
   #ifndef _WIN32_WCE
  @@ -94,21 +94,49 @@
   
   APR_DECLARE(apr_status_t) apr_socket_sendv(apr_socket_t *sock,
                                              const struct iovec *vec,
  -                                           apr_int32_t nvec, apr_size_t *nbytes)
  +                                           apr_int32_t in_vec, apr_size_t *nbytes)
   {
       apr_status_t rc = APR_SUCCESS;
       apr_ssize_t rv;
  -    int i;
  +    apr_size_t cur_len;
  +    apr_int32_t nvec = 0;
  +    int i, j = 0;
       DWORD dwBytes = 0;
  -    WSABUF *pWsaBuf = (nvec <= WSABUF_ON_STACK) ? _alloca(sizeof(WSABUF) * (nvec))
  -                                                : malloc(sizeof(WSABUF) * (nvec));
  +    WSABUF *pWsaBuf;
   
  +    for (i = 0; i < in_vec; i++) {
  +        cur_len = vec[i].iov_len;
  +        nvec++;
  +        while (cur_len > DWORD_MAX) {
  +            nvec++;
  +            cur_len -= DWORD_MAX;
  +        } 
  +    }
  +
  +    pWsaBuf = (nvec <= WSABUF_ON_STACK) ? _alloca(sizeof(WSABUF) * (nvec))
  +                                         : malloc(sizeof(WSABUF) * (nvec));
       if (!pWsaBuf)
           return APR_ENOMEM;
   
  -    for (i = 0; i < nvec; i++) {
  -        pWsaBuf[i].buf = vec[i].iov_base;
  -        pWsaBuf[i].len = vec[i].iov_len;
  +    for (i = 0; i < in_vec; i++) {
  +        char * base = vec[i].iov_base;
  +        cur_len = vec[i].iov_len;
  +        
  +        do {
  +            if (cur_len > DWORD_MAX) {
  +                pWsaBuf[j].buf = base;
  +                pWsaBuf[j].len = DWORD_MAX;
  +                cur_len -= DWORD_MAX;
  +                base += DWORD_MAX;
  +            }
  +            else {
  +                pWsaBuf[j].buf = base;
  +                pWsaBuf[j].len = (DWORD)cur_len;
  +                cur_len = 0;
  +            }
  +            j++;
  +
  +        } while (cur_len > 0);
       }
   #ifndef _WIN32_WCE
       rv = WSASend(sock->socketdes, pWsaBuf, nvec, &dwBytes, 0, NULL, NULL);
  @@ -140,7 +168,7 @@
   {
       apr_ssize_t rv;
   
  -    rv = sendto(sock->socketdes, buf, (*len), flags, 
  +    rv = sendto(sock->socketdes, buf, (int)*len, flags, 
                   (const struct sockaddr*)&where->sa, 
                   where->salen);
       if (rv == SOCKET_ERROR) {
  @@ -160,7 +188,7 @@
   {
       apr_ssize_t rv;
   
  -    rv = recvfrom(sock->socketdes, buf, (*len), flags, 
  +    rv = recvfrom(sock->socketdes, buf, (int)*len, flags, 
                     (struct sockaddr*)&from->sa, &from->salen);
       if (rv == SOCKET_ERROR) {
           (*len) = 0;
  @@ -225,13 +253,13 @@
                                                 apr_int32_t flags) 
   {
       apr_status_t status = APR_SUCCESS;
  -    apr_ssize_t rv;
  +    apr_status_t rv;
       apr_off_t curoff = *offset;
       DWORD dwFlags = 0;
  -    DWORD nbytes;
  +    apr_size_t nbytes;
       TRANSMIT_FILE_BUFFERS tfb, *ptfb = NULL;
       int ptr = 0;
  -    int bytes_to_send;   /* Bytes to send out of the file (not including headers) */
  +    apr_size_t bytes_to_send;   /* Bytes to send out of the file (not including headers)
*/
       int disconnected = 0;
       int sendv_trailers = 0;
       char hdtrbuf[4096];
  @@ -267,11 +295,15 @@
   
       /* Collapse the headers into a single buffer */
       if (hdtr && hdtr->numheaders) {
  +        apr_size_t head_length = tfb.HeadLength;
           ptfb = &tfb;
           nbytes = 0;
  -        rv = collapse_iovec((char **)&ptfb->Head, &ptfb->HeadLength, 
  +        rv = collapse_iovec((char **)&ptfb->Head, &head_length, 
                               hdtr->headers, hdtr->numheaders, 
                               hdtrbuf, sizeof(hdtrbuf));
  +
  +        tfb.HeadLength = (DWORD)head_length;
  +
           /* If not enough buffer, punt to sendv */
           if (rv == APR_INCOMPLETE) {
               rv = apr_socket_sendv(sock, hdtr->headers, hdtr->numheaders, &nbytes);
  @@ -289,19 +321,25 @@
           sock->overlapped->hEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
       }
       while (bytes_to_send) {
  +        DWORD xmitbytes;
  +
           if (bytes_to_send > MAX_SEGMENT_SIZE) {
  -            nbytes = MAX_SEGMENT_SIZE;
  +            xmitbytes = MAX_SEGMENT_SIZE;
           }
           else {
               /* Last call to TransmitFile() */
  -            nbytes = bytes_to_send;
  +            xmitbytes = (DWORD)bytes_to_send;
               /* Collapse the trailers into a single buffer */
               if (hdtr && hdtr->numtrailers) {
  +                apr_size_t tail_length = tfb.TailLength;
                   ptfb = &tfb;
  -                rv = collapse_iovec((char**) &ptfb->Tail, &ptfb->TailLength,
  +                rv = collapse_iovec((char**) &ptfb->Tail, &tail_length,
                                       hdtr->trailers, hdtr->numtrailers,
                                       hdtrbuf + ptfb->HeadLength,
                                       sizeof(hdtrbuf) - ptfb->HeadLength);
  +
  +                tfb.TailLength = (DWORD)tail_length;
  +
                   if (rv == APR_INCOMPLETE) {
                       /* If not enough buffer, punt to sendv, later */
                       sendv_trailers = 1;
  @@ -323,7 +361,7 @@
           /* XXX BoundsChecker claims dwFlags must not be zero. */
           rv = TransmitFile(sock->socketdes,  /* socket */
                             file->filehand, /* open file descriptor of the file to be
sent */
  -                          nbytes,         /* number of bytes to send. 0=send all */
  +                          xmitbytes,      /* number of bytes to send. 0=send all */
                             0,              /* Number of bytes per send. 0=use default */
                             sock->overlapped,    /* OVERLAPPED structure */
                             ptfb,           /* header and trailer buffers */
  @@ -341,7 +379,7 @@
                       if (!disconnected) {
                           if (!WSAGetOverlappedResult(sock->socketdes,
                                                       sock->overlapped,
  -                                                    &nbytes,
  +                                                    &xmitbytes,
                                                       FALSE,
                                                       &dwFlags)) {
                               status = apr_get_netos_error();
  @@ -351,7 +389,7 @@
                            * tracks bytes sent out of the file.
                            */
                           else if (ptfb) {
  -                            nbytes -= (ptfb->HeadLength + ptfb->TailLength);
  +                            xmitbytes -= (ptfb->HeadLength + ptfb->TailLength);
                           }
                       }
                   }
  @@ -374,9 +412,9 @@
           if (status != APR_SUCCESS)
               break;
   
  -        bytes_to_send -= nbytes;
  -        curoff += nbytes;
  -        *len += nbytes;
  +        bytes_to_send -= xmitbytes;
  +        curoff += xmitbytes;
  +        *len += xmitbytes;
           /* Adjust len for any headers/trailers sent */
           if (ptfb) {
               *len += (ptfb->HeadLength + ptfb->TailLength);
  
  
  

Mime
View raw message