Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .github/actions/autotools/build/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ runs:
run: ./configure
shell: bash --noprofile --norc -euxo pipefail {0}

- name: Override default `MAPNIK_PLUGINS_DIR`
run: echo "#define MAPNIK_PLUGINS_DIR \"$(find /usr -mindepth 1 -type d -name input | grep mapnik)\"" >> includes/config.h
shell: bash --noprofile --norc -euxo pipefail {0}

- name: Run `make`
run: make
shell: bash --noprofile --norc -euxo pipefail {0}
2 changes: 1 addition & 1 deletion .github/actions/cmake/test/action.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
inputs:
options:
default: --exclude-regex 'clear_dirs_.+|remove_tile_.+' --output-on-failure
default: --exclude-regex 'clear_dirs_.+|remove_tile_.+' --output-on-failure --repeat until-pass:3

runs:
using: composite
Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -272,12 +272,12 @@ jobs:
memory: 4096
ssh_shell: sh

# Mapnik is not in the `quarterly` repository (2023.10.12)
- name: Use "latest" repository
run: |
sudo mkdir -p /usr/local/etc/pkg/repos
sed 's#/quarterly#/latest#g' /etc/pkg/FreeBSD.conf | sudo tee /usr/local/etc/pkg/repos/FreeBSD.conf
sudo pkg upgrade --yes
## In case Mapnik is not in the `quarterly` repository
# - name: Use "latest" repository
# run: |
# sudo mkdir -p /usr/local/etc/pkg/repos
# sed 's#/quarterly#/latest#g' /etc/pkg/FreeBSD.conf | sudo tee /usr/local/etc/pkg/repos/FreeBSD.conf
# sudo pkg upgrade --yes

- name: Install dependencies
uses: ./.github/actions/dependencies/install
Expand Down
52 changes: 23 additions & 29 deletions Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,12 @@ bin_PROGRAMS = \
render_speedtest
noinst_PROGRAMS = \
gen_tile_test \
renderd_config_test_helper \
renderd_config_test \
renderd_test \
render_expired_test \
render_list_test \
render_old_test \
render_speedtest_test
render_speedtest_test \
unit_tests

man_MANS = \
docs/man/renderd.1 \
Expand Down Expand Up @@ -60,14 +59,14 @@ renderd_CXXFLAGS = $(MAPNIK_CFLAGS)
renderd_DATA = etc/renderd/renderd.conf
renderd_LDADD = $(PTHREAD_CFLAGS) $(MAPNIK_LDFLAGS) $(STORE_LDFLAGS) $(INIPARSER_LDFLAGS)

render_speedtest_SOURCES = \
src/render_speedtest.cpp \
src/g_logger.c \
render_expired_SOURCES = \
src/render_expired.c \
src/protocol_helper.c \
src/render_submit_queue.c \
src/renderd_config.c \
src/sys_utils.c
render_speedtest_LDADD = $(PTHREAD_CFLAGS) $(GLIB_LIBS) $(INIPARSER_LDFLAGS)
src/sys_utils.c \
$(STORE_SOURCES)
render_expired_LDADD = $(PTHREAD_CFLAGS) $(STORE_LDFLAGS) $(INIPARSER_LDFLAGS)

render_list_SOURCES = \
src/render_list.c \
Expand All @@ -78,15 +77,6 @@ render_list_SOURCES = \
$(STORE_SOURCES)
render_list_LDADD = $(PTHREAD_CFLAGS) $(STORE_LDFLAGS) $(INIPARSER_LDFLAGS)

render_expired_SOURCES = \
src/render_expired.c \
src/protocol_helper.c \
src/render_submit_queue.c \
src/renderd_config.c \
src/sys_utils.c \
$(STORE_SOURCES)
render_expired_LDADD = $(PTHREAD_CFLAGS) $(STORE_LDFLAGS) $(INIPARSER_LDFLAGS)

render_old_SOURCES = \
src/render_old.c \
src/g_logger.c \
Expand All @@ -97,6 +87,15 @@ render_old_SOURCES = \
src/sys_utils.c
render_old_LDADD = $(PTHREAD_CFLAGS) $(GLIB_LIBS) $(INIPARSER_LDFLAGS)

