Skip to content

Commit

Permalink
Move foreground definition into src/g_logger.c (#390)
Browse files Browse the repository at this point in the history
And setting it to `0`, no longer requiring defining it everywhere except in foreground executables as needed.

_Also_:
* Require `GLib` >= `v2.50`
  * Needed for [g_log_writer_standard_streams](https://docs.gtk.org/glib/func.log_writer_standard_streams.html)
* Set FreeBSD job `BUILD_PARALLEL_LEVEL` & `TEST_PARALLEL_LEVEL` environment variables via `run`
  * Rather than hard-coding them
  • Loading branch information
hummeltech authored Feb 10, 2024
1 parent 19facb0 commit fdaa5a5
Show file tree
Hide file tree
Showing 13 changed files with 20 additions and 24 deletions.
7 changes: 5 additions & 2 deletions .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -191,12 +191,10 @@ jobs:
FreeBSD:
continue-on-error: true
env:
BUILD_PARALLEL_LEVEL: 2
CFLAGS: --coverage
CTEST_HOST: localhost
CXXFLAGS: --coverage
LIBRARY_PATH: /usr/local/lib
TEST_PARALLEL_LEVEL: 2
TMPDIR: /tmp
name: >-
${{ matrix.box_generic }}
Expand Down Expand Up @@ -224,6 +222,11 @@ jobs:
- name: Checkout code
uses: actions/checkout@v4

- name: Set `BUILD_PARALLEL_LEVEL` & `TEST_PARALLEL_LEVEL`
run: |
echo "BUILD_PARALLEL_LEVEL=$(nproc)" >> "$GITHUB_ENV"
echo "TEST_PARALLEL_LEVEL=$(nproc)" >> "$GITHUB_ENV"
- name: Provision VM
uses: hummeltech/[email protected]
with:
Expand Down
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ find_package(Threads REQUIRED)

find_package(APR REQUIRED)
find_package(CAIRO REQUIRED)
find_package(GLIB REQUIRED)
find_package(GLIB 2.50 REQUIRED)
find_package(HTTPD REQUIRED)
find_package(INIPARSER REQUIRED)
find_package(LIBMAPNIK 3 REQUIRED)
Expand Down
2 changes: 2 additions & 0 deletions includes/g_logger.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
extern "C" {
#endif

extern int foreground;

void g_logger(int log_level, const char *format, ...);

const char *g_logger_level_name(int log_level);
Expand Down
2 changes: 1 addition & 1 deletion src/g_logger.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
#include <stdio.h>
#include <syslog.h>

extern int foreground;
int foreground = 0;

const char *g_logger_level_name(int log_level)
{
Expand Down
2 changes: 0 additions & 2 deletions src/gen_tile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,6 @@ using namespace mapnik;
#define RENDER_SIZE (512)
#endif

extern int foreground;

struct projectionconfig {
double bound_x0;
double bound_y0;
Expand Down
2 changes: 0 additions & 2 deletions src/mod_tile.c
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,6 @@ char *mutexfilename;
int layerCount = 0;
int global_max_zoom = 0;

int foreground = 0;

struct storage_backends {
struct storage_backend ** stores;
int noBackends;
Expand Down
4 changes: 2 additions & 2 deletions src/render_expired.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@

#include <pthread.h>

#include "g_logger.h"
#include "protocol.h"
#include "config.h"
#include "render_config.h"
Expand Down Expand Up @@ -74,8 +75,6 @@ static int maxZoom = 18;
static int verbose = 0;
static int maxLoad = MAX_LOAD_OLD;

int foreground = 1;

void display_rate(struct timeval start, struct timeval end, int num)
{
int d_s, d_us;
Expand Down Expand Up @@ -122,6 +121,7 @@ int main(int argc, char **argv)
mt >>= 1;
}

foreground = 1;

while (1) {
int option_index = 0;
Expand Down
5 changes: 3 additions & 2 deletions src/render_list.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@

#include <pthread.h>

#include "g_logger.h"
#include "gen_tile.h"
#include "protocol.h"
#include "config.h"
Expand All @@ -58,8 +59,6 @@ static int maxZoom = MAX_ZOOM;
static int verbose = 0;
static int maxLoad = MAX_LOAD_OLD;

int foreground = 1;


void display_rate(struct timeval start, struct timeval end, int num)
{
Expand Down Expand Up @@ -118,6 +117,8 @@ int main(int argc, char **argv)
struct storage_backend * store;
struct stat_info s;

foreground = 1;

while (1) {
int option_index = 0;
static struct option long_options[] = {
Expand Down
6 changes: 3 additions & 3 deletions src/render_old.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@

#include <pthread.h>


#include "g_logger.h"
#include "gen_tile.h"
#include "protocol.h"
#include "config.h"
Expand Down Expand Up @@ -64,8 +64,6 @@ static int max_load = MAX_LOAD_OLD;
static time_t planetTime;
static struct timeval start, end;

int foreground = 1;



void display_rate(struct timeval start, struct timeval end, int num)
Expand Down Expand Up @@ -200,6 +198,8 @@ int main(int argc, char **argv)
int dd, mm, yy;
struct tm tm;

foreground = 1;

while (1) {
int option_index = 0;
static struct option long_options[] = {
Expand Down
5 changes: 3 additions & 2 deletions src/render_speedtest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
#include <strings.h>
#include <getopt.h>

#include "g_logger.h"
#include "gen_tile.h"
#include "protocol.h"
#include "config.h"
Expand Down Expand Up @@ -71,8 +72,6 @@ static double boundx1 = 3.2;
static double boundy1 = 58.8;
#endif

int foreground = 1;


static double minmax(double a, double b, double c)
{
Expand Down Expand Up @@ -151,6 +150,8 @@ int main(int argc, char **argv)
int minZoom = 0;
int numThreads = 1;

foreground = 1;

while (1) {
int option_index = 0;
static struct option long_options[] = {
Expand Down
2 changes: 0 additions & 2 deletions src/renderd.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,6 @@ static renderd_config config;

int num_slave_threads;

int foreground = 0;

struct request_queue * render_request_queue;

static const char *cmdStr(enum protoCmd c)
Expand Down
2 changes: 0 additions & 2 deletions src/store.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@
#include "store_null.h"
#include "g_logger.h"

extern int foreground;

/**
* In Apache 2.2, we call the init_storage_backend once per process. For mpm_worker and mpm_event multiple threads therefore use the same
* storage context, and all storage backends need to be thread-safe in order not to cause issues with these mpm's
Expand Down
3 changes: 0 additions & 3 deletions tests/gen_tile_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,6 @@
extern struct projectionconfig *get_projection(const char *srs);
extern mapnik::box2d<double> tile2prjbounds(struct projectionconfig *prj, int x, int y, int z);

extern int foreground;
extern struct request_queue *render_request_queue;

// mutex to guard access to the shared render request counter
static pthread_mutex_t item_counter_lock;

Expand Down

0 comments on commit fdaa5a5

Please sign in to comment.