[Tile-serving] [openstreetmap/mod_tile] allow key=value parameters for AddTileConfig (PR #346)
Hummeltech
notifications at github.com
Sat Oct 28 17:26:02 UTC 2023
Also, there are a few minor formatting issues detected by the project's code formatter/linter (`Artistic Style`/`astyle`) that need to be addressed before merging, you can run this in order to format it:
```
astyle --break-blocks --indent-switches --indent=force-tab=8 --lineend=linux --options=none --pad-header --pad-oper --style=1tbs --suffix=none --unpad-paren src/mod_tile.c
```
And you can take a look at the failing job [here](https://github.com/openstreetmap/mod_tile/actions/runs/6568355845/job/17842641567) if you would like.
Here's what the patch looks like, in case you can't install/have trouble running `astyle`:
```diff
diff --git a/src/mod_tile.c b/src/mod_tile.c
index b6d6142..d44cd96 100644
--- a/src/mod_tile.c
+++ b/src/mod_tile.c
@@ -64,7 +64,6 @@ module AP_MODULE_DECLARE_DATA tile_module;
#include <inttypes.h>
#include <poll.h>
-
#include "gen_tile.h"
#include "protocol.h"
#include "render_config.h"
@@ -72,7 +71,6 @@ module AP_MODULE_DECLARE_DATA tile_module;
#include "mod_tile.h"
#include "sys_utils.h"
-
#if !defined(OS2) && !defined(WIN32) && !defined(BEOS) && !defined(NETWARE)
#include "unixd.h"
#define MOD_TILE_SET_MUTEX_PERMS /* XXX Apache should define something */
@@ -547,7 +545,7 @@ static void add_expiry(request_rec *r, struct protocol * cmd)
/* Test if the tile we are serving is out of date, then set a low maxAge*/
if (state == tileOld) {
holdoff = (scfg->cache_duration_dirty / 2) * (rand() / (RAND_MAX
- + 1.0));
+ + 1.0));
maxAge = scfg->cache_duration_dirty + holdoff;
} else {
// cache heuristic based on zoom level
@@ -596,8 +594,6 @@ static void add_expiry(request_rec *r, struct protocol * cmd)
apr_table_setn(t, "Expires", timestr);
}
-
-
static int get_global_lock(request_rec *r, apr_global_mutex_t * mutex)
{
apr_status_t rs;
@@ -854,7 +850,6 @@ static int delay_allowed(request_rec *r, enum tileState state)
}
}
-
if (inet_pton(AF_INET, ip_addr, &sin_addr) > 0) {
//ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, "Checking delays: for IP %s appears to be an IPv4 address", ip_addr);
memset(ip.s6_addr, 0, 16);
@@ -1394,7 +1389,6 @@ static int tile_handler_metrics(request_rec *r)
ap_rprintf(r, "modtile_zoom_responses_total{zoom=\"%02i\"} %li\n", i, local_stats.noRespZoom[i]);
}
-
ap_rprintf(r, "# HELP modtile_tile_reads_total Tiles served from the tile buffer\n");
ap_rprintf(r, "# TYPE modtile_tile_reads_total counter\n");
@@ -1598,7 +1592,6 @@ static int tile_translate(request_rec *r)
ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, "tile_translate: testing baseuri(%s) name(%s) extension(%s)",
tile_config->baseuri, tile_config->xmlname, tile_config->fileExtension);
-
if (!strncmp(tile_config->baseuri, r->uri, strlen(tile_config->baseuri))) {
struct tile_request_data * rdata = (struct tile_request_data *) apr_pcalloc(r->pool, sizeof(struct tile_request_data));
@@ -1826,7 +1819,6 @@ static int mod_tile_post_config(apr_pool_t *pconf, apr_pool_t *plog,
/* TODO: need a way to initialise the delaypool whitelist */
-
/* Create global mutex */
/*
@@ -1934,7 +1926,6 @@ static int mod_tile_post_config(apr_pool_t *pconf, apr_pool_t *plog,
return OK;
}
-
/*
* This routine gets called when a child inits. We use it to attach
* to the shared memory segment, and reinitialize the mutex and setup
@@ -2030,7 +2021,6 @@ static const char *_add_tile_config(cmd_parms *cmd, void *mconfig,
global_max_zoom = maxzoom;
}
-
scfg = ap_get_module_config(cmd->server->module_config, &tile_module);
tilecfg = apr_array_push(scfg->configs);
@@ -2092,42 +2082,48 @@ static const char *add_tile_mime_config(cmd_parms *cmd, void *mconfig, const cha
static const char *add_tile_config(cmd_parms *cmd, void *mconfig, const char *args)
{
const char *baseuri = ap_getword_conf(cmd->pool, &args);
- if (!baseuri) return("AddTileConfig error");
+
+ if (!baseuri) {
+ return ("AddTileConfig error");
+ }
+
const char *name = ap_getword_conf(cmd->pool, &args);
- if (!name) return("AddTileConfig error");
+
+ if (!name) {
+ return ("AddTileConfig error");
+ }
+
int maxzoom = MAX_ZOOM;
int minzoom = 0;
const char *extension = "png";
const char *mimeType = "image/png";
char *token = ap_getword_conf(cmd->pool, &args);
- while(token)
- {
+
+ while (token) {
char *eq = strchr(token, '=');
- if (eq)
- {
- *eq++=0;
- if (!strcmp(token, "maxzoom"))
- {
+
+ if (eq) {
+ *eq++ = 0;
+
+ if (!strcmp(token, "maxzoom")) {
maxzoom = atoi(eq);
- }
- else if (!strcmp(token, "minzoom"))
- {
+ } else if (!strcmp(token, "minzoom")) {
minzoom = atoi(eq);
- }
- else if (!strcmp(token, "extension"))
- {
+ } else if (!strcmp(token, "extension")) {
extension = eq;
- }
- else if (!strcmp(token, "mimetype"))
- {
+ } else if (!strcmp(token, "mimetype")) {
mimeType = eq;
}
}
- if (!*args) break;
+
+ if (!*args) {
+ break;
+ }
+
token = ap_getword_conf(cmd->pool, &args);
}
- return _add_tile_config(cmd, mconfig, baseuri, name, minzoom, maxzoom, 1, 1, extension, mimeType, NULL,NULL,0,NULL,NULL,NULL,0);
+ return _add_tile_config(cmd, mconfig, baseuri, name, minzoom, maxzoom, 1, 1, extension, mimeType, NULL, NULL, 0, NULL, NULL, NULL, 0);
}
static const char *load_tile_config(cmd_parms *cmd, void *mconfig, const char *conffile)
{
@@ -2790,7 +2786,6 @@ static void *create_tile_config(apr_pool_t *p, server_rec *s)
scfg->delaypoolRenderRate = RENDER_TOPUP_RATE;
scfg->bulkMode = 0;
-
return scfg;
}
```
--
Reply to this email directly or view it on GitHub:
https://github.com/openstreetmap/mod_tile/pull/346#issuecomment-1783876565
You are receiving this because you are subscribed to this thread.
Message ID: <openstreetmap/mod_tile/pull/346/c1783876565 at github.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstreetmap.org/pipermail/tile-serving/attachments/20231028/c1608e7a/attachment-0001.htm>
More information about the Tile-serving
mailing list