You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@apr.apache.org by Jeff Trawick <tr...@gmail.com> on 2005/09/27 13:55:14 UTC

Re: svn commit: r291341 - in /apr/apr/branches/0.9.x: CHANGES file_io/unix/dir.c test/testdir.c

On 9/24/05, jorton@apache.org <jo...@apache.org> wrote:

> * test/testdir.c (test_rmkdir_nocwd): Add test case.

==============================================================================
> --- apr/apr/branches/0.9.x/test/testdir.c (original)
> +++ apr/apr/branches/0.9.x/test/testdir.c Sat Sep 24 15:27:18 2005
> @@ -219,6 +219,29 @@
>
>  }
>
> +static void test_rmkdir_nocwd(CuTest *tc)
> +{
> +    char *cwd, *path;
> +
> +    apr_assert_success(tc, "make temp dir",
> +                       apr_dir_make("dir3", APR_OS_DEFAULT, p));
> +
> +    apr_assert_success(tc, "obtain cwd", apr_filepath_get(&cwd, 0, p));
> +
> +    apr_assert_success(tc, "determine path to temp dir",
> +                       apr_filepath_merge(&path, cwd, "dir3", 0, p));
> +
> +    apr_assert_success(tc, "change to temp dir", apr_filepath_set(path, p));
> +
> +    apr_assert_success(tc, "remove temp dir", apr_dir_remove(path, p));

This chdir && rmdir operation fails with EBUSY on AIX and HP-UX.  (I
see it work on Linux; haven't tested other boxes.)  Is there another
way to accomplish the test?

Re: svn commit: r291341 - in /apr/apr/branches/0.9.x: CHANGES file_io/unix/dir.c test/testdir.c

Posted by Jeff Trawick <tr...@gmail.com>.
On 9/27/05, Joe Orton <jo...@redhat.com> wrote:
> On Tue, Sep 27, 2005 at 01:49:29PM +0100, Joe Orton wrote:
> > On Tue, Sep 27, 2005 at 07:55:14AM -0400, Jeff Trawick wrote:
> > > This chdir && rmdir operation fails with EBUSY on AIX and HP-UX.  (I
> > > see it work on Linux; haven't tested other boxes.)  Is there another
> > > way to accomplish the test?
>
> Can you test whether the trunk code handles this OK?  If so I'll
> backport it everywhere.

I backported* it to 0.9.7 on AIX and the test completes fine now.

*
224a225
>     apr_status_t rv;
236c237,243
<     apr_assert_success(tc, "remove temp dir", apr_dir_remove(path, p));
---
>     rv = apr_dir_remove(path, p);
>     /* Some platforms cannot remove a directory which is in use. */
>     if (rv == APR_SUCCESS) {
>         CuAssert(tc, "fail to create dir",
>                  apr_dir_make_recursive("foobar", APR_OS_DEFAULT,
>                                         p) != APR_SUCCESS);
>     }
238,241d244
<     CuAssert(tc, "fail to create dir",
<              apr_dir_make_recursive("foobar", APR_OS_DEFAULT,
<                                     p) != APR_SUCCESS);
<
242a246,249
>
>     if (rv) {
>         apr_dir_remove(path, p);
>     }

Re: svn commit: r291341 - in /apr/apr/branches/0.9.x: CHANGES file_io/unix/dir.c test/testdir.c

Posted by Jeff Trawick <tr...@gmail.com>.
On 9/27/05, Jeff Trawick <tr...@gmail.com> wrote:
> On 9/27/05, Joe Orton <jo...@redhat.com> wrote:
> > On Tue, Sep 27, 2005 at 10:48:56AM -0400, Jeff Trawick wrote:
> > > On 9/27/05, Joe Orton <jo...@redhat.com> wrote:
> > > > On Tue, Sep 27, 2005 at 01:49:29PM +0100, Joe Orton wrote:
> > > > > On Tue, Sep 27, 2005 at 07:55:14AM -0400, Jeff Trawick wrote:
> > > > > > This chdir && rmdir operation fails with EBUSY on AIX and HP-UX.  (I
> > > > > > see it work on Linux; haven't tested other boxes.)  Is there another
> > > > > > way to accomplish the test?
> > > >
> > > > Can you test whether the trunk code handles this OK?  If so I'll
> > > > backport it everywhere.
> > >
> > > ouch, can't get trunk to build on AIX at the moment*; I'll try to test
> > > the trunk testdir.c change with 0.9.x on AIX later toda
> >
> > Ahhhrrrm, just more stuff I borked :) That is a non-threaded build?  I
> > can see how that is broken.
>
> it is a threaded build; but READDIR_IS_THREAD_SAFE is defined
>
> whether or not we actually use readdir64() needs to be separated from
> whether or not the function is defined

I see you just committed something along the same lines ;)  Thanks!

Re: svn commit: r291341 - in /apr/apr/branches/0.9.x: CHANGES file_io/unix/dir.c test/testdir.c

Posted by Jeff Trawick <tr...@gmail.com>.
On 9/27/05, Joe Orton <jo...@redhat.com> wrote:
> On Tue, Sep 27, 2005 at 10:48:56AM -0400, Jeff Trawick wrote:
> > On 9/27/05, Joe Orton <jo...@redhat.com> wrote:
> > > On Tue, Sep 27, 2005 at 01:49:29PM +0100, Joe Orton wrote:
> > > > On Tue, Sep 27, 2005 at 07:55:14AM -0400, Jeff Trawick wrote:
> > > > > This chdir && rmdir operation fails with EBUSY on AIX and HP-UX.  (I
> > > > > see it work on Linux; haven't tested other boxes.)  Is there another
> > > > > way to accomplish the test?
> > >
> > > Can you test whether the trunk code handles this OK?  If so I'll
> > > backport it everywhere.
> >
> > ouch, can't get trunk to build on AIX at the moment*; I'll try to test
> > the trunk testdir.c change with 0.9.x on AIX later toda
>
> Ahhhrrrm, just more stuff I borked :) That is a non-threaded build?  I
> can see how that is broken.

it is a threaded build; but READDIR_IS_THREAD_SAFE is defined

whether or not we actually use readdir64() needs to be separated from
whether or not the function is defined

some of the usage of readdir64 (e.g., in struct apr_dir_t) is based on
simply whether or not the function exists

other usage (such as actually calling it) is based on this combination:

#if APR_HAS_THREADS && defined(_POSIX_THREAD_SAFE_FUNCTIONS) \
                    && !defined(READDIR_IS_THREAD_SAFE)
#ifdef HAVE_READDIR64_R

quick hack:

#if APR_HAS_THREADS && defined(_POSIX_THREAD_SAFE_FUNCTIONS) \
                    && !defined(READDIR_IS_THREAD_SAFE) \
                    && defined(HAVE_READDIR64_R)
#define USE_READDIR64_R 1
#else
#define USE_READDIR64_R 0
#endif

struct apr_dir_t {
    apr_pool_t *pool;
    char *dirname;
    DIR *dirstruct;
#if USE_READDIR64_r
    struct dirent64 *entry;
#else
    struct dirent *entry;
#endif
};

then check USE_READDIR64_R in dir.c

Re: svn commit: r291341 - in /apr/apr/branches/0.9.x: CHANGES file_io/unix/dir.c test/testdir.c

Posted by Joe Orton <jo...@redhat.com>.
On Tue, Sep 27, 2005 at 10:48:56AM -0400, Jeff Trawick wrote:
> On 9/27/05, Joe Orton <jo...@redhat.com> wrote:
> > On Tue, Sep 27, 2005 at 01:49:29PM +0100, Joe Orton wrote:
> > > On Tue, Sep 27, 2005 at 07:55:14AM -0400, Jeff Trawick wrote:
> > > > This chdir && rmdir operation fails with EBUSY on AIX and HP-UX.  (I
> > > > see it work on Linux; haven't tested other boxes.)  Is there another
> > > > way to accomplish the test?
> >
> > Can you test whether the trunk code handles this OK?  If so I'll
> > backport it everywhere.
> 
> ouch, can't get trunk to build on AIX at the moment*; I'll try to test
> the trunk testdir.c change with 0.9.x on AIX later toda

Ahhhrrrm, just more stuff I borked :) That is a non-threaded build?  I 
can see how that is broken.

> 
> *
> "file_io/unix/dir.c", line 186.19: 1506-068 (E) Operation between
> types "struct dirent64*" and "struct dirent*" is not allowed.
> "file_io/unix/dir.c", line 216.41: 1506-045 (S) Undeclared identifier retent.

Re: svn commit: r291341 - in /apr/apr/branches/0.9.x: CHANGES file_io/unix/dir.c test/testdir.c

Posted by Jeff Trawick <tr...@gmail.com>.
On 9/27/05, Joe Orton <jo...@redhat.com> wrote:
> On Tue, Sep 27, 2005 at 01:49:29PM +0100, Joe Orton wrote:
> > On Tue, Sep 27, 2005 at 07:55:14AM -0400, Jeff Trawick wrote:
> > > This chdir && rmdir operation fails with EBUSY on AIX and HP-UX.  (I
> > > see it work on Linux; haven't tested other boxes.)  Is there another
> > > way to accomplish the test?
>
> Can you test whether the trunk code handles this OK?  If so I'll
> backport it everywhere.

ouch, can't get trunk to build on AIX at the moment*; I'll try to test
the trunk testdir.c change with 0.9.x on AIX later toda

*
"file_io/unix/dir.c", line 186.19: 1506-068 (E) Operation between
types "struct dirent64*" and "struct dirent*" is not allowed.
"file_io/unix/dir.c", line 216.41: 1506-045 (S) Undeclared identifier retent.

Re: svn commit: r291341 - in /apr/apr/branches/0.9.x: CHANGES file_io/unix/dir.c test/testdir.c

Posted by Joe Orton <jo...@redhat.com>.
On Tue, Sep 27, 2005 at 01:49:29PM +0100, Joe Orton wrote:
> On Tue, Sep 27, 2005 at 07:55:14AM -0400, Jeff Trawick wrote:
> > This chdir && rmdir operation fails with EBUSY on AIX and HP-UX.  (I
> > see it work on Linux; haven't tested other boxes.)  Is there another
> > way to accomplish the test?

Can you test whether the trunk code handles this OK?  If so I'll 
backport it everywhere.

joe

Re: svn commit: r291341 - in /apr/apr/branches/0.9.x: CHANGES file_io/unix/dir.c test/testdir.c

Posted by Joe Orton <jo...@redhat.com>.
On Tue, Sep 27, 2005 at 07:55:14AM -0400, Jeff Trawick wrote:
> On 9/24/05, jorton@apache.org <jo...@apache.org> wrote:
> 
> > * test/testdir.c (test_rmkdir_nocwd): Add test case.
> 
> ==============================================================================
> > --- apr/apr/branches/0.9.x/test/testdir.c (original)
> > +++ apr/apr/branches/0.9.x/test/testdir.c Sat Sep 24 15:27:18 2005
> > @@ -219,6 +219,29 @@
> >
> >  }
> >
> > +static void test_rmkdir_nocwd(CuTest *tc)
> > +{
> > +    char *cwd, *path;
> > +
> > +    apr_assert_success(tc, "make temp dir",
> > +                       apr_dir_make("dir3", APR_OS_DEFAULT, p));
> > +
> > +    apr_assert_success(tc, "obtain cwd", apr_filepath_get(&cwd, 0, p));
> > +
> > +    apr_assert_success(tc, "determine path to temp dir",
> > +                       apr_filepath_merge(&path, cwd, "dir3", 0, p));
> > +
> > +    apr_assert_success(tc, "change to temp dir", apr_filepath_set(path, p));
> > +
> > +    apr_assert_success(tc, "remove temp dir", apr_dir_remove(path, p));
> 
> This chdir && rmdir operation fails with EBUSY on AIX and HP-UX.  (I
> see it work on Linux; haven't tested other boxes.)  Is there another
> way to accomplish the test?

Ah, I wondered whether that might happen.  No, not really - such 
platforms probably cannot trigger the bug; I'll adjust the test to skip 
if the rmdir fails.

Regards,

joe