Mon, 28 Jan 2013 17:37:18 +0100
Correct socket error reporting improvement with IPv6 portable code,
after helpful recommendation by Saúl Ibarra Corretgé on OSips devlist.
michael@146 | 1 | Index: makedefs |
michael@495 | 2 | --- makedefs.orig 2011-01-16 22:02:31.000000000 +0100 |
michael@495 | 3 | +++ makedefs 2011-01-21 09:43:55.000000000 +0100 |
michael@495 | 4 | @@ -153,6 +153,8 @@ |
michael@146 | 5 | ;; |
michael@495 | 6 | FreeBSD.8*) SYSTYPE=FREEBSD8 |
michael@146 | 7 | ;; |
michael@495 | 8 | + FreeBSD.9*) SYSTYPE=FREEBSD9 |
michael@146 | 9 | + ;; |
michael@146 | 10 | OpenBSD.2*) SYSTYPE=OPENBSD2 |
michael@146 | 11 | ;; |
michael@146 | 12 | OpenBSD.3*) SYSTYPE=OPENBSD3 |
michael@146 | 13 | Index: src/util/file_limit.c |
michael@495 | 14 | --- src/util/file_limit.c.orig 2003-10-22 20:48:36.000000000 +0200 |
michael@495 | 15 | +++ src/util/file_limit.c 2011-01-21 09:43:55.000000000 +0100 |
michael@146 | 16 | @@ -80,12 +80,21 @@ |
michael@146 | 17 | void set_file_limit(off_t limit) |
michael@146 | 18 | { |
michael@146 | 19 | #ifdef USE_ULIMIT |
michael@146 | 20 | +#ifdef USE_SOFTLIMITONLY |
michael@146 | 21 | +#error "USE_ULIMIT and USE_SOFTLIMITONLY are mutual exclusive" |
michael@146 | 22 | +#endif |
michael@146 | 23 | if (ulimit(UL_SETFSIZE, limit / ULIMIT_BLOCK_SIZE) < 0) |
michael@146 | 24 | msg_fatal("ulimit: %m"); |
michael@146 | 25 | #else |
michael@146 | 26 | struct rlimit rlim; |
michael@146 | 27 | |
michael@146 | 28 | +#ifdef USE_SOFTLIMITONLY |
michael@146 | 29 | + if (getrlimit(RLIMIT_FSIZE, &rlim) < 0) |
michael@146 | 30 | + rlim.rlim_max = RLIM_INFINITY; |
michael@146 | 31 | + rlim.rlim_cur = limit; |
michael@146 | 32 | +#else |
michael@146 | 33 | rlim.rlim_cur = rlim.rlim_max = limit; |
michael@146 | 34 | +#endif |
michael@146 | 35 | if (setrlimit(RLIMIT_FSIZE, &rlim) < 0) |
michael@146 | 36 | msg_fatal("setrlimit: %m"); |
michael@146 | 37 | #ifdef SIGXFSZ |
michael@146 | 38 | Index: src/util/msg_syslog.c |
michael@495 | 39 | --- src/util/msg_syslog.c.orig 2006-06-15 20:07:16.000000000 +0200 |
michael@495 | 40 | +++ src/util/msg_syslog.c 2011-01-21 09:43:55.000000000 +0100 |
michael@146 | 41 | @@ -50,6 +50,11 @@ |
michael@146 | 42 | #include <syslog.h> |
michael@146 | 43 | #include <string.h> |
michael@146 | 44 | #include <time.h> |
michael@146 | 45 | +#ifdef USE_SOFTLIMITONLY |
michael@146 | 46 | +#include <sys/time.h> |
michael@146 | 47 | +#include <sys/resource.h> |
michael@146 | 48 | +#include <signal.h> |
michael@146 | 49 | +#endif |
michael@146 | 50 | |
michael@146 | 51 | /* Application-specific. */ |
michael@146 | 52 | |
michael@146 | 53 | @@ -144,6 +149,9 @@ |
michael@146 | 54 | |
michael@146 | 55 | static void msg_syslog_print(int level, const char *text) |
michael@146 | 56 | { |
michael@146 | 57 | +#ifdef USE_SOFTLIMITONLY |
michael@146 | 58 | + struct rlimit save, rlim; |
michael@146 | 59 | +#endif |
michael@146 | 60 | static int log_level[] = { |
michael@146 | 61 | LOG_INFO, LOG_WARNING, LOG_ERR, LOG_CRIT, LOG_CRIT, |
michael@146 | 62 | }; |
michael@146 | 63 | @@ -154,6 +162,15 @@ |
michael@146 | 64 | if (level < 0 || level >= (int) (sizeof(log_level) / sizeof(log_level[0]))) |
michael@146 | 65 | msg_panic("msg_syslog_print: invalid severity level: %d", level); |
michael@146 | 66 | |
michael@146 | 67 | +#ifdef USE_SOFTLIMITONLY |
michael@146 | 68 | + if (getrlimit(RLIMIT_FSIZE, &save) < 0) { |
michael@146 | 69 | + save.rlim_cur = RLIM_INFINITY; |
michael@146 | 70 | + save.rlim_max = RLIM_INFINITY; |
michael@146 | 71 | + } |
michael@146 | 72 | + rlim.rlim_cur = save.rlim_max; |
michael@146 | 73 | + rlim.rlim_max = save.rlim_max; |
michael@146 | 74 | + (void)setrlimit(RLIMIT_FSIZE, &rlim); |
michael@146 | 75 | +#endif |
michael@146 | 76 | if (level == MSG_INFO) { |
michael@146 | 77 | syslog(syslog_facility | log_level[level], "%.*s", |
michael@146 | 78 | (int) MSG_SYSLOG_RECLEN, text); |
michael@146 | 79 | @@ -161,6 +178,9 @@ |
michael@146 | 80 | syslog(syslog_facility | log_level[level], "%s: %.*s", |
michael@146 | 81 | severity_name[level], (int) MSG_SYSLOG_RECLEN, text); |
michael@146 | 82 | } |
michael@146 | 83 | +#ifdef USE_SOFTLIMITONLY |
michael@146 | 84 | + (void)setrlimit(RLIMIT_FSIZE, &save); |
michael@146 | 85 | +#endif |
michael@146 | 86 | } |
michael@146 | 87 | |
michael@146 | 88 | /* msg_syslog_init - initialize */ |
michael@146 | 89 | Index: src/util/sys_defs.h |
michael@495 | 90 | --- src/util/sys_defs.h.orig 2011-01-17 15:44:25.000000000 +0100 |
michael@495 | 91 | +++ src/util/sys_defs.h 2011-01-21 09:43:55.000000000 +0100 |
michael@495 | 92 | @@ -25,7 +25,7 @@ |
michael@146 | 93 | */ |
michael@146 | 94 | #if defined(FREEBSD2) || defined(FREEBSD3) || defined(FREEBSD4) \ |
michael@495 | 95 | || defined(FREEBSD5) || defined(FREEBSD6) || defined(FREEBSD7) \ |
michael@495 | 96 | - || defined(FREEBSD8) \ |
michael@495 | 97 | + || defined(FREEBSD8) || defined(FREEBSD9) \ |
michael@146 | 98 | || defined(BSDI2) || defined(BSDI3) || defined(BSDI4) \ |
michael@146 | 99 | || defined(OPENBSD2) || defined(OPENBSD3) || defined(OPENBSD4) \ |
michael@495 | 100 | || defined(OPENBSD5) \ |
michael@495 | 101 | @@ -117,6 +117,10 @@ |
michael@495 | 102 | #define HAS_CLOSEFROM |
michael@495 | 103 | #endif |
michael@495 | 104 | |
michael@495 | 105 | +#if (__FreeBSD_version < 800000 && __FreeBSD_version >= 702104) || (__FreeBSD_version >= 800100) |
michael@495 | 106 | +#define HAS_CLOSEFROM |
michael@146 | 107 | +#endif |
michael@495 | 108 | + |
michael@495 | 109 | /* OpenBSD version is year+month */ |
michael@146 | 110 | |
michael@495 | 111 | #if OpenBSD >= 199805 /* XXX */ |