~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/archive/azio.cc

  • Committer: Stewart Smith
  • Date: 2009-10-06 05:50:22 UTC
  • mto: This revision was merged to the branch mainline in revision 1170.
  • Revision ID: stewart@flamingspork.com-20091006055022-uh79cvwppcszr3xk
removeĀ unusedĀ HA_KEYTYPE_BIT

Show diffs side-by-side

added added

removed removed

Lines of Context:
11
11
 
12
12
/* @(#) $Id$ */
13
13
 
14
 
#include "config.h"
15
 
 
16
14
#include "azio.h"
17
15
 
18
 
#include <fcntl.h>
 
16
#include <stdio.h>
 
17
#include <string.h>
 
18
#include <stdlib.h>
 
19
#include <assert.h>
19
20
#include <unistd.h>
20
21
 
21
 
#include <cstdio>
22
 
#include <cstring>
23
 
#include <cstdlib>
24
 
#include <cassert>
25
 
 
26
 
using namespace drizzled;
27
 
 
28
22
static int const az_magic[3] = {0xfe, 0x03, 0x01}; /* az magic header */
29
23
 
30
24
static unsigned int azwrite(azio_stream *s, void *buf, unsigned int len);
43
37
static void do_aio_cleanup(azio_stream *s);
44
38
#endif
45
39
 
46
 
extern "C" pthread_handler_t run_task(void *p);
47
 
 
48
 
extern "C" pthread_handler_t run_task(void *p)
 
40
extern "C"
 
41
pthread_handler_t run_task(void *p);
 
42
 
 
43
 
 
44
pthread_handler_t run_task(void *p)
49
45
{
50
46
  int fd;
51
47
  char *buffer;
52
48
  size_t offset;
53
49
  azio_stream *s= (azio_stream *)p;
54
50
 
 
51
  my_thread_init();
 
52
 
55
53
  while (1)
56
54
  {
57
55
    pthread_mutex_lock(&s->container.thresh_mutex);
75
73
    pthread_mutex_unlock(&s->container.thresh_mutex);
76
74
  }
77
75
 
 
76
  my_thread_end();
 
77
 
78
78
  return 0;
79
79
}
80
80
 
159
159
  int err;
160
160
  int level = Z_DEFAULT_COMPRESSION ; /* compression level */
161
161
  int strategy = Z_DEFAULT_STRATEGY; /* compression strategy */
162
 
  int fd= -1;
 
162
  File fd= -1;
163
163
 
164
164
  memset(s, 0, sizeof(azio_stream));
165
165
 
225
225
  s->stream.avail_out = AZ_BUFSIZE_WRITE;
226
226
 
227
227
  errno = 0;
228
 
  s->file = fd < 0 ? internal::my_open(path, Flags, MYF(0)) : fd;
 
228
  s->file = fd < 0 ? my_open(path, Flags, MYF(0)) : fd;
229
229
#ifdef AZIO_AIO
230
230
  s->container.fd= s->file;
231
231
#endif
437
437
    if (s->mode == 'w')
438
438
    {
439
439
      err = deflateEnd(&(s->stream));
440
 
      internal::my_sync(s->file, MYF(0));
 
440
      my_sync(s->file, MYF(0));
441
441
    }
442
442
    else if (s->mode == 'r')
443
443
      err = inflateEnd(&(s->stream));
445
445
 
446
446
  do_aio_cleanup(s);
447
447
 
448
 
  if (s->file > 0 && internal::my_close(s->file, MYF(0)))
 
448
  if (s->file > 0 && my_close(s->file, MYF(0)))
449
449
      err = Z_ERRNO;
450
450
 
451
451
  s->file= -1;
459
459
  Reads the given number of uncompressed bytes from the compressed file.
460
460
  azread returns the number of bytes actually read (0 for end of file).
461
461
*/
462
 
/*
463
 
   This function is legacy, do not use.
464
 
 
465
 
     Reads the given number of uncompressed bytes from the compressed file.
466
 
   If the input file was not in gzip format, gzread copies the given number
467
 
   of bytes into the buffer.
468
 
     gzread returns the number of uncompressed bytes actually read (0 for
469
 
   end of file, -1 for error).
470
 
*/
471
 
static unsigned int azread_internal( azio_stream *s, voidp buf, unsigned int len, int *error)
 
462
unsigned int azread_internal( azio_stream *s, voidp buf, unsigned int len, int *error)
472
463
{
473
464
  Bytef *start = (Bytef*)buf; /* starting point for crc computation */
474
465
  Byte  *next_out; /* == stream.next_out but not forced far (for MSDOS) */
754
745
    err= do_flush(s, flush);
755
746
 
756
747
    if (err) return err;
757
 
    internal::my_sync(s->file, MYF(0));
 
748
    my_sync(s->file, MYF(0));
758
749
    return  s->z_err == Z_STREAM_END ? Z_OK : s->z_err;
759
750
  }
760
751
}
1072
1063
    }
1073
1064
    s->pos+= s->stream.avail_in;
1074
1065
    s->inbuf= (Byte *)s->container.buffer;
1075
 
    /* We only azio_read when we know there is more data to be read */
 
1066
    /* We only aio_read when we know there is more data to be read */
1076
1067
    if (s->pos >= s->check_point)
1077
1068
    {
1078
1069
      s->aio_inited= 0;