render_speedtest_SOURCES = \
src/render_speedtest.cpp \
src/g_logger.c \
src/protocol_helper.c \
src/render_submit_queue.c \
src/renderd_config.c \
src/sys_utils.c
render_speedtest_LDADD = $(PTHREAD_CFLAGS) $(GLIB_LIBS) $(INIPARSER_LDFLAGS)

#convert_meta_SOURCES = src/dir_utils.c src/store.c src/convert_meta.c

noinst_LIBRARIES = catch_main.o catch_test_common.o
Expand All @@ -110,16 +109,6 @@ gen_tile_test_CFLAGS = -DMAIN_ALREADY_DEFINED
gen_tile_test_CXXFLAGS = $(renderd_CXXFLAGS)
gen_tile_test_LDADD = $(renderd_LDADD) catch_test_common.o

renderd_config_test_helper_SOURCES = \
tests/renderd_config_test_helper.cpp \
src/g_logger.c \
src/renderd_config.c
renderd_config_test_helper_LDADD = $(GLIB_LIBS) $(INIPARSER_LDFLAGS) catch_main.o

renderd_config_test_SOURCES = \
tests/renderd_config_test.cpp
renderd_config_test_LDADD = $(GLIB_LIBS) catch_main.o catch_test_common.o

renderd_test_SOURCES = \
tests/renderd_test.cpp
renderd_test_LDADD = $(GLIB_LIBS) catch_main.o catch_test_common.o
Expand All @@ -140,18 +129,23 @@ render_speedtest_test_SOURCES = \
tests/render_speedtest_test.cpp
render_speedtest_test_LDADD = $(GLIB_LIBS) catch_main.o catch_test_common.o

unit_tests_SOURCES = \
tests/unit_tests.cpp
unit_tests_CXXFLAGS = -Isrc
unit_tests_LDADD = $(GLIB_LIBS) $(INIPARSER_LDFLAGS) $(MAPNIK_LDFLAGS) $(PTHREAD_CFLAGS) catch_main.o catch_test_common.o

