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
5 changes: 5 additions & 0 deletions src/include/ci/internal/opts_citp_def.h
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,11 @@ CI_CFG_OPT("EF_FDTABLE_SIZE", fdtable_size, ci_uint32,
"(help ulimit, man 2 setrlimit) are bound by this value.",
, , 0, MIN, MAX, count)

CI_CFG_OPT("EF_FDS_MAX", fds_max, ci_uint32,
"The value which is set as RLIMIT_NOFILE hard limit if the system value "
"exceeds it. EF_FDTABLE_SIZE overrides it.",
, , 1048576, MIN, MAX, count)

#define CI_UL_LOG_E 0x1 /* errors */
#define CI_UL_LOG_U 0x2 /* unexpected */
#define CI_UL_LOG_S 0x4 /* setup */
Expand Down
9 changes: 9 additions & 0 deletions src/lib/transport/unix/fdtable.c
Original file line number Diff line number Diff line change
Expand Up @@ -500,6 +500,15 @@ int citp_fdtable_ctor()
citp_fdtable.size = 4096;

if( getrlimit(RLIMIT_NOFILE, &rlim) == 0 ) {
/* Handle the case when rlim_max is too huge for malloc(). */
if( rlim.rlim_max > CITP_OPTS.fds_max ) {
Log_S(ci_log("Limit max number of opened files to EF_FDS_MAX=%u value.",
CITP_OPTS.fds_max));
rlim.rlim_max = CITP_OPTS.fds_max;
if( rlim.rlim_cur > rlim.rlim_max )
rlim.rlim_cur = rlim.rlim_max;
CI_TRY(ci_sys_setrlimit(RLIMIT_NOFILE, &rlim));
}
citp_fdtable.size = rlim.rlim_max;
if( CITP_OPTS.fdtable_size != 0 &&
CITP_OPTS.fdtable_size != rlim.rlim_max ) {
Expand Down
2 changes: 0 additions & 2 deletions src/lib/transport/unix/netif_init.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@ int citp_netif_init_ctor(void)
{
Log_S(ci_log("%s()", __FUNCTION__));

citp_set_log_level(CITP_OPTS.log_level);

citp_cmn_netif_init_ctor(CITP_OPTS.netif_dtor);

return 0;
Expand Down
3 changes: 3 additions & 0 deletions src/lib/transport/unix/startup.c
Original file line number Diff line number Diff line change
Expand Up @@ -435,6 +435,7 @@ static void citp_opts_getenv(citp_opts_t* opts)
GET_ENV_OPT_INT("EF_EPOLL_MT_SAFE", ul_epoll_mt_safe);
GET_ENV_OPT_INT("EF_WODA_SINGLE_INTERFACE", woda_single_if);
GET_ENV_OPT_INT("EF_FDTABLE_SIZE", fdtable_size);
GET_ENV_OPT_INT("EF_FDS_MAX", fds_max);
GET_ENV_OPT_INT("EF_SPIN_USEC", ul_spin_usec);
GET_ENV_OPT_INT("EF_SLEEP_SPIN_USEC", sleep_spin_usec);
GET_ENV_OPT_INT("EF_STACK_PER_THREAD",stack_per_thread);
Expand Down Expand Up @@ -582,6 +583,8 @@ citp_transport_init(void)
if( CITP_OPTS.load_env )
citp_opts_getenv(&CITP_OPTS);

citp_set_log_level(CITP_OPTS.log_level);

/* NB. We only look at EF_CONFIG_DUMP if EF_LOAD_ENV. */
if( CITP_OPTS.load_env && getenv("EF_CONFIG_DUMP") ) {
citp_dump_opts(&CITP_OPTS);
Expand Down