[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: [PATCH] Duplicate close of file handle on WIN32

From: Branko Čibej <brane_at_xbc.nu>
Date: 2003-02-03 21:13:38 CET

FYI, I fixed this in revision 4713. No more svn_io_fd_from_file...

Patrick Mayweg wrote:

>Hi,
>when a file descriptor is needed for neon the function
>svn_io_fd_from_file is called. On WIN32 it creates a file descriptor
>from the Win32-Handle. It also registers a cleanup function to close the
>
>file descriptor. This also closes the Win32-Handle, which is also closed
>
>for the apr-file. This is one closeing too many. Only if you run svn in
>a debugger, this problem shows up. The right thing to do is to duplicate
>
>the handle. I have written a patch for that and it fixes my problem.
>
>* ./subversion/libsvn_subr/io.c
>
> (svn_io_fd_from_file) Added call to DuplicateHandle
>
>Index: subversion/libsvn_subr/io.c
>===================================================================
>--- subversion/libsvn_subr/io.c (revision 4685)
>+++ subversion/libsvn_subr/io.c (working copy)
>@@ -1674,7 +1674,15 @@
> #ifndef SVN_WIN32
> *fd_p = fd;
> #else
>- *fd_p = _open_osfhandle ((long) fd, _O_RDWR);
>+ apr_os_file_t fd2 = 0;
>+ if (DuplicateHandle (GetCurrentProcess(), fd, GetCurrentProcess(),
>+ (LPHANDLE)&fd2, 0, FALSE,
>+ DUPLICATE_SAME_ACCESS) == FALSE)
>+ {
>+ status = APR_EBADF;
>+ return status;
>+ }
>+ *fd_p = _open_osfhandle ((long) fd2, _O_RDWR);
>
> /* We must close the file descriptor when the apr_file_t is
> closed, otherwise we'll run out of them. What happens if the
>
>
>Regards,
>Patrick Mayweg
>

-- 
Brane Čibej   <brane_at_xbc.nu>   http://www.xbc.nu/brane/
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Mon Feb 3 21:14:40 2003

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.