~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to mysys/mf_cache.c

  • Committer: Mark Atwood
  • Date: 2008-10-16 11:16:12 UTC
  • mfrom: (520.1.2 drizzle)
  • mto: (520.1.13 drizzle)
  • mto: This revision was merged to the branch mainline in revision 530.
  • Revision ID: mark@fallenpegasus.com-20081016111612-5nei7m5subslx912
mergeĀ fromĀ head

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
#include <mysys/mysys_err.h>
22
22
#include <mysys/iocache.h>
23
23
 
24
 
        /*
25
 
          Remove an open tempfile so that it doesn't survive
26
 
          if we crash;  If the operating system doesn't support
27
 
          this, just remember the file name for later removal
28
 
        */
29
 
 
30
 
static bool cache_remove_open_tmp(IO_CACHE *cache __attribute__((unused)),
31
 
                                     const char *name)
32
 
{
33
 
#if O_TEMPORARY == 0
34
 
#if !defined(CANT_DELETE_OPEN_FILES)
35
 
  /* The following should always succeed */
36
 
  (void) my_delete(name,MYF(MY_WME | ME_NOINPUT));
37
 
#else
38
 
  int length;
39
 
  if (!(cache->file_name=
40
 
        (char*) my_malloc((length=strlen(name)+1),MYF(MY_WME))))
41
 
  {
42
 
    my_close(cache->file,MYF(0));
43
 
    cache->file = -1;
44
 
    errno=my_errno=ENOMEM;
45
 
    return 1;
46
 
  }
47
 
  memcpy(cache->file_name,name,length);
48
 
#endif
49
 
#endif /* O_TEMPORARY == 0 */
50
 
  return 0;
51
 
}
52
24
 
53
25
        /*
54
26
        ** Open tempfile cached by IO_CACHE
83
55
  char name_buff[FN_REFLEN];
84
56
  int error=1;
85
57
  if ((cache->file=create_temp_file(name_buff, cache->dir, cache->prefix,
86
 
                                    (O_RDWR | O_TRUNC |
87
 
                                     O_TEMPORARY | O_SHORT_LIVED),
 
58
                                    (O_RDWR | O_TRUNC),
88
59
                                    MYF(MY_WME))) >= 0)
89
60
  {
90
61
    error=0;
91
 
    cache_remove_open_tmp(cache, name_buff);
 
62
    my_delete(name_buff,MYF(MY_WME | ME_NOINPUT));
92
63
  }
93
64
  return(error);
94
65
}