Project

General

Profile

Feature #3071 ยป freebsd-build.patch

FreeBSD build update and fix - devnexen, 2021-03-07 12:56

View differences:

include/lighttpd/server.h
63 63
	liWorker *main_worker;
64 64
	guint worker_count;
65 65
	GArray *workers;
66
#ifdef LIGHTY_OS_LINUX
66
#if defined(LIGHTY_OS_LINUX) || defined(LIGHTY_OS_FREEBSD)
67 67
	liValue *workers_cpu_affinity;
68 68
#endif
69 69
	GArray *ts_formats;      /** array of (GString*), add with li_server_ts_format_add() */
include/lighttpd/settings.h
97 97
# include <sched.h>
98 98
#endif
99 99

  
100
#if defined(LIGHTY_OS_FREEBSD)
101
# include <sys/cpuset.h>
102
typedef cpuset_t cpu_set_t;
103
#endif
104

  
100 105
/* on linux 2.4.x you get either sendfile or LFS */
101 106
#if defined(LIGHTY_OS_LINUX) && defined(HAVE_SYS_SENDFILE_H) && defined(HAVE_SENDFILE) && (defined(_LARGEFILE_SOURCE) || defined(HAVE_SENDFILE64)) && defined(HAVE_WRITEV) && !defined(HAVE_SENDFILE_BROKEN)
102 107
# define USE_LINUX_SENDFILE
include/lighttpd/sys_socket.h
53 53
        (sizeof(*(su)) - sizeof((su)->sun_path) + strlen((su)->sun_path))
54 54
#endif /* SUN_LEN */
55 55

  
56
#ifndef SOL_TCP
57
#define SOL_TCP IPPROTO_TCP
58
#endif
59

  
56 60
#define sockread( fd, buf, bytes ) read( fd, buf, bytes )
57 61
#define closesocket(x) close(x)
58 62

  
src/main/plugin_core.c
2163 2163
static void plugin_core_prepare_worker(liServer *srv, liPlugin *p, liWorker *wrk) {
2164 2164
	UNUSED(p);
2165 2165

  
2166
#if defined(LIGHTY_OS_LINUX)
2167
	/* sched_setaffinity is only available on linux */
2166
#if defined(LIGHTY_OS_LINUX) || defined(LIGHTY_OS_FREEBSD)
2167
	/* affinity is only available on linux and freebsd */
2168 2168
	{
2169 2169
		cpu_set_t mask;
2170 2170
		liValue *v = srv->workers_cpu_affinity;
......
2193 2193
			DEBUG(srv, "binding worker #%u to cpus %s", wrk->ndx+1, wrk->tmp_str->str);
2194 2194
		}
2195 2195

  
2196
#if defined(LIGHTY_OS_LINUX)
2196 2197
		if (0 != sched_setaffinity(0, sizeof(mask), &mask)) {
2198
#elif defined(LIGHTY_OS_FREEBSD)
2199
		if (0 != cpuset_setaffinity(CPU_LEVEL_WHICH, CPU_WHICH_PID, -1, sizeof(mask), &mask)) {
2200
#endif
2197 2201
			ERROR(srv, "couldn't set cpu affinity mask for worker #%u: %s", wrk->ndx, g_strerror(errno));
2198 2202
		}
2199 2203
	}
    (1-1/1)