CLEANFILES=*.slo mod_tile.la stderr.out src/*.slo src/*.lo src/.libs/* src/*.la

COMMA=,

test: gen_tile_test renderd_config_test_helper renderd_config_test renderd_test render_expired_test render_list_test render_old_test render_speedtest_test
test: gen_tile_test renderd_test render_expired_test render_list_test render_old_test render_speedtest_test unit_tests
./gen_tile_test
./renderd_config_test
./renderd_test
./render_expired_test
./render_list_test
./render_old_test
./render_speedtest_test
./unit_tests

all-local:
$(APXS) -c $(DEF_LDLIBS) $(AM_CFLAGS) \
Expand Down
2 changes: 2 additions & 0 deletions docker/debian/Dockerfile.autotools
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,11 @@ RUN --mount=type=cache,sharing=locked,id=debian:${debian_version}-/var/cache/apt
## Build, Test & Install `mod_tile`
COPY . /tmp/mod_tile_src
WORKDIR /tmp/mod_tile_src
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
RUN export DESTDIR=/tmp/mod_tile && \
./autogen.sh && \
./configure && \
echo "#define MAPNIK_PLUGINS_DIR \"$(find /usr -mindepth 1 -type d -name input | grep mapnik)\"" >> includes/config.h && \
make DESTDIR=${DESTDIR} install install-mod_tile
RUN make test

Expand Down
2 changes: 2 additions & 0 deletions docker/ubuntu/Dockerfile.autotools
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,11 @@ RUN --mount=type=cache,sharing=locked,id=ubuntu:${ubuntu_version}-/var/cache/apt
## Build, Test & Install `mod_tile`
COPY . /tmp/mod_tile_src
WORKDIR /tmp/mod_tile_src
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
RUN export DESTDIR=/tmp/mod_tile && \
./autogen.sh && \
./configure && \
echo "#define MAPNIK_PLUGINS_DIR \"$(find /usr -mindepth 1 -type d -name input | grep mapnik)\"" >> includes/config.h && \
make DESTDIR=${DESTDIR} install install-mod_tile
RUN make test

Expand Down
6 changes: 3 additions & 3 deletions docs/build/building_on_freebsd.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ Please see our [Continuous Integration script](/.github/workflows/build-and-test
```shell
#!/usr/bin/env sh

# Mapnik is not in the `quarterly` repository (2023.10.12)
sudo mkdir -p /usr/local/etc/pkg/repos
sudo sed 's#/quarterly#/latest#g' /etc/pkg/FreeBSD.conf > /usr/local/etc/pkg/repos/FreeBSD.conf
## In case Mapnik is not in the `quarterly` repository
# sudo mkdir -p /usr/local/etc/pkg/repos
# sed 's#/quarterly#/latest#g' /etc/pkg/FreeBSD.conf | sudo tee /usr/local/etc/pkg/repos/FreeBSD.conf

# Update installed packages
sudo pkg upgrade --yes
Expand Down
1 change: 1 addition & 0 deletions includes/render_submit_queue.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
extern "C" {
#endif

int make_connection(const char *spath);
void enqueue(const char *xmlname, int x, int y, int z);
void spawn_workers(int num, const char *socketpath, int maxLoad);
void wait_for_empty_queue(void);
Expand Down
6 changes: 3 additions & 3 deletions includes/renderd_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,15 @@ extern "C" {
#endif

int num_slave_threads;
renderd_config config;
renderd_config *config;
renderd_config config_slaves[MAX_SLAVES];
xmlconfigitem maps[XMLCONFIGS_MAX];

double min_max_double_opt(const char *opt_arg, const char *opt_type_name, double minimum, double maximum);
int min_max_int_opt(const char *opt_arg, const char *opt_type_name, int minimum, int maximum);
void free_map_section(xmlconfigitem map_section);
void free_map_section(xmlconfigitem *map_section);
void free_map_sections(xmlconfigitem *map_sections);
void free_renderd_section(renderd_config renderd_section);
void free_renderd_section(renderd_config *renderd_section);
void free_renderd_sections(renderd_config *renderd_sections);
void process_config_file(const char *config_file_name, int active_renderd_section_num, int log_level);
void process_map_sections(dictionary *ini, const char *config_file_name, xmlconfigitem *maps_dest, const char *default_tile_dir, int num_threads);
Expand Down
29 changes: 18 additions & 11 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -212,30 +212,37 @@ set(gen_tile_test_SRCS
)
set(gen_tile_test_LIBS
${renderd_LIBS}
${STORE_LIBRARIES}
)
add_executable(gen_tile_test ${gen_tile_test_SRCS})
set_target_properties(gen_tile_test PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/tests)
target_compile_definitions(gen_tile_test PRIVATE MAIN_ALREADY_DEFINED)
target_include_directories(gen_tile_test PRIVATE ${PROJECT_SOURCE_DIR}/tests)
target_link_libraries(gen_tile_test ${gen_tile_test_LIBS})
set_target_properties(gen_tile_test PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/tests)


#-----------------------------------------------------------------------------
#
# renderd_config_test_helper
# unit_tests
#
#-----------------------------------------------------------------------------

set(renderd_config_test_helper_SRCS
${PROJECT_SOURCE_DIR}/tests/renderd_config_test_helper.cpp
g_logger.c
renderd_config.c
set(unit_tests_SRCS
$<TARGET_OBJECTS:catch_main_o>
${PROJECT_SOURCE_DIR}/tests/unit_tests.cpp
)
set(renderd_config_test_helper_LIBS
${GLIB_LIBRARIES}
set(unit_tests_LIBS
${COMMON_LIBRARIES}
${INIPARSER_LIBRARIES}
${LIBMAPNIK_LIBRARIES}
)
add_executable(unit_tests ${unit_tests_SRCS})
set_target_properties(unit_tests PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/tests)
target_compile_definitions(unit_tests PRIVATE
MAPNIK_XML="${PROJECT_SOURCE_DIR}/utils/example-map/mapnik.xml"
RENDERD_CONF="${PROJECT_SOURCE_DIR}/etc/renderd/renderd.conf.examples"
)
add_executable(renderd_config_test_helper ${renderd_config_test_helper_SRCS})
target_link_libraries(renderd_config_test_helper ${renderd_config_test_helper_LIBS})
set_target_properties(renderd_config_test_helper PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/tests)
target_include_directories(unit_tests PRIVATE ${PROJECT_SOURCE_DIR}/src ${PROJECT_SOURCE_DIR}/tests)
target_link_libraries(unit_tests ${unit_tests_LIBS})

endif()
49 changes: 24 additions & 25 deletions src/cache_expire.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@
* URL.
* RFC for HTCP can be found at http://www.htcp.org/
*/
static void cache_expire_url(int sock, char * url)
static void cache_expire_url(int sock, char *url)
{
char * buf;
char *buf;

if (sock < 0) {
return;
Expand All @@ -44,66 +44,66 @@ static void cache_expire_url(int sock, char * url)
int url_len;

url_len = strlen(url);
buf = (char *) malloc(12 + 22 + url_len);
buf = (char *)malloc(12 + 22 + url_len);

if (!buf) {
return;
}

idx = 0;

//16 bit: Overall length of the datagram packet, including this header
// 16 bit: Overall length of the datagram packet, including this header
*((uint16_t *)(&buf[idx])) = htons(12 + 22 + url_len);
idx += 2;

//HTCP version. Currently at 0.0
buf[idx++] = 0; //Major version
buf[idx++] = 0; //Minor version
// HTCP version. Currently at 0.0
buf[idx++] = 0; // Major version
buf[idx++] = 0; // Minor version

//Length of HTCP data, including this field
// Length of HTCP data, including this field
*((uint16_t *)(&buf[idx])) = htons(8 + 22 + url_len);
idx += 2;

//HTCP opcode CLR=4
// HTCP opcode CLR=4
buf[idx++] = 4;
//Reserved
// Reserved
buf[idx++] = 0;

//32 bit transaction id;
// 32 bit transaction id;
*((uint32_t *)(&buf[idx])) = htonl(255);
idx += 4;

buf[idx++] = 0;
buf[idx++] = 0; //HTCP reason
buf[idx++] = 0; // HTCP reason

//Length of the Method string
// Length of the Method string
*((uint16_t *)(&buf[idx])) = htons(4);
idx += 2;

///Method string
/// Method string
memcpy(&buf[idx], "HEAD", 4);
idx += 4;

//Length of the url string
// Length of the url string
*((uint16_t *)(&buf[idx])) = htons(url_len);
idx += 2;

//Url string
// Url string
memcpy(&buf[idx], url, url_len);
idx += url_len;

//Length of version string
// Length of version string
*((uint16_t *)(&buf[idx])) = htons(8);
idx += 2;

//version string
// version string
memcpy(&buf[idx], "HTTP/1.1", 8);
idx += 8;

//Length of request headers. Currently 0 as we don't have any headers to send
// Length of request headers. Currently 0 as we don't have any headers to send
*((uint16_t *)(&buf[idx])) = htons(0);

if (send(sock, (void *) buf, (12 + 22 + url_len), 0) < (12 + 22 + url_len)) {
if (send(sock, (void *)buf, (12 + 22 + url_len), 0) < (12 + 22 + url_len)) {
g_logger(G_LOG_LEVEL_ERROR, "Failed to send HTCP purge for %s", url);
};

Expand All @@ -117,13 +117,13 @@ void cache_expire(int sock, const char *host, const char *uri, int x, int y, int
return;
}

char * url = (char *)malloc(1024);
char *url = (char *)malloc(1024);
snprintf(url, 1024, "http://%s%s%i/%i/%i.png", host, uri, z, x, y);
cache_expire_url(sock, url);
free(url);
}

int init_cache_expire(const char * htcphost)
int init_cache_expire(const char *htcphost)
{
struct addrinfo hints;
struct addrinfo *result, *rp;
Expand All @@ -132,7 +132,7 @@ int init_cache_expire(const char * htcphost)
/* Obtain address(es) matching host/port */

memset(&hints, 0, sizeof(struct addrinfo));
hints.ai_family = AF_UNSPEC; /* Allow IPv4 or IPv6 */
hints.ai_family = AF_UNSPEC; /* Allow IPv4 or IPv6 */
hints.ai_socktype = SOCK_DGRAM; /* Datagram socket */
hints.ai_flags = 0;
hints.ai_protocol = 0; /* Any protocol */
Expand All @@ -157,7 +157,7 @@ int init_cache_expire(const char * htcphost)
}

if (connect(sfd, rp->ai_addr, rp->ai_addrlen) != -1) {
break; /* Success */
break; /* Success */
}

close(sfd);
Expand All @@ -171,5 +171,4 @@ int init_cache_expire(const char * htcphost)
freeaddrinfo(result); /* No longer needed */

return sfd;

}
Loading
Loading