<pre style='margin:0'>
Joshua Root (jmroot) pushed a commit to branch master
in repository macports-base.
</pre>
<p><a href="https://github.com/macports/macports-base/commit/b856b49512cc7c50bc064f056e97fad7ca5b3f5e">https://github.com/macports/macports-base/commit/b856b49512cc7c50bc064f056e97fad7ca5b3f5e</a></p>
<pre style="white-space: pre; background: #F8F8F8">The following commit(s) were added to refs/heads/master by this push:
<span style='display:block; white-space:pre;color:#404040;'> new b856b49 Always maximise RLIMIT_NOFILE
</span>b856b49 is described below
<span style='display:block; white-space:pre;color:#808000;'>commit b856b49512cc7c50bc064f056e97fad7ca5b3f5e
</span>Author: Joshua Root <jmr@macports.org>
AuthorDate: Sat Dec 10 16:42:39 2016 +1100
<span style='display:block; white-space:pre;color:#404040;'> Always maximise RLIMIT_NOFILE
</span><span style='display:block; white-space:pre;color:#404040;'>
</span><span style='display:block; white-space:pre;color:#404040;'> This should at least work around problems with running out of fds.
</span><span style='display:block; white-space:pre;color:#404040;'> Code calling setrlimit has been moved from one place in tracelib.c and
</span><span style='display:block; white-space:pre;color:#404040;'> put in its own command, which is called from mportinit.
</span><span style='display:block; white-space:pre;color:#404040;'>
</span><span style='display:block; white-space:pre;color:#404040;'> See: https://trac.macports.org/ticket/50986
</span>---
src/macports1.0/macports.tcl | 3 +++
src/pextlib1.0/Pextlib.c | 36 ++++++++++++++++++++++++++++++++++++
src/pextlib1.0/tracelib.c | 19 -------------------
3 files changed, 39 insertions(+), 19 deletions(-)
<span style='display:block; white-space:pre;color:#808080;'>diff --git a/src/macports1.0/macports.tcl b/src/macports1.0/macports.tcl
</span><span style='display:block; white-space:pre;color:#808080;'>index f9cceaf..cb1f76f 100644
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>--- a/src/macports1.0/macports.tcl
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>+++ b/src/macports1.0/macports.tcl
</span><span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -633,6 +633,9 @@ proc mportinit {{up_ui_options {}} {up_options {}} {up_variations {}}} {
</span> # a Tcl error, which can be caught, if necessary.
signal -restart error {TERM INT}
<span style='display:block; white-space:pre;background:#e0ffe0;'>+ # Set RLIMIT_NOFILE to the maximum possible
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set_max_open_files
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span> # set up platform info variables
set os_arch $tcl_platform(machine)
if {$os_arch eq "Power Macintosh"} {set os_arch "powerpc"}
<span style='display:block; white-space:pre;color:#808080;'>diff --git a/src/pextlib1.0/Pextlib.c b/src/pextlib1.0/Pextlib.c
</span><span style='display:block; white-space:pre;color:#808080;'>index 03e6732..2482466 100644
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>--- a/src/pextlib1.0/Pextlib.c
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>+++ b/src/pextlib1.0/Pextlib.c
</span><span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -46,6 +46,7 @@
</span> /* required for vasprintf(3) on Linux */
#define _GNU_SOURCE
<span style='display:block; white-space:pre;background:#e0ffe0;'>+#include <sys/resource.h>
</span> #include <sys/types.h>
#include <sys/socket.h>
#include <sys/stat.h>
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -612,6 +613,40 @@ int CheckBrokenDNSCmd(ClientData clientData UNUSED, Tcl_Interp *interp, int objc
</span> return TCL_OK;
}
<span style='display:block; white-space:pre;background:#e0ffe0;'>+/*
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set_max_open_files
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ synopsis: set_max_open_files
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ raises the limit of open files to the maximum
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+*/
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+int SetMaxOpenFilesCmd(ClientData clientData UNUSED, Tcl_Interp *interp, int objc UNUSED, Tcl_Obj *CONST objv[] UNUSED)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+{
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ struct rlimit rl;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if (getrlimit(RLIMIT_NOFILE, &rl) == -1) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ Tcl_SetErrno(errno);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ Tcl_ResetResult(interp);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ Tcl_AppendResult(interp, "set_max_open_files: getrlimit failed: ", (char *)Tcl_PosixError(interp), NULL);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ return TCL_ERROR;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ } else {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+#ifdef OPEN_MAX
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if (rl.rlim_max > OPEN_MAX) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ rl.rlim_max = OPEN_MAX;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+#endif
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ rl.rlim_cur = rl.rlim_max;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if (setrlimit(RLIMIT_NOFILE, &rl) == -1) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ Tcl_SetErrno(errno);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ Tcl_ResetResult(interp);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ Tcl_AppendResult(interp, "set_max_open_files: setrlimit failed: ", (char *)Tcl_PosixError(interp), NULL);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ return TCL_ERROR;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ return TCL_OK;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span> int Pextlib_Init(Tcl_Interp *interp)
{
if (Tcl_InitStubs(interp, "8.4", 0) == NULL)
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -672,6 +707,7 @@ int Pextlib_Init(Tcl_Interp *interp)
</span> Tcl_CreateObjCommand(interp, "term_get_size", TermGetSizeCmd, NULL, NULL);
Tcl_CreateObjCommand(interp, "check_broken_dns", CheckBrokenDNSCmd, NULL, NULL);
<span style='display:block; white-space:pre;background:#e0ffe0;'>+ Tcl_CreateObjCommand(interp, "set_max_open_files", SetMaxOpenFilesCmd, NULL, NULL);
</span>
if (Tcl_PkgProvide(interp, "Pextlib", "1.0") != TCL_OK)
return TCL_ERROR;
<span style='display:block; white-space:pre;color:#808080;'>diff --git a/src/pextlib1.0/tracelib.c b/src/pextlib1.0/tracelib.c
</span><span style='display:block; white-space:pre;color:#808080;'>index 5d42e6b..0725b48 100644
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>--- a/src/pextlib1.0/tracelib.c
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>+++ b/src/pextlib1.0/tracelib.c
</span><span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -40,7 +40,6 @@
</span> #include <errno.h>
#include <fcntl.h>
#include <inttypes.h>
<span style='display:block; white-space:pre;background:#ffe0e0;'>-#include <limits.h>
</span> #include <pthread.h>
#include <signal.h>
#include <stdarg.h>
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -52,7 +51,6 @@
</span> #if HAVE_SYS_EVENT_H
#include <sys/event.h>
#endif
<span style='display:block; white-space:pre;background:#ffe0e0;'>-#include <sys/resource.h>
</span> #include <sys/socket.h>
#include <sys/time.h>
#include <sys/types.h>
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -649,28 +647,11 @@ static void dep_check(int sock, char *path) {
</span>
static int TracelibOpenSocketCmd(Tcl_Interp *in) {
struct sockaddr_un sun;
<span style='display:block; white-space:pre;background:#ffe0e0;'>- struct rlimit rl;
</span>
if (-1 == (sock = socket(PF_LOCAL, SOCK_STREAM, 0))) {
return error2tcl("socket: ", errno, in);
}
<span style='display:block; white-space:pre;background:#ffe0e0;'>- /* raise the limit of open files to the maximum from the default soft limit
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- * of 256 */
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- if (getrlimit(RLIMIT_NOFILE, &rl) == -1) {
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- ui_warn(interp, "getrlimit failed (%d), skipping setrlimit", errno);
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- } else {
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-#ifdef OPEN_MAX
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- if (rl.rlim_max > OPEN_MAX) {
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- rl.rlim_max = OPEN_MAX;
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- }
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-#endif
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- rl.rlim_cur = rl.rlim_max;
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- if (setrlimit(RLIMIT_NOFILE, &rl) == -1) {
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- ui_warn(interp, "setrlimit failed (%d)", errno);
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- }
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- }
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-
</span> sun.sun_family = AF_UNIX;
strlcpy(sun.sun_path, name, sizeof(sun.sun_path));
</pre><pre style='margin:0'>
</pre>