stoddard 00/02/14 16:15:49
Modified: src/lib/apr/file_io/win32 filedup.c open.c pipe.c Log: Fix some Windows APR problems found while trying to get piped logs working. Revision Changes Path 1.5 +19 -6 apache-2.0/src/lib/apr/file_io/win32/filedup.c Index: filedup.c =================================================================== RCS file: /home/cvs/apache-2.0/src/lib/apr/file_io/win32/filedup.c,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- filedup.c 1999/12/15 18:06:31 1.4 +++ filedup.c 2000/02/15 00:15:42 1.5 @@ -61,16 +61,29 @@ ap_status_t ap_dupfile(struct file_t **new_file, struct file_t *old_file) { + int have_file = 0; HANDLE hCurrentProcess = GetCurrentProcess(); - (*new_file) = (struct file_t *)ap_palloc(old_file->cntxt, - sizeof(struct file_t)); - + if ((*new_file) == NULL) { - return APR_ENOMEM; + (*new_file) = (struct file_t *)ap_pcalloc(old_file->cntxt, + sizeof(struct file_t)); + if ((*new_file) == NULL) { + return APR_ENOMEM; + } + } else { + have_file = 1; } + (*new_file)->cntxt = old_file->cntxt; - DuplicateHandle(hCurrentProcess, old_file->filehand, hCurrentProcess, - &(*new_file)->filehand, 0, FALSE, DUPLICATE_SAME_ACCESS); + if (have_file) { + DuplicateHandle(hCurrentProcess, (*new_file)->filehand, hCurrentProcess, + &old_file->filehand, 0, FALSE, DUPLICATE_SAME_ACCESS); + } + else { + DuplicateHandle(hCurrentProcess, old_file->filehand, hCurrentProcess, + &(*new_file)->filehand, 0, FALSE, DUPLICATE_SAME_ACCESS); + } + (*new_file)->fname = ap_pstrdup(old_file->cntxt, old_file->fname); (*new_file)->demonfname = ap_pstrdup(old_file->cntxt, old_file->demonfname); (*new_file)->lowerdemonfname = ap_pstrdup(old_file->cntxt, old_file->lowerdemonfname); 1.18 +1 -3 apache-2.0/src/lib/apr/file_io/win32/open.c Index: open.c =================================================================== RCS file: /home/cvs/apache-2.0/src/lib/apr/file_io/win32/open.c,v retrieving revision 1.17 retrieving revision 1.18 diff -u -r1.17 -r1.18 --- open.c 2000/02/01 00:35:58 1.17 +++ open.c 2000/02/15 00:15:44 1.18 @@ -80,8 +80,6 @@ { DWORD oflags = 0; DWORD createflags = 0; - DWORD theerror; - /*mode_t mode = get_fileperms(perm);*/ (*dafile) = (struct file_t *)ap_palloc(cont, sizeof(struct file_t)); @@ -206,7 +204,7 @@ if ((*thefile) == NULL) { return APR_ENOMEM; } - + memset(*thefile, '\0', sizeof(struct file_t)); (*thefile)->filehand = GetStdHandle(STD_ERROR_HANDLE); (*thefile)->cntxt = cont; (*thefile)->fname = NULL; 1.4 +2 -0 apache-2.0/src/lib/apr/file_io/win32/pipe.c Index: pipe.c =================================================================== RCS file: /home/cvs/apache-2.0/src/lib/apr/file_io/win32/pipe.c,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- pipe.c 1999/10/06 23:03:54 1.3 +++ pipe.c 2000/02/15 00:15:45 1.4 @@ -72,10 +72,12 @@ sa.lpSecurityDescriptor = NULL; (*in) = (struct file_t *)ap_palloc(cont, sizeof(struct file_t)); + memset(*in, '\0', sizeof(struct file_t)); (*in)->cntxt = cont; (*in)->fname = ap_pstrdup(cont, "PIPE"); (*out) = (struct file_t *)ap_palloc(cont, sizeof(struct file_t)); + memset(*out, '\0', sizeof(struct file_t)); (*out)->cntxt = cont; (*out)->fname = ap_pstrdup(cont, "PIPE");