You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@apr.apache.org by Mladen Turk <mt...@apache.org> on 2003/03/31 17:52:29 UTC

[PATCH] WIN32 filedup

Hi,

The WIN32 version of apr_file_dup is missing the create_mutex call.
This make duplicated file unusable (the ap segfaults) if opened
with APR_APPEND flag.

Here is the patch:

RCS file: /home/cvspublic/apr/file_io/win32/filedup.c,v
retrieving revision 1.54
diff -u -3 -r1.54 filedup.c
--- filedup.c	7 Jan 2003 00:52:53 -0000	1.54
+++ filedup.c	31 Mar 2003 15:50:27 -0000
@@ -81,7 +81,9 @@
     (*new_file)->fname = apr_pstrdup(p, old_file->fname);
     (*new_file)->append = old_file->append;
     (*new_file)->buffered = FALSE;
-
+    if ((*new_file)->append)
+        apr_thread_mutex_create(&(*new_file)->mutex, 
+                                APR_THREAD_MUTEX_DEFAULT, p); 
     apr_pool_cleanup_register((*new_file)->pool, (void *)(*new_file),
file_cleanup,
                         apr_pool_cleanup_null);
 


MT.


Re: [PATCH] WIN32 filedup

Posted by Jeff Trawick <tr...@attglobal.net>.
Mladen Turk wrote:
> Hi,
> 
> The WIN32 version of apr_file_dup is missing the create_mutex call.
> This make duplicated file unusable (the ap segfaults) if opened
> with APR_APPEND flag.
> 
> Here is the patch:
> 
> RCS file: /home/cvspublic/apr/file_io/win32/filedup.c,v
> retrieving revision 1.54
> diff -u -3 -r1.54 filedup.c
> --- filedup.c	7 Jan 2003 00:52:53 -0000	1.54
> +++ filedup.c	31 Mar 2003 15:50:27 -0000
> @@ -81,7 +81,9 @@
>      (*new_file)->fname = apr_pstrdup(p, old_file->fname);
>      (*new_file)->append = old_file->append;
>      (*new_file)->buffered = FALSE;
> -
> +    if ((*new_file)->append)
> +        apr_thread_mutex_create(&(*new_file)->mutex, 
> +                                APR_THREAD_MUTEX_DEFAULT, p); 

Shouldn't we check retcode of apr_thread_mutex_create() and return a 
failure if it fails?

Two out of three calls surveyed in win32/file_io/*c recommend checking 
the return code.