globus_gass_cache
10.3
Toggle main menu visibility
Loading...
Searching...
No Matches
globus_i_gass_cache.h
1
/*
2
* Copyright 1999-2006 University of Chicago
3
*
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
* you may not use this file except in compliance with the License.
6
* You may obtain a copy of the License at
7
*
8
* http://www.apache.org/licenses/LICENSE-2.0
9
*
10
* Unless required by applicable law or agreed to in writing, software
11
* distributed under the License is distributed on an "AS IS" BASIS,
12
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
* See the License for the specific language governing permissions and
14
* limitations under the License.
15
*/
16
17
#ifndef GLOBUS_DONT_DOCUMENT_INTERNAL
18
23
#include "globus_symboltable.h"
24
25
/* defines the environment variable to be used as default cache dir. */
26
#define GLOBUS_L_GASS_CACHE_DEFAULT_DIR_ENV_VAR "GLOBUS_GASS_CACHE_DEFAULT"
27
#define GLOBUS_L_GASS_CACHE_DEBUG "GLOBUS_GASS_CACHE_DEBUG"
28
29
/* if GLOBUS_L_GASS_CACHE_DEFAULT_DIR_ENV_VAR is not defined in user env. */
30
/* we use $HOME and GLOBUS_L_GASS_CACHE_DEFAULT_DIR_NAME below */
31
/* before V0.9:
32
#define GLOBUS_L_GASS_CACHE_DEFAULT_DIR_NAME "/.globus_gass_cache"
33
*/
34
#define GLOBUS_L_DOT_GLOBUS_DIR_NAME "/.globus"
35
#define GLOBUS_L_GASS_CACHE_DEFAULT_DIR_NAME "/.gass_cache"
36
#define GLOBUS_L_GASS_CACHE_GLOBAL_DIR "global"
37
#define GLOBUS_L_GASS_CACHE_LOCAL_DIR "local"
38
#define GLOBUS_L_GASS_CACHE_TMP_DIR "tmp"
39
#define GLOBUS_L_GASS_CACHE_LOG_DIR "log"
40
41
/* Files are created with 777 and the access restriction is left to umask */
42
#ifdef _WIN32
43
#define GLOBUS_L_GASS_CACHE_MODE_RWX (_S_IRWXU)
44
#define GLOBUS_L_GASS_CACHE_MODE_RW (_S_IRUSR|_S_IWUSR)
45
#else
46
#define GLOBUS_L_GASS_CACHE_MODE_RWX \
47
(S_IRWXU|S_IRWXG|S_IRWXO)
48
#define GLOBUS_L_GASS_CACHE_MODE_RW \
49
(S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH)
50
#endif
51
#define GLOBUS_L_GASS_CACHE_DIR_MODE GLOBUS_L_GASS_CACHE_MODE_RWX
52
#define GLOBUS_L_GASS_CACHE_DATAFILE_MODE GLOBUS_L_GASS_CACHE_MODE_RWX
53
#define GLOBUS_L_GASS_CACHE_UNIQFILE_MODE GLOBUS_L_GASS_CACHE_MODE_RWX
54
#define GLOBUS_L_GASS_CACHE_URLFILE_MODE GLOBUS_L_GASS_CACHE_MODE_RW
55
#define GLOBUS_L_GASS_CACHE_TAGFILE_MODE GLOBUS_L_GASS_CACHE_MODE_RW
56
#define GLOBUS_L_GASS_CACHE_SKEWFILE_MODE GLOBUS_L_GASS_CACHE_MODE_RW
57
58
/* Length of sleep while waiting for ready */
59
#define LOCK_SLEEP_USEC 500000
60
61
/* Special file names */
62
#define DATA_FILE "data"
/* Name of the data file */
63
#define DATA_FILE_PAT "data"
/* Pattern for matching */
64
#define DATA_FILE_PAT_LEN 4
/* It's length */
65
#define UDATA_FILE "data."
/* Uniq data file name */
66
#define UDATA_FILE_PAT "data."
/* Uniq data file pattern */
67
#define UDATA_FILE_PAT_LEN 5
/* Length of it */
68
#define LOCK_FILE "lock"
/* Name of the lock file */
69
#define URL_FILE "url"
/* Name of the URL file */
70
#define TAG_FILE "tag"
/* Name of the tag file */
71
#define UNIQ_NAME_FORMAT "%s_%lx_%lx"
72
#define UNIQ_NAME_MAX (20 + MAXHOSTNAMELEN)
/* Reserved for uniq */
73
/* Largest possible file */
74
#define MAX_FILENAME_LEN ( DATA_FILE_PAT_LEN + UNIQ_NAME_MAX )
75
76
/* Time limits, etc. */
77
#define LOCK_MAX_SECONDS 30
78
#define LOCK_SLEEP_USEC 500000
79
#define NOTREADY_MAX_SECONDS 300
/* mtime age before NR "broken" */
80
#define NOTREADY_CHECK_SECONDS 10
/* Seconds between NR lock checks. */
81
#define SKEWCALC_SECONDS 3600
/* Seconds between skew calcs. */
82
#define EBUSY_SLEEP_USEC 10000
/* Retry delay after EBUSY */
83
84
/*
85
* RedHat 6.2 link seems to return ENOENT sometimes even though it
86
* *does* exist & stat() says so. So, we'll stat() it, and, if it does
87
* exist, sleep a bit & try again. These define how long to wait before
88
* the retry, and how many times we're willing to try before giving up.
89
*/
90
#define LINKBUG_SLEEP_USEC 50000
/* Sleep before trying link() again */
91
#define LINKBUG_MAX_RETRY 100
/* Max times to retry.. */
92
93
/* Various functions will keep trying in several cases, but should
94
eventually give up. This controls how many times to try before
95
that.. */
96
#define MAKE_DIRTREE_MAX_TRIES 100
97
#define UNLINK_MAX_TRIES 20
98
#define CREATE_MAX_TRIES 20
99
100
/* If compilled with LOCK_TOUT defined, the lock will timeout after
101
LOCK_TOUT try to get the lock, if the file to lock is older than
102
LOCK_TOUT*LOOP_TIME
103
104
LOOPTIME is currently define as 50000 (50ms)
105
If I define LOCK_TOUT 600, I will wait until the lock file and temp file
106
are untouched for more than 30s before I break the lock.*/
107
#define LOCK_TOUT 600
108
109
#define GLOBUS_L_GASS_CACHE_NULL_TAG "null"
110
111
112
113
/******************************************************************************
114
macro to trace the code during debug phase and to log the cache activity
115
******************************************************************************/
116
117
#ifdef DEBUG
118
119
#define CACHE_TRACE(_f_)\
120
globus_l_gass_cache_trace(__FILE__,__LINE__, (_f_) )
121
#define CACHE_TRACE2(_f_,_a1_)\
122
globus_l_gass_cache_trace(__FILE__,__LINE__, (_f_),(_a1_) )
123
#define CACHE_TRACE3(_f_,_a1_,_a2_)\
124
globus_l_gass_cache_trace(__FILE__,__LINE__, (_f_),(_a1_),(_a2_) )
125
#define CACHE_TRACE4(_f_,_a1_,_a2_,_a3_)\
126
globus_l_gass_cache_trace(__FILE__,__LINE__,\
127
(_f_),(_a1_),(_a2_),(_a3_) )
128
#define CACHE_TRACE5(_f_,_a1_,_a2_,_a3_,_a4_)\
129
globus_l_gass_cache_trace(__FILE__,__LINE__,\
130
(_f_),(_a1_),(_a2_),(_a3_),(_a4_) )
131
132
#ifdef GLOBUS_L_GASS_CACHE_LOG
133
#define GLOBUS_L_GASS_CACHE_LG(_f_)\
134
globus_l_gass_cache_trace(__FILE__,__LINE__, (_f_) );\
135
globus_l_gass_cache_log(cache_handle->log_FILE, (_f_) )
136
#define GLOBUS_L_GASS_CACHE_LG2(_f_,_a1_)\
137
globus_l_gass_cache_trace(__FILE__,__LINE__, (_f_),(_a1_) );\
138
globus_l_gass_cache_log(cache_handle->log_FILE, (_f_),(_a1_) )
139
#define GLOBUS_L_GASS_CACHE_LG3(_f_,_a1_,_a2_)\
140
globus_l_gass_cache_trace(__FILE__,__LINE__, (_f_),(_a1_),(_a2_) );\
141
globus_l_gass_cache_log(cache_handle->log_FILE, (_f_),(_a1_),(_a2_) )
142
#define GLOBUS_L_GASS_CACHE_LG4(_f_,_a1_,_a2_,_a3_)\
143
globus_l_gass_cache_trace(__FILE__,__LINE__,(_f_),(_a1_),(_a2_),(_a3_) );\
144
globus_l_gass_cache_log(cache_handle->log_FILE,(_f_),(_a1_),(_a2_),(_a3_) )
145
146
#else
147
#define GLOBUS_L_GASS_CACHE_LG(_f_)
148
#define GLOBUS_L_GASS_CACHE_LG2(_f_,_a1_)
149
#define GLOBUS_L_GASS_CACHE_LG3(_f_,_a1_,_a2_)
150
#define GLOBUS_L_GASS_CACHE_LG4(_f_,_a1_,_a2_,_a3_)
151
#endif
152
153
#else
154
155
#define CACHE_TRACE(_f_)
156
#define CACHE_TRACE2(_f_,_a1_)
157
#define CACHE_TRACE3(_f_,_a1_,_a2_)
158
#define CACHE_TRACE4(_f_,_a1_,_a2_,_a3_)
159
#define CACHE_TRACE5(_f_,_a1_,_a2_,_a3_,_a4_)
160
#ifdef GLOBUS_L_GASS_CACHE_LOG
161
#define GLOBUS_L_GASS_CACHE_LG(_f_)\
162
globus_l_gass_cache_log(cache_handle->log_FILE, _f_ );
163
#define GLOBUS_L_GASS_CACHE_LG2(_f_,_a1_)\
164
globus_l_gass_cache_log(cache_handle->log_FILE, (_f_),(_a1_) );
165
#define GLOBUS_L_GASS_CACHE_LG3(_f_,_a1_,_a2_)\
166
globus_l_gass_cache_log(cache_handle->log_FILE,\
167
(_f_),(_a1_),(_a2_) );
168
#define GLOBUS_L_GASS_CACHE_LG4(_f_,_a1_,_a2_,_a3_)\
169
globus_l_gass_cache_log(cache_handle->log_FILE,\
170
(_f_),(_a1_),(_a2_),(_a3_) );
171
#else
172
#define GLOBUS_L_GASS_CACHE_LG(_f_)
173
#define GLOBUS_L_GASS_CACHE_LG2(_f_,_a1_)
174
#define GLOBUS_L_GASS_CACHE_LG3(_f_,_a1_,_a2_)
175
#define GLOBUS_L_GASS_CACHE_LG4(_f_,_a1_,_a2_,_a3_)
176
#endif
177
178
typedef
struct
globus_i_gass_cache_t
179
{
180
/* dirty hack to know if this cache has been opened/init. */
181
void
* init;
182
183
/* version number read out of the state file */
184
char
*cache_directory_path;
185
char
*global_directory_path;
186
char
*local_directory_path;
187
char
*tmp_directory_path;
188
189
/* Current lengths */
190
int
global_dir_len;
191
int
local_dir_len;
192
int
tmp_dir_len;
193
194
/* Max lengths */
195
int
max_mangled_url;
196
int
max_mangled_tag;
197
198
/* Valid mangling options */
199
unsigned
mangling_options;
200
201
/* Cache directory type (hierarchial, flat,...) */
202
int
cache_type;
203
204
/* Cache MD5 directory levels (for non flat) */
205
int
directory_levels;
206
207
/* Logging info */
208
FILE* log_FILE;
209
char
*log_file_name;
210
}
211
globus_i_gass_cache_t;
212
213
214
215
#endif
216
217
#endif
/* GLOBUS_DONT_DOCUMENT_INTERNAL */
globus_i_gass_cache.h
Generated by
1.17.0