Skip to content

Commit 925183a

Browse files
Make /status and /dirty URLs controlable with apache conf (#359)
* Allow the …/status URL to be turned on or off (default of on remains) Add ModTileEnableStatusURL On/Off to allow the …/status to be turned on (default) or off. Previous behaviour has …/status on, which is not changed in this patch. * Allow the …/dirty URL to be turned on or off (default of on remains) Add ModTileEnableDirtyURL On/Off to allow the …/dirty to be turned on (default) or off. Previous behaviour has …/dirty on, which is not changed in this patch. * Make …/dirty & …/status disabled by default. This is a breaking change. To get the old default behaviour back, you must now manually add `ModTileEnableStatusURL On` & `ModTileEnableDirtyURL On` to your apache configuration. * Change default for ModTileEnable Dirty/Status URL to On * Add log output for when `/dirty`/`/status` is Off * Add tests for "ModTileEnable{Dirty|Status}URL Off" --------- Co-authored-by: Amanda McCann <amanda@technomancy.org>
1 parent 4580b2e commit 925183a

5 files changed

Lines changed: 94 additions & 13 deletions

File tree

etc/apache2/renderd-example-map.conf

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,4 +145,14 @@ Listen 8081
145145
# Parameters (poolsize in tiles and topup rate in tiles per second) for throttling render requests.
146146
ModTileThrottlingRenders 128 0.2
147147

148+
# Enable the .../Z/X/Y.ext/status URL, which shows details of that tile.
149+
# Off = a 404 is returned for that url instead.
150+
# Default: On
151+
#ModTileEnableStatusURL Off
152+
153+
# Enable the .../Z/X/Y.ext/dirty URL, which marks that tile as dirty.
154+
# Off = a 404 is returned for that url instead.
155+
# Default: On
156+
#ModTileEnableDirtyURL Off
157+
148158
</VirtualHost>

includes/mod_tile.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,8 @@ typedef struct {
136136
int delaypoolRenderSize;
137137
long delaypoolRenderRate;
138138
int bulkMode;
139+
int enableStatusUrl;
140+
int enableDirtyUrl;
139141
} tile_server_conf;
140142

141143
typedef struct tile_request_data {

src/mod_tile.c

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -989,6 +989,12 @@ static int tile_handler_dirty(request_rec *r)
989989
sconf = r->server->module_config;
990990
scfg = ap_get_module_config(sconf, &tile_module);
991991

992+
// Is /dirty URL enabled?
993+
if (!scfg->enableDirtyUrl) {
994+
ap_log_rerror(APLOG_MARK, APLOG_WARNING, 0, r, "tile_handler_dirty: /dirty URL is not enabled");
995+
return HTTP_NOT_FOUND;
996+
}
997+
992998
if (scfg->bulkMode) {
993999
return OK;
9941000
}
@@ -1134,6 +1140,8 @@ static int tile_storage_hook(request_rec *r)
11341140

11351141
static int tile_handler_status(request_rec *r)
11361142
{
1143+
ap_conf_vector_t *sconf;
1144+
tile_server_conf *scfg;
11371145
enum tileState state;
11381146
char mtime_str[APR_CTIME_LEN];
11391147
char atime_str[APR_CTIME_LEN];
@@ -1145,6 +1153,15 @@ static int tile_handler_status(request_rec *r)
11451153
return DECLINED;
11461154
}
11471155

1156+
sconf = r->server->module_config;
1157+
scfg = ap_get_module_config(sconf, &tile_module);
1158+
1159+
// Is /status URL enabled?
1160+
if (!scfg->enableStatusUrl) {
1161+
ap_log_rerror(APLOG_MARK, APLOG_WARNING, 0, r, "tile_handler_status: /status URL is not enabled");
1162+
return HTTP_NOT_FOUND;
1163+
}
1164+
11481165
rdata = (struct tile_request_data *)ap_get_module_config(r->request_config, &tile_module);
11491166
cmd = rdata->cmd;
11501167

@@ -2672,6 +2689,20 @@ static const char *mod_tile_bulk_mode(cmd_parms *cmd, void *mconfig, int bulkMod
26722689
return NULL;
26732690
}
26742691

2692+
static const char *mod_tile_enable_status_url(cmd_parms *cmd, void *mconfig, int enableStatusUrl)
2693+
{
2694+
tile_server_conf *scfg = ap_get_module_config(cmd->server->module_config, &tile_module);
2695+
scfg->enableStatusUrl = enableStatusUrl;
2696+
return NULL;
2697+
}
2698+
2699+
static const char *mod_tile_enable_dirty_url(cmd_parms *cmd, void *mconfig, int enableDirtyUrl)
2700+
{
2701+
tile_server_conf *scfg = ap_get_module_config(cmd->server->module_config, &tile_module);
2702+
scfg->enableDirtyUrl = enableDirtyUrl;
2703+
return NULL;
2704+
}
2705+
26752706
static const char *mod_tile_delaypool_tiles_config(cmd_parms *cmd, void *mconfig, const char *bucketsize_string, const char *topuprate_string)
26762707
{
26772708
int bucketsize;
@@ -2751,6 +2782,8 @@ static void *create_tile_config(apr_pool_t *p, server_rec *s)
27512782
scfg->delaypoolRenderSize = AVAILABLE_RENDER_BUCKET_SIZE;
27522783
scfg->delaypoolRenderRate = RENDER_TOPUP_RATE;
27532784
scfg->bulkMode = 0;
2785+
scfg->enableStatusUrl = 1;
2786+
scfg->enableDirtyUrl = 1;
27542787

27552788

27562789
return scfg;
@@ -2793,6 +2826,8 @@ static void *merge_tile_config(apr_pool_t *p, void *basev, void *overridesv)
27932826
scfg->delaypoolRenderSize = scfg_over->delaypoolRenderSize;
27942827
scfg->delaypoolRenderRate = scfg_over->delaypoolRenderRate;
27952828
scfg->bulkMode = scfg_over->bulkMode;
2829+
scfg->enableStatusUrl = scfg_over->enableStatusUrl;
2830+
scfg->enableDirtyUrl = scfg_over->enableDirtyUrl;
27962831

27972832
//Construct a table of minimum cache times per zoom level
27982833
for (i = 0; i <= MAX_ZOOM_SERVER; i++) {
@@ -2984,6 +3019,20 @@ static const command_rec tile_cmds[] = {
29843019
OR_OPTIONS, /* where available */
29853020
"On Off - make all requests to renderd with bulk render priority, never mark tiles dirty" /* directive description */
29863021
),
3022+
AP_INIT_FLAG(
3023+
"ModTileEnableStatusURL", /* directive name */
3024+
mod_tile_enable_status_url, /* config action routine */
3025+
NULL, /* argument to include in call */
3026+
OR_OPTIONS, /* where available */
3027+
"On Off - whether to handle .../status urls " /* directive description */
3028+
),
3029+
AP_INIT_FLAG(
3030+
"ModTileEnableDirtyURL", /* directive name */
3031+
mod_tile_enable_dirty_url, /* config action routine */
3032+
NULL, /* argument to include in call */
3033+
OR_OPTIONS, /* where available */
3034+
"On Off - whether to handle .../dirty urls " /* directive description */
3035+
),
29873036
{NULL}
29883037
};
29893038

tests/CMakeLists.txt

Lines changed: 29 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -47,15 +47,21 @@ set(TILE_PNG256_URL "http://localhost:${HTTPD0_PORT}/tiles/renderd-example-png25
4747
set(TILE_PNG32_URL "http://localhost:${HTTPD0_PORT}/tiles/renderd-example-png32/9/297/191.png")
4848
set(TILE_WEBP_URL "http://localhost:${HTTPD0_PORT}/tiles/renderd-example-webp/9/297/191.webp")
4949

50-
set(TILE_DEFAULT_CMD "${CURL_EXECUTABLE} --fail --silent ${TILE_DEFAULT_URL}")
50+
set(TILE_DIRTY_OFF_URL "http://localhost:${HTTPD1_PORT}/tiles/renderd-example/9/297/191.png/dirty")
51+
set(TILE_DIRTY_ON_URL "http://localhost:${HTTPD0_PORT}/tiles/renderd-example/9/297/191.png/dirty")
52+
set(TILE_STATUS_OFF_URL "http://localhost:${HTTPD1_PORT}/tiles/renderd-example/9/297/191.png/status")
53+
set(TILE_STATUS_ON_URL "http://localhost:${HTTPD0_PORT}/tiles/renderd-example/9/297/191.png/status")
54+
55+
set(CURL_CMD "${CURL_EXECUTABLE} --fail --silent")
56+
set(TILE_DEFAULT_CMD "${CURL_CMD} ${TILE_DEFAULT_URL}")
5157
set(TILE_DEFAULT_SHA256SUM "dbf26531286e844a3a9735cdd193598dca78d22f77cafe5824bcaf17f88cbb08")
52-
set(TILE_JPG_CMD "${CURL_EXECUTABLE} --fail --silent ${TILE_JPG_URL}")
58+
set(TILE_JPG_CMD "${CURL_CMD} ${TILE_JPG_URL}")
5359
set(TILE_JPG_SHA256SUM "e09c3406c02f03583dadf0c8404c2d3efdc06a40d399e381ed2f47f49fde42d7")
54-
set(TILE_PNG256_CMD "${CURL_EXECUTABLE} --fail --silent ${TILE_PNG256_URL}")
60+
set(TILE_PNG256_CMD "${CURL_CMD} ${TILE_PNG256_URL}")
5561
set(TILE_PNG256_SHA256SUM "${TILE_DEFAULT_SHA256SUM}")
56-
set(TILE_PNG32_CMD "${CURL_EXECUTABLE} --fail --silent ${TILE_PNG32_URL}")
62+
set(TILE_PNG32_CMD "${CURL_CMD} ${TILE_PNG32_URL}")
5763
set(TILE_PNG32_SHA256SUM "1006d92152f1e18896e0016fb43201b14bbcf7655955b74495ad3610541d325b")
58-
set(TILE_WEBP_CMD "${CURL_EXECUTABLE} --fail --silent ${TILE_WEBP_URL}")
64+
set(TILE_WEBP_CMD "${CURL_CMD} ${TILE_WEBP_URL}")
5965
set(TILE_WEBP_SHA256SUM_4 "ef3862a57831b21ec69c15be196e1e2b4fea66246c361142631b9fa22b85decc") # libwebp.so.4
6066
set(TILE_WEBP_SHA256SUM_6 "96fc0455b2269a7bcd4a5b3c9844529c3c77e3bb15f56e72f78a5af3bc15b6b5") # libwebp.so.6
6167
set(TILE_WEBP_SHA256SUM_7 "a82ef9ba5dc333de88af7b645084c30ab2b01c664e17162cbf6659c287cc4df4") # libwebp.so.7
@@ -202,24 +208,34 @@ add_test(
202208
add_test(
203209
NAME dirty_tile
204210
COMMAND ${BASH} -c "
205-
TILE_STATUS_CMD=\"${TILE_DEFAULT_CMD}/status\"
206-
TILE_LAST_RENDERED_AT_OLD=$(\${TILE_STATUS_CMD} | ${GREP_EXECUTABLE} -o 'Last rendered at [^\\.]*.')
211+
TILE_DIRTY_ON_CMD=\"${CURL_CMD} ${TILE_DIRTY_ON_URL}\"
212+
TILE_STATUS_ON_CMD=\"${CURL_CMD} ${TILE_STATUS_ON_URL}\"
213+
TILE_LAST_RENDERED_AT_OLD=$(\${TILE_STATUS_ON_CMD} | ${GREP_EXECUTABLE} -o 'Last rendered at [^\\.]*.')
207214
echo \"Tile Last Rendered At (Old): \${TILE_LAST_RENDERED_AT_OLD}\"
208215
sleep 5;
209-
TILE_DIRTY_CMD=\"${TILE_DEFAULT_CMD}/dirty\"
210-
TILE_DIRTY_OUTPUT=$(\${TILE_DIRTY_CMD})
211-
echo \"Dirty: \${TILE_DIRTY_OUTPUT}\"
212-
if [ \"\${TILE_DIRTY_OUTPUT}\" != \"Tile submitted for rendering\" ]; then
216+
TILE_DIRTY_ON_OUTPUT=$(\${TILE_DIRTY_ON_CMD})
217+
echo \"Dirty: \${TILE_DIRTY_ON_OUTPUT}\"
218+
if [ \"\${TILE_DIRTY_ON_OUTPUT}\" != \"Tile submitted for rendering\" ]; then
213219
exit 1;
214220
fi
215-
TILE_LAST_RENDERED_AT_NEW=$(\${TILE_STATUS_CMD} | ${GREP_EXECUTABLE} -o 'Last rendered at [^\\.]*.')
221+
TILE_LAST_RENDERED_AT_NEW=$(\${TILE_STATUS_ON_CMD} | ${GREP_EXECUTABLE} -o 'Last rendered at [^\\.]*.')
216222
echo \"Tile Last Rendered At (New): \${TILE_LAST_RENDERED_AT_NEW}\"
217223
until [ \"\${TILE_LAST_RENDERED_AT_OLD}\" != \"\${TILE_LAST_RENDERED_AT_NEW}\" ]; do
218224
echo 'Sleeping 1s';
219225
sleep 1;
220-
TILE_LAST_RENDERED_AT_NEW=$(\${TILE_STATUS_CMD} | ${GREP_EXECUTABLE} -o 'Last rendered at [^\\.]*.');
226+
TILE_LAST_RENDERED_AT_NEW=$(\${TILE_STATUS_ON_CMD} | ${GREP_EXECUTABLE} -o 'Last rendered at [^\\.]*.');
221227
echo \"Tile Last Rendered At (New): \${TILE_LAST_RENDERED_AT_NEW}\";
222228
done
229+
TILE_DIRTY_OFF_CODE=$(${CURL_CMD} --write-out '%{http_code}' ${TILE_DIRTY_OFF_URL})
230+
echo \"Dirty Off code: '\${TILE_DIRTY_OFF_CODE}'\"
231+
if [ \"\${TILE_DIRTY_OFF_CODE}\" != \"404\" ]; then
232+
exit 1;
233+
fi
234+
TILE_STATUS_OFF_CODE=$(${CURL_CMD} --write-out '%{http_code}' ${TILE_STATUS_OFF_URL})
235+
echo \"Status Off code: '\${TILE_STATUS_OFF_CODE}'\"
236+
if [ \"\${TILE_STATUS_OFF_CODE}\" != \"404\" ]; then
237+
exit 1;
238+
fi
223239
"
224240
WORKING_DIRECTORY tests
225241
)

tests/httpd.conf.in

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@ Redirect /renderd-example-map/leaflet/leaflet.min.js https://unpkg.com/leaflet/d
2323
ModTileCacheDurationMediumZoom 13 86400
2424
ModTileCacheDurationMinimum 10800
2525
ModTileCacheLastModifiedFactor 0.20
26+
ModTileEnableDirtyURL On
2627
ModTileEnableStats On
28+
ModTileEnableStatusURL On
2729
ModTileEnableTileThrottling Off
2830
ModTileEnableTileThrottlingXForward 0
2931
ModTileMaxLoadMissing 5
@@ -45,7 +47,9 @@ Redirect /renderd-example-map/leaflet/leaflet.min.js https://unpkg.com/leaflet/d
4547
ModTileCacheDurationMediumZoom 13 86400
4648
ModTileCacheDurationMinimum 10800
4749
ModTileCacheLastModifiedFactor 0.20
50+
ModTileEnableDirtyURL Off
4851
ModTileEnableStats On
52+
ModTileEnableStatusURL Off
4953
ModTileEnableTileThrottling Off
5054
ModTileEnableTileThrottlingXForward 0
5155
ModTileMaxLoadMissing 5

0 commit comments

Comments
 (0)