1
0
mirror of https://github.com/stefanocasazza/ULib.git synced 2025-09-28 19:05:55 +08:00

MACOSX fix

This commit is contained in:
stefanocasazza 2015-10-07 18:42:21 +02:00
parent da040da550
commit 9aeff66c2a
8 changed files with 61 additions and 31 deletions

View File

@ -54,18 +54,19 @@ public:
U_ERROR("you must avoid the jnl suffix, exiting");
}
if (x.open(10 * 1024 * 1024, false, false, true)) // bool open(uint32_t log_size, bool btruncate, bool cdb_brdonly, bool breference)
const char* method = argv[optind++];
if (method == 0) U_ERROR("<number_of_command> argument is missing");
if (u__isdigit(*method) == false) U_ERROR("<number_of_command> argument is not numeric");
int op = method[0] - '0';
if (x.open(10 * 1024 * 1024, false, op == 6, true)) // bool open(uint32_t log_size, bool btruncate, bool cdb_brdonly, bool breference)
{
const char* method = argv[optind++];
if (method == 0) U_ERROR("<number_of_command> argument is missing");
if (u__isdigit(*method) == false) U_ERROR("<number_of_command> argument is not numeric");
if (method[1] == 's') x.setShared(0,0); // POSIX shared memory object (interprocess - can be used by unrelated processes)
else x.resetReference();
int op = method[0] - '0';
switch (op)
{
case 1: // get

View File

@ -3,7 +3,7 @@
dist_sysconf_DATA = uclient.cfg.default
DEFAULT_INCLUDES = -I. -I$(top_srcdir)/include
DEFAULT_CONFIG_FILE = $(sysconfdir)/uclient.cfg
DEFAULT_CONFIG_FILE = @ULIB_SYSCONFDIR@/uclient.cfg
ulib_la = @ULIBS@ $(top_builddir)/src/ulib/lib@ULIB@.la @ULIB_LIBS@

View File

@ -381,7 +381,7 @@ top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
dist_sysconf_DATA = uclient.cfg.default
DEFAULT_INCLUDES = -I. -I$(top_srcdir)/include
DEFAULT_CONFIG_FILE = $(sysconfdir)/uclient.cfg
DEFAULT_CONFIG_FILE = @ULIB_SYSCONFDIR@/uclient.cfg
ulib_la = @ULIBS@ $(top_builddir)/src/ulib/lib@ULIB@.la @ULIB_LIBS@
@SSL_TRUE@uclient_LDADD = $(ulib_la)
@SSL_TRUE@uclient_SOURCES = uclient.cpp

View File

@ -4397,13 +4397,15 @@ static void GET_login() // MAIN PAGE
}
else
{
// campi bisenzio
USSIPlugIn::setAlternativeInclude(cache->getContent(U_CONSTANT_TO_PARAM("login.tmpl")), sz, false,
title_default->data(), 0, 0,
url_banner_ap->data(),
ap_ref_ap->data(),
request1.data(),
url_banner_comune->data(),
ap_ref_comune->data());
url_banner_ap->rep,
ap_ref_ap->rep,
request1.rep,
url_banner_comune->rep,
ap_ref_comune->rep);
}
}
else

View File

@ -341,7 +341,7 @@ typedef int socket_t;
#undef getchar
#undef putchar
#if !defined(_GNU_SOURCE) || defined(__NetBSD__)
#if !defined(_GNU_SOURCE) || defined(__OSX__) || defined(__NetBSD__)
typedef void (*sighandler_t)(int); /* Convenient typedef for signal handlers */
#endif
typedef unsigned long timeout_t; /* Typedef for millisecond timer values */

View File

