Skip to content

Commit f3b9abd

Browse files
committed
don't clear locks on startup (not needed now they have a timeout)
1 parent abe1372 commit f3b9abd

File tree

3 files changed

+1
-64
lines changed

3 files changed

+1
-64
lines changed

include/mapcache.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1183,7 +1183,6 @@ struct mapcache_locker{
11831183
mapcache_lock_result (*ping_lock)(mapcache_context *ctx, mapcache_locker *self, char *resource, void *lock);
11841184
void (*release_lock)(mapcache_context *ctx, mapcache_locker *self, char *resource, void *lock);
11851185

1186-
void (*clear_all_locks)(mapcache_context *ctx, mapcache_locker *self);
11871186
void (*parse_xml)(mapcache_context *ctx, mapcache_locker *self, ezxml_t node);
11881187
mapcache_lock_mode type;
11891188
double timeout;
@@ -1214,7 +1213,6 @@ typedef struct {
12141213
mapcache_locker locker;
12151214
int nservers;
12161215
mapcache_locker_memcache_server *servers;
1217-
int timeout; /* in seconds, passed and honoured by memcache, not mapcache */
12181216
} mapcache_locker_memcache;
12191217

12201218
mapcache_locker* mapcache_locker_memcache_create(mapcache_context *ctx);

lib/configuration.c

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,6 @@ void mapcache_configuration_parse(mapcache_context *ctx, const char *filename, m
4141

4242
GC_CHECK_ERROR(ctx);
4343

44-
if(!cgi && config->locker->clear_all_locks) {
45-
config->locker->clear_all_locks(ctx, config->locker);
46-
GC_CHECK_ERROR(ctx);
47-
}
48-
4944
/* if we were suppplied with an onlineresource, make sure it ends with a / */
5045
if(NULL != (url = (char*)apr_table_get(config->metadata,"url"))) {
5146
char *urlend = url + strlen(url)-1;

lib/lock.c

Lines changed: 1 addition & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -76,35 +76,6 @@ int mapcache_lock_or_wait_for_resource(mapcache_context *ctx, mapcache_locker *l
7676
}
7777

7878

79-
void mapcache_locker_disk_clear_all_locks(mapcache_context *ctx, mapcache_locker *self) {
80-
mapcache_locker_disk *ldisk = (mapcache_locker_disk*)self;
81-
apr_dir_t *lockdir;
82-
char errmsg[120];
83-
apr_finfo_t finfo;
84-
apr_status_t rv = apr_dir_open(&lockdir,ldisk->dir,ctx->pool);
85-
if(rv != APR_SUCCESS) {
86-
ctx->set_error(ctx,500, "failed to open lock directory %s: %s" ,ldisk->dir,apr_strerror(rv,errmsg,120));
87-
return;
88-
}
89-
90-
while ((apr_dir_read(&finfo, APR_FINFO_DIRENT|APR_FINFO_TYPE|APR_FINFO_NAME, lockdir)) == APR_SUCCESS) {
91-
if(finfo.filetype == APR_REG) {
92-
if(!strncmp(finfo.name, MAPCACHE_LOCKFILE_PREFIX, strlen(MAPCACHE_LOCKFILE_PREFIX))) {
93-
ctx->log(ctx,MAPCACHE_WARN,"found old lockfile %s/%s, deleting it",ldisk->dir,
94-
finfo.name);
95-
rv = apr_file_remove(apr_psprintf(ctx->pool,"%s/%s",ldisk->dir, finfo.name),ctx->pool);
96-
if(rv != APR_SUCCESS) {
97-
ctx->set_error(ctx,500, "failed to remove lockfile %s: %s",finfo.name,apr_strerror(rv,errmsg,120));
98-
return;
99-
}
100-
101-
}
102-
103-
}
104-
}
105-
apr_dir_close(lockdir);
106-
}
107-
10879
mapcache_lock_result mapcache_locker_disk_aquire_lock(mapcache_context *ctx, mapcache_locker *self, char *resource, void **lock) {
10980
char *lockname, errmsg[120];
11081
mapcache_locker_disk *ldisk;
@@ -180,7 +151,6 @@ mapcache_locker* mapcache_locker_disk_create(mapcache_context *ctx) {
180151
mapcache_locker_disk *ld = (mapcache_locker_disk*)apr_pcalloc(ctx->pool, sizeof(mapcache_locker_disk));
181152
mapcache_locker *l = (mapcache_locker*)ld;
182153
l->type = MAPCACHE_LOCKER_DISK;
183-
l->clear_all_locks = mapcache_locker_disk_clear_all_locks;
184154
l->aquire_lock = mapcache_locker_disk_aquire_lock;
185155
l->parse_xml = mapcache_locker_disk_parse_xml;
186156
l->release_lock = mapcache_locker_disk_release_lock;
@@ -203,17 +173,6 @@ mapcache_lock_result mapcache_locker_fallback_ping_lock(mapcache_context *ctx, m
203173
return flock->locker->ping_lock(ctx,flock->locker,resource,flock->lock);
204174
}
205175

206-
void mapcache_locker_fallback_clear_all_locks(mapcache_context *ctx, mapcache_locker *self) {
207-
int i;
208-
mapcache_locker_fallback *locker = (mapcache_locker_fallback*)self;
209-
for(i=0;i<locker->lockers->nelts;i++) {
210-
mapcache_locker *child_locker = APR_ARRAY_IDX(locker->lockers, i, mapcache_locker*);
211-
if(child_locker->clear_all_locks) {
212-
child_locker->clear_all_locks(ctx,child_locker);
213-
}
214-
}
215-
}
216-
217176
mapcache_lock_result mapcache_locker_fallback_aquire_lock(mapcache_context *ctx, mapcache_locker *self, char *resource, void **lock) {
218177
int i;
219178
mapcache_locker_fallback *locker = (mapcache_locker_fallback*)self;
@@ -279,19 +238,6 @@ void mapcache_locker_memcache_parse_xml(mapcache_context *ctx, mapcache_locker *
279238
}
280239
lm->nservers++;
281240
}
282-
283-
284-
if((node = ezxml_child(doc,"timeout")) != NULL) {
285-
lm->timeout = (unsigned int)strtol(node->txt,&endptr,10);
286-
if(*endptr != 0 || lm->timeout <= 0) {
287-
ctx->set_error(ctx, 400, "failed to parse memcache locker timeout \"%s\". Expecting a positive integer",
288-
node->txt);
289-
return;
290-
}
291-
} else {
292-
/* default: timeout after 10 minutes */
293-
lm->timeout = 600;
294-
}
295241
}
296242

297243
static char* memcache_key_for_resource(mapcache_context *ctx, mapcache_locker_memcache *lm, const char *resource)
@@ -362,7 +308,7 @@ mapcache_lock_result mapcache_locker_memcache_aquire_lock(mapcache_context *ctx,
362308
return MAPCACHE_LOCK_NOENT;
363309
}
364310
*lock = memcache;
365-
rv = apr_memcache_add(memcache,key,"1",1,lm->timeout,0);
311+
rv = apr_memcache_add(memcache,key,"1",1,self->timeout,0);
366312
if( rv == APR_SUCCESS) {
367313
return MAPCACHE_LOCK_AQUIRED;
368314
} else if ( rv == APR_EEXIST ) {
@@ -395,7 +341,6 @@ mapcache_locker* mapcache_locker_memcache_create(mapcache_context *ctx) {
395341
mapcache_locker_memcache *lm = (mapcache_locker_memcache*)apr_pcalloc(ctx->pool, sizeof(mapcache_locker_memcache));
396342
mapcache_locker *l = (mapcache_locker*)lm;
397343
l->type = MAPCACHE_LOCKER_MEMCACHE;
398-
l->clear_all_locks = NULL;
399344
l->aquire_lock = mapcache_locker_memcache_aquire_lock;
400345
l->ping_lock = mapcache_locker_memcache_ping_lock;
401346
l->parse_xml = mapcache_locker_memcache_parse_xml;
@@ -411,7 +356,6 @@ mapcache_locker* mapcache_locker_fallback_create(mapcache_context *ctx) {
411356
mapcache_locker_fallback *lm = (mapcache_locker_fallback*)apr_pcalloc(ctx->pool, sizeof(mapcache_locker_fallback));
412357
mapcache_locker *l = (mapcache_locker*)lm;
413358
l->type = MAPCACHE_LOCKER_FALLBACK;
414-
l->clear_all_locks = mapcache_locker_fallback_clear_all_locks;
415359
l->aquire_lock = mapcache_locker_fallback_aquire_lock;
416360
l->ping_lock = mapcache_locker_fallback_ping_lock;
417361
l->parse_xml = mapcache_locker_fallback_parse_xml;

0 commit comments

Comments
 (0)