The code modifies the threads creation with a modified attributes object to limit the stack size.
The Makefile was modified to move the application into the Mail section. Please move the whole application subdirectory to the mail subdirectory after patching. Signed-off-by: Lubos Stanek (lubek) <[email protected]> Index: net/smtptrapd/patches/300-threadstacksize.patch =================================================================== --- net/smtptrapd/patches/300-threadstacksize.patch (revision 0) +++ net/smtptrapd/patches/300-threadstacksize.patch (revision 0) @@ -0,0 +1,62 @@ +diff -urN smtptrapd-1.5/smtptrapd.c smtptrapd-1.5-threadlimit/smtptrapd.c +--- smtptrapd-1.5/smtptrapd.c 2009-04-10 11:36:14.000000000 +0200 ++++ smtptrapd-1.5-threadstacksize/smtptrapd.c 2009-04-10 11:54:10.000000000 +0200 +@@ -39,6 +39,8 @@ + #include <fcntl.h> + #ifdef __linux__ + #include <getopt.h> ++#include <limits.h> ++#define LINUX_THREAD_STACK_SIZE (PTHREAD_STACK_MIN * 2) + #endif + + #define LISTEN_PORT 25 +@@ -500,7 +502,7 @@ + return; + } + +-void *consumer(void) { ++void *consumer(void *unused) { + int fd; + + while (1) { +@@ -533,6 +535,8 @@ + + int main(int argc, char **argv) { + pthread_t t; ++ pthread_attr_t attrib; ++ pthread_attr_t *pattrib = NULL; + int s, x, c; + + /* do some config init */ +@@ -691,9 +695,30 @@ + pthread_setconcurrency(config.threads); + #endif + ++#ifdef __linux__ ++ /* The default stack size for threads on linux is very ++ * large. Here we adjust it down. This isn't portable so it ++ * is limited to linux. */ ++ if(pthread_attr_init(&attrib) != 0) { ++ syslog(LOG_CRIT, "error: initializing thread attribute"); ++ close(s); ++ closelog(); ++ exit(EX_OSERR); ++ } ++ ++ if(pthread_attr_setstacksize(&attrib, LINUX_THREAD_STACK_SIZE) != 0) { ++ syslog(LOG_CRIT, "error: setting thread stack size"); ++ close(s); ++ closelog(); ++ exit(EX_OSERR); ++ } ++ ++ pattrib = &attrib; ++#endif /* __linux__ */ ++ + /* create a number of consumer threads */ + for (x = 0; x < config.threads; x++) { +- if (pthread_create(&t, NULL, (void *) consumer, NULL) != 0) { ++ if (pthread_create(&t, pattrib, consumer, NULL) != 0) { + syslog(LOG_CRIT, "error: failed to create thread"); + close(s); + closelog(); Index: net/smtptrapd/Makefile =================================================================== --- net/smtptrapd/Makefile (revision 15207) +++ net/smtptrapd/Makefile (working copy) @@ -9,7 +9,7 @@ PKG_NAME:=smtptrapd PKG_VERSION:=1.5 -PKG_RELEASE:=1 +PKG_RELEASE:=2 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz PKG_SOURCE_URL:=...@sf/$(PKG_NAME) @@ -18,8 +18,8 @@ include $(INCLUDE_DIR)/package.mk define Package/smtptrapd - SECTION:=net - CATEGORY:=Network + SECTION:=mail + CATEGORY:=Mail DEPENDS:=+libpthread TITLE:=SMTP Trap Daemon URL:=http://smtptrapd.sourceforge.net/ _______________________________________________ openwrt-devel mailing list [email protected] https://lists.openwrt.org/mailman/listinfo/openwrt-devel
