From 83f2fc098f9aaae358cd4682a292d48c44df7021 Mon Sep 17 00:00:00 2001 From: Hans Zandbelt Date: Sun, 21 Dec 2008 20:34:15 +0000 Subject: [PATCH 1/1] workaround asterisk daemon issue #4071 caused by uclibc 0.29 (thanks to charles.kirsch) SVN-Revision: 13712 --- net/asterisk-1.4.x/Makefile | 2 +- .../035-main-asterisk-uclibc-daemon.patch | 42 +++++++++++++++++++ 2 files changed, 43 insertions(+), 1 deletion(-) create mode 100644 net/asterisk-1.4.x/patches/035-main-asterisk-uclibc-daemon.patch diff --git a/net/asterisk-1.4.x/Makefile b/net/asterisk-1.4.x/Makefile index f36ad44e71..b3c5faf046 100644 --- a/net/asterisk-1.4.x/Makefile +++ b/net/asterisk-1.4.x/Makefile @@ -10,7 +10,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=asterisk PKG_VERSION:=1.4.22 -PKG_RELEASE:=1 +PKG_RELEASE:=2 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz PKG_SOURCE_URL:=http://downloads.digium.com/pub/asterisk/releases/ diff --git a/net/asterisk-1.4.x/patches/035-main-asterisk-uclibc-daemon.patch b/net/asterisk-1.4.x/patches/035-main-asterisk-uclibc-daemon.patch new file mode 100644 index 0000000000..262bed4a74 --- /dev/null +++ b/net/asterisk-1.4.x/patches/035-main-asterisk-uclibc-daemon.patch @@ -0,0 +1,42 @@ +diff -Nru asterisk-1.4.22.org/main/asterisk.c asterisk-1.4.22/main/asterisk.c +--- asterisk-1.4.22.org/main/asterisk.c 2008-07-26 17:31:21.000000000 +0200 ++++ asterisk-1.4.22/main/asterisk.c 2008-12-20 22:49:58.000000000 +0100 +@@ -2935,7 +2935,38 @@ + #if HAVE_WORKING_FORK + if (ast_opt_always_fork || !ast_opt_no_fork) { + #ifndef HAVE_SBIN_LAUNCHD ++#ifndef __UCLIBC__ + daemon(1, 0); ++#else ++/* ++ workaround for uClibc-0.9.29 mipsel bug: ++ recursive mutexes do not work if uClibc daemon() function has been called, ++ if parent thread locks a mutex ++ the child thread cannot acquire a lock with the same name ++ (same code works if daemon() is not called) ++ but duplication of uClibc daemon.c code in here does work. ++*/ ++ int fd; ++ switch (fork()) { ++ case -1: ++ exit(1); ++ case 0: ++ break; ++ default: ++ _exit(0); ++ } ++ if (setsid() == -1) ++ exit(1); ++ if (fork()) ++ _exit(0); ++ if ((fd = open("/dev/null", O_RDWR, 0)) != -1) { ++ dup2(fd, STDIN_FILENO); ++ dup2(fd, STDOUT_FILENO); ++ dup2(fd, STDERR_FILENO); ++ if (fd > 2) ++ close(fd); ++ } ++#endif + ast_mainpid = getpid(); + /* Blindly re-write pid file since we are forking */ + unlink(ast_config_AST_PID); -- 2.30.2