@ -1129,7 +1129,7 @@ UServer_Base::~UServer_Base()
(void) UFile::setSysParam("/proc/sys/net/ipv4/tcp_fin_timeout", tcp_fin_timeout, true);
if (USocket::iBackLog >= SOMAXCONN)
if (USocket::iBackLog > SOMAXCONN)
{
(void) UFile::setSysParam("/proc/sys/net/core/somaxconn", sysctl_somaxconn, true);
(void) UFile::setSysParam("/proc/sys/net/ipv4/tcp_max_syn_backlog", sysctl_max_syn_backlog, true);
@ -2135,14 +2135,18 @@ void UServer_Base::init()
tcp_abort_on_overflow = UFile::setSysParam("/proc/sys/net/ipv4/tcp_abort_on_overflow", 1, true);
}
else if (USocket::iBackLog >= SOMAXCONN)
else if (USocket::iBackLog > SOMAXCONN)
{
int value = USocket::iBackLog * 2;
// NB: take a look at `netstat -s | grep overflowed`
sysctl_somaxconn = UFile::setSysParam("/proc/sys/net/core/somaxconn", value);
sysctl_max_syn_backlog = UFile::setSysParam("/proc/sys/net/ipv4/tcp_max_syn_backlog", value * 2);
sysctl_somaxconn = UFile::setSysParam("/proc/sys/net/core/somaxconn", USocket::iBackLog);
if (sysctl_somaxconn == USocket::iBackLog) sysctl_max_syn_backlog = UFile::setSysParam("/proc/sys/net/ipv4/tcp_max_syn_backlog", USocket::iBackLog * 8);
else
{
U_WARNING("The TCP backlog (LISTEN_BACKLOG) setting of %u cannot be enforced because of OS error - "
"/proc/sys/net/core/somaxconn is set to the lower value of %u", USocket::iBackLog, SOMAXCONN);
}
}
# endif
@ -2381,7 +2385,7 @@ void UServer_Base::init()
if (handler_inotify) UNotifier::min_connection++;
}
UNotifier::max_connection = (UNotifier::max_connection ? UNotifier::max_connection : USocket::iBackLog / 2) + (UNotifier::num_connection = UNotifier::min_connection);
UNotifier::max_connection = (UNotifier::max_connection ? UNotifier::max_connection : USocket::iBackLog) + (UNotifier::num_connection = UNotifier::min_connection);
if (num_client_threshold == 0) num_client_threshold =
# ifndef U_SERVER_CHECK_TIME_BETWEEN_REQUEST

View File

@ -15,7 +15,7 @@
#include <ulib/utility/uhttp.h>
#include <ulib/ssl/net/ssl_session.h>
/*
/**
* Forward secrecy
*
* You should consider forward secrecy. Forward secrecy means that the keys for a connection aren't stored on disk.

View File

@ -646,12 +646,22 @@ bool UHTTP::UCServletPage::compile(const UString& program)
/* You may also open a dll with tcc_add_file() and use symbols from that */
# ifdef DEBUG
(void) U_SYSCALL(tcc_add_file, "%p,%S,%d", s, U_PREFIXDIR "/lib/libulib_g.so");
# ifdef HAVE_ARCH64
# ifdef DEBUG
# define U_LIB_SO U_PREFIXDIR "/lib64/libulib_g.so"
# else
# define U_LIB_SO U_PREFIXDIR "/lib64/libulib.so"
# endif
# else
(void) U_SYSCALL(tcc_add_file, "%p,%S,%d", s, U_PREFIXDIR "/lib/libulib.so");
# ifdef DEBUG
# define U_LIB_SO U_PREFIXDIR "/lib/libulib_g.so"
# else
# define U_LIB_SO U_PREFIXDIR "/lib/libulib.so"
# endif
# endif
(void) U_SYSCALL(tcc_add_file, "%p,%S,%d", s, U_LIB_SO);
int rc;
UString token;
uint32_t pos = 0;
@ -1265,15 +1275,28 @@ next:
if (rlim > 1024)
{
struct rlimit nofile = {
rlim, // Soft limit
rlim // Hard limit (ceiling for rlim_cur)
};
/**
* struct rlimit {
* rlim_t rlim_cur; // Soft limit
* rlim_t rlim_max; // Hard limit (ceiling for rlim_cur)
* };
*/
struct rlimit nofile = { rlim, rlim };
if (U_SYSCALL(setrlimit, "%d,%p", RLIMIT_NOFILE, &nofile) == 0)
{
U_SRV_LOG("Updated program fd_max: %u", rlim);
}
else
{
U_WARNING("Your DOCUMENT_ROOT cache may be require at least %u max file descriptors. I can't set maximum open files because of OS error", rlim);
if (U_SYSCALL(getrlimit, "%d,%p", RLIMIT_NOFILE, &nofile) == 0)
{
U_WARNING("Current maximum open files is %u. If you need higher increase 'ulimit -n'", nofile.rlim_max);
}
}
}
#endif