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

tmpfile callback problems.

From: Ben Collins-Sussman <sussman_at_collab.net>
Date: 2001-09-18 23:08:33 CEST

So I'm trying to modify ra_dav to use the new callback for creating
and destroying tmpfiles (in SVN/tmp/)

The callbacks vtable looks like:

typedef struct svn_ra_callbacks_t
{
  /* Open a unique temporary file for writing in the working copy.
     This file will be automatically deleted when FP is closed.
     The full path to the file is returned in *FILENAME. */
  svn_error_t *(*open_tmp_file) (apr_file_t **fp,
                                 svn_stringbuf_t **filename,
                                 void *callback_baton);
  
  /* Retrieve an AUTHENTICATOR/AUTH_BATON pair from the client,
     which represents the protocol METHOD. */
  svn_error_t *(*get_authenticator) (void **authenticator,
                                     void **auth_baton,
                                     apr_uint64_t method,
                                     void *callback_baton,
                                     apr_pool_t *pool);

} svn_ra_callbacks_t;

Notice that instead of a delete_tmp_file() callback, open_tmp_file
simply adds the APR_DELONCLOSE flag. So calling apr_file_close(fp) is
all ra_dav needs to do. (open_tmp_file also calls the thread-safe
svn_io_open_unique_file() under the hood, so ra_dav doesn't have to
anymore.)

So now I discover ickiness... apparently in both the commit and update
cases, ra_dav needs to hand a vanilla "FILE *" version of the tmpfile
to neon; an apr_file_t won't do. So ra_dav closes the apr_file_t,
then fopen()/fclose()'s the file for neon.

Being ignorant, I say, "this is bad, because of delete-on-close". So
I move the apr_file_close() -after- all the fopen/fclose business (for
example, I do this in commit.c:commit_stream_close).

Still though -- I get a segfault when committing, specifically in
commit_stream_close, because fopen() tries to reopen the tmpfile, and
it's already gone somehow.

gstein or joe, can you give me a clue?

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Sat Oct 21 14:36:41 2006

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