1
/* Copyright (c) 2008 PrimeBase Technologies GmbH, Germany
3
* PrimeBase Media Stream for MySQL
5
* This program is free software; you can redistribute it and/or modify
6
* it under the terms of the GNU General Public License as published by
7
* the Free Software Foundation; either version 2 of the License, or
8
* (at your option) any later version.
10
* This program is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
* GNU General Public License for more details.
15
* You should have received a copy of the GNU General Public License
16
* along with this program; if not, write to the Free Software
17
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19
* Original author: Paul McCullagh
20
* Continued development: Barry Leslie
28
* Temporary BLOBs are BLOBs that are to be deleted after an certain
31
* The temporary log is also used to schedule asynchronous operations to be performed
32
* on the BLOB such as uploading it to a cloud.
34
* Temporary BLOBs are referenced by the temporary log.
37
#ifndef __TEMPLOG_MS_H__
38
#define __TEMPLOG_MS_H__
52
// Changed MS_TEMP_LOG_MAGIC and MS_TEMP_LOG_VERSION
53
// when the disk size of ti_type_1 was changed from
54
// CSDiskValue4 to CSDiskValue1.
56
#define MS_TEMP_LOG_MAGIC 0xF9E6D7C9
57
#define MS_TEMP_LOG_VERSION 3
58
#define MS_TEMP_LOG_HEAD_SIZE 32
60
#define MS_TL_BLOB_REF 1
61
#define MS_TL_REPO_REF 2
62
#define MS_TL_TABLE_REF 3
64
typedef struct MSTempLogHead {
65
CSDiskValue4 th_magic_4; /* Table magic number. */
66
CSDiskValue2 th_version_2; /* The header version. */
67
CSDiskValue2 th_head_size_2; /* The size of the header. */
68
CSDiskValue2 th_rec_size_2; /* The size of a temp log record. */
69
CSDiskValue4 th_reserved_4;
70
} MSTempLogHeadRec, *MSTempLogHeadPtr;
72
typedef struct MSTempLogItem {
73
CSDiskValue1 ti_type_1; /* 1 = BLOB reference, 2 = Repository reference, 3 = Table reference */
74
CSDiskValue4 ti_table_id_4; /* Table ID (non-zero if valid). */
75
CSDiskValue6 ti_blob_id_6; /* Blob ID (non-zero if valid). */
76
CSDiskValue4 ti_auth_code_4; /* To make sure we do not delete the wrong thing. */
77
CSDiskValue4 ti_time_4; /* The time of deletion/creation */
78
} MSTempLogItemRec, *MSTempLogItemPtr;
80
class MSTempLogFile : public CSReadBufferedFile {
88
friend class MSTempLog;
91
static MSTempLogFile *newTempLogFile(u_int id, MSTempLog *temp_log, CSFile *path);
94
class MSTempLog : public CSRefObject {
99
size_t myTempLogHeadSize;
101
MSTempLog(u_int id, MSDatabase *db, off_t file_size);
102
virtual ~MSTempLog();
105
CSPath *getLogPath();
106
MSTempLogFile *openTempLog();
109
// virtual void retain() {
110
// CSRefObject::retain();
111
// printf("MSTempLog retained %d\n", iRefCount);
114
// virtual void release() {
115
// printf("MSTempLog released %d\n", iRefCount);
116
// CSRefObject::release();
120
friend class MSTempLogThread;
123
MSDatabase *iLogDatabase;
127
static u_long gTempBlobTimeout;
129
static time_t adjustWaitTime(time_t then, time_t now);
132
class MSTempLogThread : public CSDaemon {
134
MSTempLogThread(time_t wait_time, MSDatabase *db);
135
virtual ~MSTempLogThread();
139
virtual bool doWork();
141
virtual void *finalize();
144
MSDatabase *iTempLogDatabase;
145
MSTempLogFile *iTempLogFile;