httpd-apreq-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Randy Kobes <ra...@theoryx5.uwinnipeg.ca>
Subject Re: [apreq-2] $upload->tempname on Win32
Date Sat, 03 Jul 2004 22:51:21 GMT
On Sat, 3 Jul 2004, Joe Schaefer wrote:

> Joe Schaefer <joe+gmane@sunstarsys.com> writes:
>
> > Joe Schaefer <joe+gmane@sunstarsys.com> writes:
> >
> > [...]
> >
> > > Do you know which file in apr I should be looking at?
> >
> > Never mind, I found it- the relevant files are
> > apr/apr_file_io/unix/mktemp.c and apr/apr_file_io/win32/open.c.
> >
> > According to msdn FILE_FLAG_DELETE_ON_CLOSE requires
> > FILE_SHARE_DELETE to permit reopening the file.  It looks
> > like that's being added at line 227 in open.c:
> >
> >     if (apr_os_level >= APR_WIN_NT)
> >         sharemode |= FILE_SHARE_DELETE;
> >
> > Not sure if this conditional is being satisfied, you
> > might want to start by double-checking it.
>
> Assuming apr is doing this correctly, is there
> a way to open the file in Perl with FILE_SHARE_DELETE
> set?  It could be that the test script's attempt
> to reopen the tempfile fails because Perl's open()
> isn't passing this flag to the underlying system call.
>
> Otherwise I think we should just document this issue
> and xfail some portion of the tempname tests on Win32.

Thanks, Joe - that looks exactly what's happening.  There is
a Win32 module that gives access to FILE_SHARE_DELETE, but
based upon your tracking things down, I think things stay
consistent if we let apr handle things as much as possible.
So I tried, at least for this test, to use APR::PerlIO to
handle the opening:
===================================================
Index: t/response/TestApreq/request.pm
===================================================================
RCS file: /home/cvs/httpd-apreq-2/glue/perl/t/response/TestApReq/request.pm,v
retrieving revision 1.17
diff -u -r1.17 request.pm
--- t/response/TestApreq/request.pm	2 Jul 2004 20:50:16 -0000	1.17
+++ t/response/TestApreq/request.pm	3 Jul 2004 22:39:09 -0000
@@ -8,6 +8,10 @@
 use Apache::Request ();
 use Apache::Connection;
 use Apache::Upload;
+use APR::Pool;
+use APR::PerlIO;
+
+my $p = APR::Pool->new();

 sub handler {
     my $r = shift;
@@ -62,7 +66,7 @@
     }
     elsif ($test eq 'tempname') {
         my $upload = $req->upload("HTTPUPLOAD");
-        open my $fh, "<", $upload->tempname or die $!;
+        open my $fh, "<:APR", $upload->tempname, $p or die $!;
         $r->print(<$fh>);
     }
     elsif ($test eq 'bad') {

================================================================
With this, all the glue/perl/t/apreq/request tests pass for
me (without any tweaking of \r\n issues I had before). We
may not want to change the test to do this (but rather, just
skip it for Win32), but in any case, there does seem to be a
well-defined way to manipulate $upload->tempname on Win32.
Great work!

-- 
best regards,
randy

Mime
View raw message