Going back to take two... I'm reviewing and committing so changes to occur fairly shortly don't create extra hassles later applying these patches.
Some are trivial, some are very close to rights. I'm committing those tonight. Some need more review. I'm uncomfortable with one aspect or another of your choices in porting in such module patches - so I'll post questions to the list and your attention on those points. But that takes significantly more time to either reassure myself they are fine-as-is, or post the question on how we should approach them. Some are outright wrong. I'll post those as well with detailed explanation of the underlying issues. Again, it takes more time than I have tonight. Finally, I don't have a ton of time, and I'd love to see these finished this month. Others understand Win32 sockets API as well if not better than I, so I'm attaching the network aspects of your patch for seperate review. Would a Win32 committer care to review the attached network_io patches from Mladen for style, consistency and correctness? Deep understanding of WinCE isn't necessary, if you ASSURE that the patch does NOT change the behavior on other Win32 platforms :) Bill From: "William A. Rowe, Jr." <[EMAIL PROTECTED]> Sent: Sunday, February 10, 2002 11:05 PM > From: "Mladen Turk" <[EMAIL PROTECTED]> > To: <dev@apr.apache.org> > Cc: "William A. Rowe, Jr." <[EMAIL PROTECTED]> > Sent: Sunday, February 10, 2002 12:30 PM > Subject: APR WCE take 3 > > > > My last patch to enable WCE builds need to patch the 36 files to get things > > work. > > That's fine :) > > So I'm still slogging through those 36 files, individually, to prevent us > from introducing errors like the 'Global\' name-prefix patch did to locks.c. > (We forgot to consider unnamed locks.) > > Yes - it takes more time this way - it will be month end before I'm 100% > finished applying your entire patch set. But it is clearer, and will greatly > benefit any future hacking.
Index: include/arch/win32/networkio.h =================================================================== RCS file: /home/cvspublic/apr/include/arch/win32/networkio.h,v retrieving revision 1.20 diff -u -r1.20 networkio.h --- include/arch/win32/networkio.h 16 Jul 2001 20:37:00 -0000 1.20 +++ include/arch/win32/networkio.h 29 Jan 2002 14:42:51 -0000 @@ -78,9 +78,18 @@ int numread; fd_set *write; int numwrite; - fd_set *except; + fd_set *exception; int numexcept; }; + +#ifdef _WIN32_WCE +#ifndef WSABUF +typedef struct _WSABUF { + u_long len; /* the length of the buffer */ + char FAR * buf; /* the pointer to the buffer */ +} WSABUF, FAR * LPWSABUF; +#endif +#endif apr_status_t status_from_res_error(int); Index: network_io/win32/poll.c =================================================================== RCS file: /home/cvspublic/apr/network_io/win32/poll.c,v retrieving revision 1.28 diff -u -r1.28 poll.c --- network_io/win32/poll.c 6 Aug 2001 16:15:04 -0000 1.28 +++ network_io/win32/poll.c 29 Jan 2002 14:42:56 -0000 @@ -56,9 +56,12 @@ #include "apr_network_io.h" #include "apr_general.h" #include "apr_lib.h" +#if APR_HAVE_ERRNO_H #include <errno.h> +#endif +#if APR_HAVE_TIME_H #include <time.h> - +#endif APR_DECLARE(apr_status_t) apr_poll_setup(apr_pollfd_t **new, apr_int32_t num, apr_pool_t *cont) @@ -70,12 +73,12 @@ (*new)->cntxt = cont; (*new)->read = (fd_set *)apr_palloc(cont, sizeof(fd_set)); (*new)->write = (fd_set *)apr_palloc(cont, sizeof(fd_set)); - (*new)->except = (fd_set *)apr_palloc(cont, sizeof(fd_set)); + (*new)->exception = (fd_set *)apr_palloc(cont, sizeof(fd_set)); FD_ZERO((*new)->read); (*new)->numread = 0; FD_ZERO((*new)->write); (*new)->numwrite = 0; - FD_ZERO((*new)->except); + FD_ZERO((*new)->exception); (*new)->numexcept = 0; return APR_SUCCESS; } @@ -115,7 +118,7 @@ newwrite = aprset->write; } if (aprset->numexcept != 0) { - newexcept = aprset->except; + newexcept = aprset->exception; } if (newread == NULL && newwrite == NULL && newexcept == NULL) { @@ -164,8 +167,13 @@ if (FD_ISSET(sock->sock, aprset->read)) { revents |= APR_POLLIN; +#ifdef _WIN32_WCE + if (recv(sock->sock, data.buf, data.len, 0) == SOCKET_ERROR) +#else if (WSARecv(sock->sock, &data, 1, &dummy, &flags, NULL, - NULL) == SOCKET_ERROR) { + NULL) == SOCKET_ERROR) +#endif + { /* This is only legit since we don't return the error */ dummy = WSAGetLastError(); switch (dummy) { @@ -195,7 +203,7 @@ * connection on a non-blocking socket. Might be a bad assumption, but * it works for now. rbb. */ - if (FD_ISSET(sock->sock, aprset->except)) { + if (FD_ISSET(sock->sock, aprset->exception)) { revents |= APR_POLLPRI; } @@ -225,7 +233,7 @@ aprset->numread--; } if (events & APR_POLLPRI) { - FD_CLR(sock->sock, aprset->except); + FD_CLR(sock->sock, aprset->exception); aprset->numexcept--; } if (events & APR_POLLOUT) { Index: network_io/win32/sendrecv.c =================================================================== RCS file: /home/cvspublic/apr/network_io/win32/sendrecv.c,v retrieving revision 1.45 diff -u -r1.45 sendrecv.c --- network_io/win32/sendrecv.c 28 Dec 2001 23:50:49 -0000 1.45 +++ network_io/win32/sendrecv.c 29 Jan 2002 14:42:58 -0000 @@ -58,7 +58,9 @@ #include "apr_network_io.h" #include "apr_lib.h" #include "fileio.h" +#if APR_HAVE_TIME_H #include <time.h> +#endif /* MAX_SEGMENT_SIZE is the maximum amount of data that will be sent to a client * in one call of TransmitFile. This number must be small enough to give the @@ -82,7 +84,12 @@ wsaData.len = *len; wsaData.buf = (char*) buf; +#ifndef _WIN32_WCE rv = WSASend(sock->sock, &wsaData, 1, &dwBytes, 0, NULL, NULL); +#else + rv = send(sock->sock, wsaData.buf, wsaData.len, 0); + dwBytes = rv; +#endif if (rv == SOCKET_ERROR) { lasterror = apr_get_netos_error(); return lasterror; @@ -106,7 +113,12 @@ wsaData.len = *len; wsaData.buf = (char*) buf; +#ifndef _WIN32_WCE rv = WSARecv(sock->sock, &wsaData, 1, &dwBytes, &flags, NULL, NULL); +#else + rv = recv(sock->sock, wsaData.buf, wsaData.len, 0); + dwBytes = rv; +#endif if (rv == SOCKET_ERROR) { lasterror = apr_get_netos_error(); *len = 0; @@ -139,12 +151,21 @@ pWsaBuf[i].buf = vec[i].iov_base; pWsaBuf[i].len = vec[i].iov_len; } - +#ifndef _WIN32_WCE rv = WSASend(sock->sock, pWsaBuf, nvec, &dwBytes, 0, NULL, NULL); if (rv == SOCKET_ERROR) { rc = apr_get_netos_error(); } - +#else + for (i = 0; i < nvec; i++) { + rv = send(sock->sock, pWsaBuf[i].buf, pWsaBuf[i].len, 0); + if (rv == SOCKET_ERROR) { + rc = apr_get_netos_error(); + break; + } + dwBytes += rv; + } +#endif if (nvec > WSABUF_ON_STACK) free(pWsaBuf); Index: network_io/win32/sockaddr.c =================================================================== RCS file: /home/cvspublic/apr/network_io/win32/sockaddr.c,v retrieving revision 1.25 diff -u -r1.25 sockaddr.c --- network_io/win32/sockaddr.c 16 Feb 2001 04:16:04 -0000 1.25 +++ network_io/win32/sockaddr.c 29 Jan 2002 14:42:58 -0000 @@ -57,6 +57,7 @@ #include "apr_general.h" #include "apr_strings.h" #include "apr_lib.h" +#include "apr_private.h" #include <string.h> static apr_status_t get_local_addr(apr_socket_t *sock) @@ -72,6 +73,14 @@ } } +#ifdef _WIN32_WCE +/* WCE lacks getservbyname */ +static void *getservbyname(const char *name, const char *proto) +{ + return NULL; +} + +#endif /* Include this here so we have get_local_addr defined... */ #include "../unix/sa_common.c" Index: network_io/win32/sockets.c =================================================================== RCS file: /home/cvspublic/apr/network_io/win32/sockets.c,v retrieving revision 1.70 diff -u -r1.70 sockets.c --- network_io/win32/sockets.c 4 Jan 2002 21:28:56 -0000 1.70 +++ network_io/win32/sockets.c 29 Jan 2002 14:42:59 -0000 @@ -167,8 +167,9 @@ APR_DECLARE(apr_status_t) apr_shutdown(apr_socket_t *thesocket, apr_shutdown_how_e how) { - int winhow; + int winhow = 0; +#if SD_RECEIVE switch (how) { case APR_SHUTDOWN_READ: { winhow = SD_RECEIVE; @@ -185,6 +186,7 @@ default: return APR_BADARG; } +#endif if (shutdown(thesocket->sock, winhow) == 0) { return APR_SUCCESS; } Index: shmem/win32/shm.c =================================================================== RCS file: /home/cvspublic/apr/shmem/win32/shm.c,v retrieving revision 1.9 diff -u -r1.9 shm.c --- shmem/win32/shm.c 28 Jan 2002 15:56:08 -0000 1.9 +++ shmem/win32/shm.c 29 Jan 2002 14:43:00 -0000 @@ -119,12 +119,16 @@ if (!file) { /* Do Anonymous, which will be an inherited handle */ +#ifndef _WIN32_WCE hFile = INVALID_HANDLE_VALUE; sec.nLength = sizeof(SECURITY_ATTRIBUTES); sec.lpSecurityDescriptor = NULL; sec.bInheritHandle = TRUE; + psec = &sec; +#else + psec = NULL; +#endif mapkey = NULL; - psec = &sec; } else { /* Do file backed, which is not an inherited handle @@ -218,7 +222,15 @@ #if APR_HAS_UNICODE_FS IF_WIN_OS_IS_UNICODE { +#ifndef _WIN32_WCE hMap = OpenFileMappingW(FILE_MAP_READ | FILE_MAP_WRITE, FALSE, mapkey); +#else + /* The WCE 3.0 lacks OpenFileMapping. So we emulate one with + * opening the existing shmem and reading its size from the header + */ + hMap = CreateFileMappingW(INVALID_HANDLE_VALUE, NULL, + PAGE_READWRITE, 0, sizeof(apr_shm_t), mapkey); +#endif } #endif #if APR_HAS_ANSI_FS @@ -240,13 +252,28 @@ *m = (apr_shm_t *) apr_palloc(pool, sizeof(apr_shm_t)); (*m)->pool = pool; - (*m)->hMap = hMap; (*m)->memblk = base; - (*m)->usrmem = (char*)base + sizeof(memblock_t); /* Real (*m)->mem->size could be recovered with VirtualQuery */ (*m)->size = (*m)->memblk->size; - (*m)->length = (*m)->memblk->length; +#if _WIN32_WCE + /* Reopen with real size */ + UnmapViewOfFile(base); + CloseHandle(hMap); + hMap = CreateFileMappingW(INVALID_HANDLE_VALUE, NULL, + PAGE_READWRITE, 0, (*m)->size, mapkey); + if (!hMap) { + return apr_get_os_error(); + } + base = MapViewOfFile(hMap, FILE_MAP_READ | FILE_MAP_WRITE, 0, 0, 0); + if (!base) { + CloseHandle(hMap); + return apr_get_os_error(); + } +#endif + (*m)->hMap = hMap; + (*m)->length = (*m)->memblk->length; + (*m)->usrmem = (char*)base + sizeof(memblock_t); apr_pool_cleanup_register((*m)->pool, *m, shm_cleanup, apr_pool_cleanup_null); return APR_SUCCESS;