stoddard 00/01/24 12:58:32
Modified: src/lib/apr aprlib.mak aprlib.dsp src/lib/apr/network_io/win32 sendrecv.c Log: More sendfile tweaks for Windows. Still not ready for prime time. Revision Changes Path 1.7 +9 -211 apache-2.0/src/lib/apr/aprlib.mak Index: aprlib.mak =================================================================== RCS file: /home/cvs/apache-2.0/src/lib/apr/aprlib.mak,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- aprlib.mak 2000/01/17 23:16:02 1.6 +++ aprlib.mak 2000/01/24 20:58:13 1.7 @@ -105,8 +105,8 @@ LINK32=link.exe LINK32_FLAGS=kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib\ advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib\ - odbccp32.lib ws2_32.lib /nologo /subsystem:windows /dll /incremental:no\ - /pdb:"$(OUTDIR)\aprlib.pdb" /machine:I386 /def:".\aprlib.def"\ + odbccp32.lib ws2_32.lib mswsock.lib /nologo /subsystem:windows /dll\ + /incremental:no /pdb:"$(OUTDIR)\aprlib.pdb" /machine:I386 /def:".\aprlib.def"\ /out:"$(OUTDIR)\aprlib.dll" /implib:"$(OUTDIR)\aprlib.lib" DEF_FILE= \ ".\aprlib.def" @@ -232,9 +232,10 @@ LINK32=link.exe LINK32_FLAGS=kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib\ advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib\ - odbccp32.lib ws2_32.lib /nologo /subsystem:windows /dll /incremental:yes\ - /pdb:"$(OUTDIR)\aprlib.pdb" /debug /machine:I386 /def:".\aprlib.def"\ - /out:"$(OUTDIR)\aprlib.dll" /implib:"$(OUTDIR)\aprlib.lib" /pdbtype:sept + odbccp32.lib ws2_32.lib mswsock.lib /nologo /subsystem:windows /dll\ + /incremental:yes /pdb:"$(OUTDIR)\aprlib.pdb" /debug /machine:I386\ + /def:".\aprlib.def" /out:"$(OUTDIR)\aprlib.dll" /implib:"$(OUTDIR)\aprlib.lib"\ + /pdbtype:sept DEF_FILE= \ ".\aprlib.def" LINK32_OBJS= \ @@ -328,11 +329,7 @@ ".\include\apr_win.h"\ ".\include\apr_winconfig.h"\ ".\time\win32\atime.h"\ - {$(INCLUDE)}"sys\types.h"\ -NODEP_CPP_ACCES=\ - ".\include\apr.h"\ - "$(INTDIR)\access.obj" : $(SOURCE) $(DEP_CPP_ACCES) "$(INTDIR)" $(CPP) $(CPP_PROJ) $(SOURCE) @@ -371,11 +368,6 @@ ".\include\apr_time.h"\ ".\include\apr_win.h"\ ".\include\apr_winconfig.h"\ - {$(INCLUDE)}"sys\types.h"\ - -NODEP_CPP_APR_C=\ - ".\include\apr.h"\ - ".\lib\apr_config.h"\ "$(INTDIR)\apr_cpystrn.obj" : $(SOURCE) $(DEP_CPP_APR_C) "$(INTDIR)" @@ -403,25 +395,10 @@ SOURCE=.\lib\apr_execve.c -!IF "$(CFG)" == "aprlib - Win32 Release" - -NODEP_CPP_APR_E=\ - ".\lib\apr_config.h"\ - - -"$(INTDIR)\apr_execve.obj" : $(SOURCE) "$(INTDIR)" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -!ELSEIF "$(CFG)" == "aprlib - Win32 Debug" - - "$(INTDIR)\apr_execve.obj" : $(SOURCE) "$(INTDIR)" $(CPP) $(CPP_PROJ) $(SOURCE) -!ENDIF - SOURCE=.\lib\apr_fnmatch.c !IF "$(CFG)" == "aprlib - Win32 Release" @@ -435,11 +412,6 @@ ".\include\apr_thread_proc.h"\ ".\include\apr_time.h"\ ".\include\apr_win.h"\ - {$(INCLUDE)}"sys\types.h"\ - -NODEP_CPP_APR_F=\ - ".\include\apr.h"\ - ".\lib\apr_config.h"\ "$(INTDIR)\apr_fnmatch.obj" : $(SOURCE) $(DEP_CPP_APR_F) "$(INTDIR)" @@ -478,11 +450,6 @@ ".\include\apr_time.h"\ ".\include\apr_win.h"\ ".\include\apr_winconfig.h"\ - {$(INCLUDE)}"sys\types.h"\ - -NODEP_CPP_APR_G=\ - ".\include\apr.h"\ - ".\lib\apr_config.h"\ "$(INTDIR)\apr_getpass.obj" : $(SOURCE) $(DEP_CPP_APR_G) "$(INTDIR)" @@ -521,12 +488,7 @@ ".\include\apr_thread_proc.h"\ ".\include\apr_time.h"\ ".\include\apr_win.h"\ - {$(INCLUDE)}"sys\types.h"\ -NODEP_CPP_APR_M=\ - ".\include\apr.h"\ - ".\lib\apr_config.h"\ - "$(INTDIR)\apr_md5.obj" : $(SOURCE) $(DEP_CPP_APR_M) "$(INTDIR)" $(CPP) $(CPP_PROJ) $(SOURCE) @@ -568,12 +530,6 @@ ".\include\apr_win.h"\ ".\include\apr_winconfig.h"\ ".\misc\win32\misc.h"\ - {$(INCLUDE)}"sys\stat.h"\ - {$(INCLUDE)}"sys\types.h"\ - -NODEP_CPP_APR_P=\ - ".\include\apr.h"\ - ".\lib\apr_config.h"\ "$(INTDIR)\apr_pools.obj" : $(SOURCE) $(DEP_CPP_APR_P) "$(INTDIR)" @@ -616,12 +572,6 @@ ".\include\apr_time.h"\ ".\include\apr_win.h"\ ".\include\apr_winconfig.h"\ - {$(INCLUDE)}"sys\types.h"\ - -NODEP_CPP_APR_S=\ - ".\include\apr.h"\ - ".\lib\apr_config.h"\ - ".\lib\http_log.h"\ CPP_SWITCHES=/nologo /MT /W3 /GX /O2 /I "./include" /I "./inc" /I\ "./misc/win32" /I "./file_io/win32" /I "./misc/win32/" /I "./file_io/win32/" /D\ @@ -660,9 +610,6 @@ !ENDIF SOURCE=.\lib\apr_snprintf.c - -!IF "$(CFG)" == "aprlib - Win32 Release" - DEP_CPP_APR_SN=\ ".\include\apr_errno.h"\ ".\include\apr_file_io.h"\ @@ -672,36 +619,12 @@ ".\include\apr_time.h"\ ".\include\apr_win.h"\ ".\include\apr_winconfig.h"\ - {$(INCLUDE)}"sys\types.h"\ - -NODEP_CPP_APR_SN=\ - ".\include\apr.h"\ - ".\lib\apr_config.h"\ "$(INTDIR)\apr_snprintf.obj" : $(SOURCE) $(DEP_CPP_APR_SN) "$(INTDIR)" $(CPP) $(CPP_PROJ) $(SOURCE) -!ELSEIF "$(CFG)" == "aprlib - Win32 Debug" - -DEP_CPP_APR_SN=\ - ".\include\apr_errno.h"\ - ".\include\apr_file_io.h"\ - ".\include\apr_general.h"\ - ".\include\apr_lib.h"\ - ".\include\apr_thread_proc.h"\ - ".\include\apr_time.h"\ - ".\include\apr_win.h"\ - ".\include\apr_winconfig.h"\ - - -"$(INTDIR)\apr_snprintf.obj" : $(SOURCE) $(DEP_CPP_APR_SN) "$(INTDIR)" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -!ENDIF - SOURCE=.\lib\apr_tables.c !IF "$(CFG)" == "aprlib - Win32 Release" @@ -718,12 +641,7 @@ ".\include\apr_win.h"\ ".\include\apr_winconfig.h"\ ".\misc\win32\misc.h"\ - {$(INCLUDE)}"sys\types.h"\ -NODEP_CPP_APR_T=\ - ".\include\apr.h"\ - ".\lib\apr_config.h"\ - "$(INTDIR)\apr_tables.obj" : $(SOURCE) $(DEP_CPP_APR_T) "$(INTDIR)" $(CPP) $(CPP_PROJ) $(SOURCE) @@ -769,11 +687,6 @@ ".\include\apr_time.h"\ ".\include\apr_win.h"\ ".\include\apr_winconfig.h"\ - {$(INCLUDE)}"sys\stat.h"\ - {$(INCLUDE)}"sys\types.h"\ - -NODEP_CPP_DIR_C=\ - ".\include\apr.h"\ "$(INTDIR)\dir.obj" : $(SOURCE) $(DEP_CPP_DIR_C) "$(INTDIR)" @@ -819,11 +732,6 @@ ".\include\apr_time.h"\ ".\include\apr_win.h"\ ".\include\apr_winconfig.h"\ - {$(INCLUDE)}"sys\stat.h"\ - {$(INCLUDE)}"sys\types.h"\ - -NODEP_CPP_FILEA=\ - ".\include\apr.h"\ "$(INTDIR)\fileacc.obj" : $(SOURCE) $(DEP_CPP_FILEA) "$(INTDIR)" @@ -866,12 +774,7 @@ ".\include\apr_time.h"\ ".\include\apr_win.h"\ ".\include\apr_winconfig.h"\ - {$(INCLUDE)}"sys\stat.h"\ - {$(INCLUDE)}"sys\types.h"\ -NODEP_CPP_FILED=\ - ".\include\apr.h"\ - "$(INTDIR)\filedup.obj" : $(SOURCE) $(DEP_CPP_FILED) "$(INTDIR)" $(CPP) $(CPP_PROJ) $(SOURCE) @@ -913,11 +816,6 @@ ".\include\apr_time.h"\ ".\include\apr_win.h"\ ".\include\apr_winconfig.h"\ - {$(INCLUDE)}"sys\stat.h"\ - {$(INCLUDE)}"sys\types.h"\ - -NODEP_CPP_FILES=\ - ".\include\apr.h"\ "$(INTDIR)\filestat.obj" : $(SOURCE) $(DEP_CPP_FILES) "$(INTDIR)" @@ -957,10 +855,6 @@ ".\include\apr_time.h"\ ".\include\apr_win.h"\ ".\misc\win32\misc.h"\ - {$(INCLUDE)}"sys\types.h"\ - -NODEP_CPP_GETOP=\ - ".\include\apr.h"\ "$(INTDIR)\getopt.obj" : $(SOURCE) $(DEP_CPP_GETOP) "$(INTDIR)" @@ -1001,11 +895,7 @@ ".\include\apr_time.h"\ ".\include\apr_win.h"\ ".\locks\win32\locks.h"\ - {$(INCLUDE)}"sys\types.h"\ -NODEP_CPP_LOCKS=\ - ".\include\apr.h"\ - "$(INTDIR)\locks.obj" : $(SOURCE) $(DEP_CPP_LOCKS) "$(INTDIR)" $(CPP) $(CPP_PROJ) $(SOURCE) @@ -1046,11 +936,6 @@ ".\include\apr_time.h"\ ".\include\apr_win.h"\ ".\include\apr_winconfig.h"\ - {$(INCLUDE)}"sys\stat.h"\ - {$(INCLUDE)}"sys\types.h"\ - -NODEP_CPP_NAMES=\ - ".\include\apr.h"\ "$(INTDIR)\names.obj" : $(SOURCE) $(DEP_CPP_NAMES) "$(INTDIR)" @@ -1094,11 +979,6 @@ ".\include\apr_time.h"\ ".\include\apr_win.h"\ ".\include\apr_winconfig.h"\ - {$(INCLUDE)}"sys\stat.h"\ - {$(INCLUDE)}"sys\types.h"\ - -NODEP_CPP_OPEN_=\ - ".\include\apr.h"\ "$(INTDIR)\open.obj" : $(SOURCE) $(DEP_CPP_OPEN_) "$(INTDIR)" @@ -1144,12 +1024,7 @@ ".\include\apr_time.h"\ ".\include\apr_win.h"\ ".\include\apr_winconfig.h"\ - {$(INCLUDE)}"sys\stat.h"\ - {$(INCLUDE)}"sys\types.h"\ -NODEP_CPP_PIPE_=\ - ".\include\apr.h"\ - "$(INTDIR)\pipe.obj" : $(SOURCE) $(DEP_CPP_PIPE_) "$(INTDIR)" $(CPP) $(CPP_PROJ) $(SOURCE) @@ -1190,10 +1065,6 @@ ".\include\apr_time.h"\ ".\include\apr_win.h"\ ".\network_io\win32\networkio.h"\ - {$(INCLUDE)}"sys\types.h"\ - -NODEP_CPP_POLL_=\ - ".\include\apr.h"\ "$(INTDIR)\poll.obj" : $(SOURCE) $(DEP_CPP_POLL_) "$(INTDIR)" @@ -1239,12 +1110,7 @@ ".\include\apr_win.h"\ ".\include\apr_winconfig.h"\ ".\threadproc\win32\threadproc.h"\ - {$(INCLUDE)}"sys\stat.h"\ - {$(INCLUDE)}"sys\types.h"\ -NODEP_CPP_PROC_=\ - ".\include\apr.h"\ - "$(INTDIR)\proc.obj" : $(SOURCE) $(DEP_CPP_PROC_) "$(INTDIR)" $(CPP) $(CPP_PROJ) $(SOURCE) @@ -1276,30 +1142,14 @@ !ENDIF SOURCE=.\file_io\win32\readdir.c - -!IF "$(CFG)" == "aprlib - Win32 Release" - DEP_CPP_READD=\ ".\file_io\win32\readdir.h"\ - {$(INCLUDE)}"sys\types.h"\ "$(INTDIR)\readdir.obj" : $(SOURCE) $(DEP_CPP_READD) "$(INTDIR)" $(CPP) $(CPP_PROJ) $(SOURCE) -!ELSEIF "$(CFG)" == "aprlib - Win32 Debug" - -DEP_CPP_READD=\ - ".\file_io\win32\readdir.h"\ - - -"$(INTDIR)\readdir.obj" : $(SOURCE) $(DEP_CPP_READD) "$(INTDIR)" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -!ENDIF - SOURCE=.\file_io\win32\readwrite.c !IF "$(CFG)" == "aprlib - Win32 Release" @@ -1315,11 +1165,6 @@ ".\include\apr_time.h"\ ".\include\apr_win.h"\ ".\include\apr_winconfig.h"\ - {$(INCLUDE)}"sys\stat.h"\ - {$(INCLUDE)}"sys\types.h"\ - -NODEP_CPP_READW=\ - ".\include\apr.h"\ "$(INTDIR)\readwrite.obj" : $(SOURCE) $(DEP_CPP_READW) "$(INTDIR)" @@ -1362,12 +1207,7 @@ ".\include\apr_time.h"\ ".\include\apr_win.h"\ ".\include\apr_winconfig.h"\ - {$(INCLUDE)}"sys\stat.h"\ - {$(INCLUDE)}"sys\types.h"\ -NODEP_CPP_SEEK_=\ - ".\include\apr.h"\ - "$(INTDIR)\seek.obj" : $(SOURCE) $(DEP_CPP_SEEK_) "$(INTDIR)" $(CPP) $(CPP_PROJ) $(SOURCE) @@ -1408,10 +1248,6 @@ ".\include\apr_time.h"\ ".\include\apr_win.h"\ ".\network_io\win32\networkio.h"\ - {$(INCLUDE)}"sys\types.h"\ - -NODEP_CPP_SENDR=\ - ".\include\apr.h"\ "$(INTDIR)\sendrecv.obj" : $(SOURCE) $(DEP_CPP_SENDR) "$(INTDIR)" @@ -1421,14 +1257,17 @@ !ELSEIF "$(CFG)" == "aprlib - Win32 Debug" DEP_CPP_SENDR=\ + ".\file_io\win32\fileio.h"\ ".\include\apr_errno.h"\ ".\include\apr_file_io.h"\ ".\include\apr_general.h"\ ".\include\apr_lib.h"\ ".\include\apr_network_io.h"\ + ".\include\apr_pools.h"\ ".\include\apr_thread_proc.h"\ ".\include\apr_time.h"\ ".\include\apr_win.h"\ + ".\include\apr_winconfig.h"\ ".\network_io\win32\networkio.h"\ @@ -1454,12 +1293,7 @@ ".\include\apr_win.h"\ ".\include\apr_winconfig.h"\ ".\threadproc\win32\threadproc.h"\ - {$(INCLUDE)}"sys\stat.h"\ - {$(INCLUDE)}"sys\types.h"\ -NODEP_CPP_SIGNA=\ - ".\include\apr.h"\ - "$(INTDIR)\signals.obj" : $(SOURCE) $(DEP_CPP_SIGNA) "$(INTDIR)" $(CPP) $(CPP_PROJ) $(SOURCE) @@ -1501,10 +1335,6 @@ ".\include\apr_time.h"\ ".\include\apr_win.h"\ ".\network_io\win32\networkio.h"\ - {$(INCLUDE)}"sys\types.h"\ - -NODEP_CPP_SOCKA=\ - ".\include\apr.h"\ "$(INTDIR)\sockaddr.obj" : $(SOURCE) $(DEP_CPP_SOCKA) "$(INTDIR)" @@ -1547,10 +1377,6 @@ ".\include\apr_time.h"\ ".\include\apr_win.h"\ ".\network_io\win32\networkio.h"\ - {$(INCLUDE)}"sys\types.h"\ - -NODEP_CPP_SOCKE=\ - ".\include\apr.h"\ "$(INTDIR)\sockets.obj" : $(SOURCE) $(DEP_CPP_SOCKE) "$(INTDIR)" @@ -1593,11 +1419,7 @@ ".\include\apr_time.h"\ ".\include\apr_win.h"\ ".\network_io\win32\networkio.h"\ - {$(INCLUDE)}"sys\types.h"\ -NODEP_CPP_SOCKO=\ - ".\include\apr.h"\ - "$(INTDIR)\sockopt.obj" : $(SOURCE) $(DEP_CPP_SOCKO) "$(INTDIR)" $(CPP) $(CPP_PROJ) $(SOURCE) @@ -1639,10 +1461,6 @@ ".\include\apr_win.h"\ ".\include\apr_winconfig.h"\ ".\misc\win32\misc.h"\ - {$(INCLUDE)}"sys\types.h"\ - -NODEP_CPP_START=\ - ".\include\apr.h"\ "$(INTDIR)\start.obj" : $(SOURCE) $(DEP_CPP_START) "$(INTDIR)" @@ -1688,11 +1506,7 @@ ".\include\apr_win.h"\ ".\include\apr_winconfig.h"\ ".\threadproc\win32\threadproc.h"\ - {$(INCLUDE)}"sys\types.h"\ -NODEP_CPP_THREA=\ - ".\include\apr.h"\ - "$(INTDIR)\thread.obj" : $(SOURCE) $(DEP_CPP_THREA) "$(INTDIR)" $(CPP) $(CPP_PROJ) $(SOURCE) @@ -1733,10 +1547,6 @@ ".\include\apr_time.h"\ ".\include\apr_win.h"\ ".\threadproc\win32\threadproc.h"\ - {$(INCLUDE)}"sys\types.h"\ - -NODEP_CPP_THREAD=\ - ".\include\apr.h"\ "$(INTDIR)\threadcancel.obj" : $(SOURCE) $(DEP_CPP_THREAD) "$(INTDIR)" @@ -1777,10 +1587,6 @@ ".\include\apr_time.h"\ ".\include\apr_win.h"\ ".\threadproc\win32\threadproc.h"\ - {$(INCLUDE)}"sys\types.h"\ - -NODEP_CPP_THREADP=\ - ".\include\apr.h"\ "$(INTDIR)\threadpriv.obj" : $(SOURCE) $(DEP_CPP_THREADP) "$(INTDIR)" @@ -1826,11 +1632,7 @@ ".\include\apr_win.h"\ ".\include\apr_winconfig.h"\ ".\time\win32\atime.h"\ - {$(INCLUDE)}"sys\types.h"\ -NODEP_CPP_TIME_=\ - ".\include\apr.h"\ - "$(INTDIR)\time.obj" : $(SOURCE) $(DEP_CPP_TIME_) "$(INTDIR)" $(CPP) $(CPP_PROJ) $(SOURCE) @@ -1875,10 +1677,6 @@ ".\include\apr_win.h"\ ".\include\apr_winconfig.h"\ ".\time\win32\atime.h"\ - {$(INCLUDE)}"sys\types.h"\ - -NODEP_CPP_TIMES=\ - ".\include\apr.h"\ "$(INTDIR)\timestr.obj" : $(SOURCE) $(DEP_CPP_TIMES) "$(INTDIR)" 1.7 +2 -2 apache-2.0/src/lib/apr/aprlib.dsp Index: aprlib.dsp =================================================================== RCS file: /home/cvs/apache-2.0/src/lib/apr/aprlib.dsp,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- aprlib.dsp 2000/01/17 23:16:00 1.6 +++ aprlib.dsp 2000/01/24 20:58:15 1.7 @@ -52,7 +52,7 @@ # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /machine:I386 -# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ws2_32.lib /nologo /subsystem:windows /dll /machine:I386 +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ws2_32.lib mswsock.lib /nologo /subsystem:windows /dll /machine:I386 !ELSEIF "$(CFG)" == "aprlib - Win32 Debug" @@ -78,7 +78,7 @@ # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /debug /machine:I386 /pdbtype:sept -# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ws2_32.lib /nologo /subsystem:windows /dll /debug /machine:I386 /pdbtype:sept +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ws2_32.lib mswsock.lib /nologo /subsystem:windows /dll /debug /machine:I386 /pdbtype:sept !ENDIF 1.4 +45 -8 apache-2.0/src/lib/apr/network_io/win32/sendrecv.c Index: sendrecv.c =================================================================== RCS file: /home/cvs/apache-2.0/src/lib/apr/network_io/win32/sendrecv.c,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- sendrecv.c 2000/01/24 04:11:10 1.3 +++ sendrecv.c 2000/01/24 20:58:20 1.4 @@ -60,6 +60,7 @@ #include "apr_general.h" #include "apr_network_io.h" #include "apr_lib.h" +#include "fileio.h" #include <time.h> ap_status_t ap_send(struct socket_t *sock, const char *buf, ap_ssize_t *len) @@ -194,13 +195,13 @@ ap_int32_t flags) { ap_ssize_t rv; - int rv; - int lasterror; + OVERLAPPED Overlapped, *pOverlapped; + TRANSMIT_FILE_BUFFERS TFBuffs, *pTFBuffs; + int i, lasterror, ptr = 0; int timeout = sock->timeout * 1000; /* Need timeout in milliseconds */ - HANDLE nfd; DWORD dwFlags = 0; - - ap_get_os_file(&nfd, file); + size_t headerlen = 0, trailerlen = 0; + void *headerbuf, *trailerbuf; rv = setsockopt(sock->sock, SOL_SOCKET, SO_SNDTIMEO, (char*) &timeout, sizeof(timeout)); @@ -212,18 +213,54 @@ #else dwFlags = 0; // TF_DISCONNECT;TF_WRITE_BEHIND;TF_REUSE_SOCKET; #endif + + /* TransmitFile can only send one header and one footer */ + pTFBuffs = NULL; + memset(&TFBuffs, '0', sizeof (TFBuffs)); + if (hdtr->numheaders) { + for (i = 0; i < hdtr->numheaders; i++) { + TFBuffs.HeadLength += hdtr->headers[i].iov_len; + } + + TFBuffs.Head = ap_palloc(sock->cntxt, headerlen); /* should this be a malloc? */ + + for (i = 0; i < hdtr->numheaders; i++) { + memcpy(&TFBuffs.Head, hdtr->headers[i].iov_base + ptr, + hdtr->headers[i].iov_len); + ptr += hdtr->headers[i].iov_len; + } + pTFBuffs = &TFBuffs; + } + if (hdtr->numtrailers) { + for (i = 0; i < hdtr->numtrailers; i++) { + TFBuffs.TailLength += hdtr->headers[i].iov_len; + } + + TFBuffs.Tail = ap_palloc(sock->cntxt, trailerlen); /* Should this be a malloc */ + + for (i = 0; i < hdtr->numtrailers; i++) { + memcpy(&TFBuffs.Tail, hdtr->trailers[i].iov_base + ptr, + hdtr->trailers[i].iov_len); + ptr += hdtr->trailers[i].iov_len; + } + + pTFBuffs = &TFBuffs; + } + +// memset(&overlapped,'0', sizeof(overlapped)); rv = TransmitFile(sock->sock, /* socket */ - nfd, /* open file descriptor of the file to be sent */ - filelen, /* number of bytes to send. 0==> send all */ + file->filehand, /* open file descriptor of the file to be sent */ + *len, /* number of bytes to send. 0==> send all */ 0, /* Number of bytes per send. 0=> use default */ NULL, /* OVERLAPPED structure */ - NULL, /* header and trailer buffers */ + pTFBuffs, /* header and trailer buffers */ dwFlags); /* flags to control various aspects of TransmitFIle */ if (!rv) { lasterror = WSAGetLastError(); printf("TransmitFile failed with error %d\n", lasterror); return lasterror; } + return APR_SUCCESS; } #endif