first, create remote.conf file manually, and then edit the /opt/etc/init.d/S57amuled
Code:........... start() { set backup=$HOME echo "Starting amuled..." echo "Configuration's setting are located in /opt/share/amule" export HOME=/opt/share/amule /opt/bin/amuled -f /opt/bin/amuleweb --config-file=/opt/share/amule/.aMule/remote.conf --quiet & export HOME=$backup echo "done" } ..........
this script restart amuled if it crashes.
(it does not guard amuleweb)
this script could be run with command like /opt/sbin/amule_check & in post-mount scriptCode:while true; do PID=`ps | grep amuled | grep -v grep` if ! test -z "$PID"; then PID=`su amule -c "amulecmd -f ~/.aMule/amule.conf -c status" | grep "Succeeded! Connection established"` fi if test -z "$PID"; then #running problems, restart killall amuled 2>/dev/null killall amuleweb 2>/dev/null sleep 1 killall -9 amuled 2>/dev/null killall -9 amuleweb 2>/dev/null sleep 1 su amule -c"amuled -f >/dev/null" fi sleep 5 done
PS. Please, note script does not uses standard S57amuled to run amule, because running amule as a root is not a good idea IMHO.
It seems that the large file crash problem is solved, thanks to the clue from dimonb. It is specific for uclibc and to some extent mipsel. I already posted detailed report in the Russian thread:
http://www.wl500g.info/showthread.php?p=51681#post51681
It happens because of buggy (or feature-rich?) setrlimit of uclibc. Maximum value of RLIMIT_FSIZE is RLIM_INFINITY which is defined as either (~0UL), or (~0UL >> 1) (latter includes also mips). setrlimit because of unknown idea of developer makes once again >> 1 . This is where 1Gb comes from.
If I execute 'strace amuled -f 2> log.log' I get:
After patching strace gives:Code:getrlimit(RLIMIT_DATA, {rlim_cur=RLIM_INFINITY, rlim_max=RLIM_INFINITY}) = 0 setrlimit(RLIMIT_DATA, {rlim_cur=1073741823, rlim_max=1073741823}) = 0 getrlimit(RLIMIT_FSIZE, {rlim_cur=RLIM_INFINITY, rlim_max=RLIM_INFINITY}) = 0 setrlimit(RLIMIT_FSIZE, {rlim_cur=1073741823, rlim_max=1073741823}) = 0 getrlimit(RLIMIT_NOFILE, {rlim_cur=1024, rlim_max=1024}) = 0 setrlimit(RLIMIT_NOFILE, {rlim_cur=1024, rlim_max=1024}) = 0 getrlimit(RLIMIT_RSS, {rlim_cur=7401488, rlim_max=4735824}) = 0 setrlimit(RLIMIT_RSS, {rlim_cur=720283552, rlim_max=2147449912
After patching it seems that the problem of maximum file size waived at all (at least till 4Gb size, as larger files are not supported by aMule at all):Code:getrlimit(RLIMIT_DATA, {rlim_cur=RLIM_INFINITY, rlim_max=RLIM_INFINITY}) = 0 getrlimit(RLIMIT_FSIZE, {rlim_cur=RLIM_INFINITY, rlim_max=RLIM_INFINITY}) = 0 getrlimit(RLIMIT_NOFILE, {rlim_cur=1024, rlim_max=1024}) = 0 getrlimit(RLIMIT_RSS, {rlim_cur=RLIM_INFINITY, rlim_max=RLIM_INFINITY}) = 0
2oleo or someone involved in development. Could you please "peer review" this stuff and if you find it sane submit in a right place. It's my first development under linux (which consists of a double slash ).Code:_llseek(13, 4205578240, [4205578240], SEEK_SET) = 0 write(13, "\210\302\2568\10\25\322\16\225\350!\372\200OQ\6x\326\362"..., 10240) = 10240 _llseek(13, 4205598720, [4205578240], SEEK_SET) = 0 write(13, "\216\35{\312\347\305\271\247\243{\206\202\357\254\311`"..., 10240) = 10240 _llseek(13, 4205608960, [4205608960], SEEK_SET) = 0 write(13, "\36\250\2732;\354C!\356\232\376\352\365\202\177,~h\233"..., 10240) = 10240
I suggest also to change S57amuled again to something like this:
I believe we have to enforce the user to chose more safe way.Code:#!/bin/sh PATH=/sbin:/bin:/usr/bin:/usr/sbin:/opt/bin:/opt/sbin #It is not safe to run amuled by the root #Before the first run you have to create user p2p or whichever you like USER=p2p DIR=/opt/home/p2p DAEMON=/opt/bin/amuled NAME=amuled NAME2=amuleweb start() { echo "Configuration's setting are located in $DIR" echo -n "Starting $NAME... " su $USER -c "export HOME=$DIR && $DAEMON -f" echo "done" } stop() { echo -n "Shutting down $NAME... " killall $NAME killall $NAME2 echo "done" } case "$1" in start) start ;; stop) stop ;; restart) stop sleep 1 start ;; *) echo "Usage: $0 (start|stop|restart)" exit 1 ;; esac
Could you post a patch to amule with "diff -u old new" here. I have also upgraded uclibc to 0.9.28.3 and waiting to upgrade the feeds as all of them should be rebuilded.
OK, now I hope I did the patch correctly.
Patch added with http://trac.nslu2-linux.org/optware/changeset/5903
Not very clever though. We could also go undefining HAVE_ or setting
to make it universal. But until then, ...PHP Code:
#ifndef __UCLIBC__
#endif
Even better approach would be to fix uclibc's setrlimit to make it arch dependent instead of weird >>1 , as any application in optware/oleg feed using this function has this problem.
However, at the moment this is not the biggest problem. After your compilation the issue is not solved. The patch is applied, because there are no calls to setrlimit, however, getrlimit returns 700Mb instead of RLIM_INFINITY.
So, in the new build file-size-limit is lower than before. This behavior is not related to my patch, but might be due to the changes in the uclibc library, or differences in the build system, (or even in the execution environment?). The second is most likely. The size of my amuled binary is 3723Mb, the size of you binary is 3243Mb.Code:getrlimit(RLIMIT_DATA, {rlim_cur=716175296, rlim_max=720250752}) = 0 getrlimit(RLIMIT_FSIZE, {rlim_cur=716175296, rlim_max=720250752}) = 0 getrlimit(RLIMIT_NOFILE, {rlim_cur=716175296, rlim_max=720250752}) = 0 getrlimit(RLIMIT_RSS, {rlim_cur=7401488, rlim_max=9442296}) = 0
Here is my build system (created according to http://www.nslu2-linux.org/wiki/Optw...ckageToOptware ):
openSuSE 10.2
mkdir /opt/optware
cd /opt/optware
svn co http://svn.nslu2-linux.org/svnroot/optware/trunk optware
edit /opt/optware/Makefile : OPTWARE_TARGET ?= oleg
make directories ipkg-utils
make
After compiling toolchain and creation of about 10 packs (including amule-2.1.3-6.ipk) I stopped it. Then I edited /opt/optware/builds/amule/src/amule.cpp
I was compiling it while being in /opt/optware with make amule
What is wrong?
Could you please verify if the updated uclibc library works without your patch. I am planning to merge uclibc-unstable branch back to trunk.
Here is what you do:
You will need to replace all packages on your system with packages that you built. This means at least uclibc-opt, ipkg-opt, amule and dependent packages.Code:svn co http://svn.nslu2-linux.org/svnroot/optware/branches/uclibc-unstable unstable cd unstable export OPTWARE_TARGET=oleg make directories make toolchain make amule
Newest toolchain uses gcc 4.1.2 and latest uclibc 0.9.28.3
I did not verify if limits work as espected, but I've created this branch to softland mediatomb exception handling with SJLJ.
If you will find that amule have the same symptmoms, then we will create patch for uclibc! Either by backport from 0.9.29 or from scratch.
OK, I hope I did what you've expected.
I compiled the unstable toolchain and packages as you wrote. Then I set up a spare flash-drive as /opt and started to install newly compiled packages as usually:
mkdir /opt/tmp
mkdir /opt/tmp/ipkg
ipkg.sh update
ipkg.sh install ipkg
after that i started to install locally compiled packages. I haven't succeed only with ipkg-opt, as ipkg was already installed
amule shows:
as a response toCode:getrlimit(RLIMIT_DATA, {rlim_cur=RLIM_INFINITY, rlim_max=RLIM_INFINITY}) = 0 setrlimit(RLIMIT_DATA, {rlim_cur=704010*1024, rlim_max=4674376}) = 0 getrlimit(RLIMIT_FSIZE, {rlim_cur=RLIM_INFINITY, rlim_max=RLIM_INFINITY}) = 0 setrlimit(RLIMIT_FSIZE, {rlim_cur=704010*1024, rlim_max=4674376}) = 0 getrlimit(RLIMIT_NOFILE, {rlim_cur=RLIM_INFINITY, rlim_max=RLIM_INFINITY}) = 0 setrlimit(RLIMIT_NOFILE, {rlim_cur=1024, rlim_max=1024}) = 0 getrlimit(RLIMIT_RSS, {rlim_cur=2147450584, rlim_max=4674512}) = 0 setrlimit(RLIMIT_RSS, {rlim_cur=704010*1024, rlim_max=2147449144}) = 0
Do you understand something? I can only say that while compiling on my computer I get correct initial RLIMITs in all cases. setrlimits works wrong in both cases.Code:static void UnlimitResource(RLIMIT_RESOURCE resType) { #if defined(HAVE_GETRLIMIT) && defined(HAVE_SETRLIMIT) struct rlimit rl; getrlimit(resType, &rl); rl.rlim_cur = rl.rlim_max; setrlimit(resType, &rl); #endif }
Last edited by al37919; 11-04-2007 at 05:37.
To isolate the problem I suggest the folowing program rlimit.c
Compile it with buildroot-4.1.2-13 under router withPHP Code:
#include <sys/time.h>
#include <sys/resource.h>
static void UnlimitResource(int resType)
{
struct rlimit rl;
getrlimit(resType, &rl);
rl.rlim_cur = rl.rlim_max;
setrlimit(resType, &rl);
getrlimit(resType, &rl);
}
int main()
{
UnlimitResource(RLIMIT_DATA);
UnlimitResource(RLIMIT_FSIZE);
UnlimitResource(RLIMIT_NOFILE);
UnlimitResource(RLIMIT_RSS);
}
gcc rlimit.c and report its output of strace ./a.out.
When I've compiled it with buildroot-4.1.1-12 I've got the following result:
That shows filesize limit 1GB limit with current trunk oleg feed.Code:getrlimit(RLIMIT_DATA, {rlim_cur=RLIM_INFINITY, rlim_max=RLIM_INFINITY}) = 0 setrlimit(RLIMIT_DATA, {rlim_cur=1073741823, rlim_max=1073741823}) = 0 getrlimit(RLIMIT_DATA, {rlim_cur=1073741823, rlim_max=1073741823}) = 0 getrlimit(RLIMIT_FSIZE, {rlim_cur=RLIM_INFINITY, rlim_max=RLIM_INFINITY}) = 0 setrlimit(RLIMIT_FSIZE, {rlim_cur=1073741823, rlim_max=1073741823}) = 0 getrlimit(RLIMIT_FSIZE, {rlim_cur=1073741823, rlim_max=1073741823}) = 0 getrlimit(RLIMIT_NOFILE, {rlim_cur=1024, rlim_max=1024}) = 0 setrlimit(RLIMIT_NOFILE, {rlim_cur=1024, rlim_max=1024}) = 0 getrlimit(RLIMIT_NOFILE, {rlim_cur=1024, rlim_max=1024}) = 0 getrlimit(RLIMIT_RSS, {rlim_cur=RLIM_INFINITY, rlim_max=RLIM_INFINITY}) = 0 setrlimit(RLIMIT_RSS, {rlim_cur=1073741823, rlim_max=1073741823}) = 0 getrlimit(RLIMIT_RSS, {rlim_cur=1073741823, rlim_max=1073741823}) = 0 exit(0) = ?
Please give gcc --version to verify that you have correct buildroot and uclibc.
So you need at least ipkg-opt, uclibc-opt, buildroot and strace from unstable branch to verify this.
OK, I did it. I have native-compiled it in the two cases (unstable and stable). The both indicate the same 1Gb problem as you shown and as I shown in my initial post. I'm confused only with uclibc-opt - 0.9.28-13, as I would expect to find here uclibc-opt - 0.9.28.3.
unstable:
stable:PHP Code:
root@wl500g,/opt/tmp> ipkg list_installed
...
buildroot - 4.1.2-13 -
libuclibc++ - 0.2.2-5 -
uclibc-opt - 0.9.28-13 -
...
root@wl500g,/opt/tmp> gcc --version
gcc (GCC) 4.1.2
...
root@wl500g,/opt/tmp> gcc rlimit.c
root@wl500g,/opt/tmp> strace ./a.out
...
getrlimit(RLIMIT_DATA, {rlim_cur=RLIM_INFINITY, rlim_max=RLIM_INFINITY}) = 0
setrlimit(RLIMIT_DATA, {rlim_cur=1073741823, rlim_max=1073741823}) = 0
getrlimit(RLIMIT_DATA, {rlim_cur=1073741823, rlim_max=1073741823}) = 0
getrlimit(RLIMIT_FSIZE, {rlim_cur=RLIM_INFINITY, rlim_max=RLIM_INFINITY}) = 0
setrlimit(RLIMIT_FSIZE, {rlim_cur=1073741823, rlim_max=1073741823}) = 0
getrlimit(RLIMIT_FSIZE, {rlim_cur=1073741823, rlim_max=1073741823}) = 0
getrlimit(RLIMIT_NOFILE, {rlim_cur=1024, rlim_max=1024}) = 0
setrlimit(RLIMIT_NOFILE, {rlim_cur=1024, rlim_max=1024}) = 0
getrlimit(RLIMIT_NOFILE, {rlim_cur=1024, rlim_max=1024}) = 0
getrlimit(RLIMIT_RSS, {rlim_cur=RLIM_INFINITY, rlim_max=RLIM_INFINITY}) = 0
setrlimit(RLIMIT_RSS, {rlim_cur=1073741823, rlim_max=1073741823}) = 0
getrlimit(RLIMIT_RSS, {rlim_cur=1073741823, rlim_max=1073741823}) = 0
PHP Code:
root@wl500g,/opt/tmp> ipkg list_installed | grep -e u[cC]libc
buildroot - 4.1.1-12 - uClibc compilation toolchain
libuclibc++ - 0.2.2-4 - C++ standard library designed for use in embedded systems
uclibc-opt - 0.9.28-12 - micro C library for embedded Linux systems
root@wl500g,/opt/tmp> gcc --version
gcc (GCC) 4.1.1
...
root@wl500g,/opt/tmp> gcc rlimit.c
root@wl500g,/opt/tmp> strace ./a.out
...
getrlimit(RLIMIT_DATA, {rlim_cur=RLIM_INFINITY, rlim_max=RLIM_INFINITY}) = 0
setrlimit(RLIMIT_DATA, {rlim_cur=1073741823, rlim_max=1073741823}) = 0
getrlimit(RLIMIT_DATA, {rlim_cur=1073741823, rlim_max=1073741823}) = 0
getrlimit(RLIMIT_FSIZE, {rlim_cur=RLIM_INFINITY, rlim_max=RLIM_INFINITY}) = 0
setrlimit(RLIMIT_FSIZE, {rlim_cur=1073741823, rlim_max=1073741823}) = 0
getrlimit(RLIMIT_FSIZE, {rlim_cur=1073741823, rlim_max=1073741823}) = 0
getrlimit(RLIMIT_NOFILE, {rlim_cur=1024, rlim_max=1024}) = 0
setrlimit(RLIMIT_NOFILE, {rlim_cur=1024, rlim_max=1024}) = 0
getrlimit(RLIMIT_NOFILE, {rlim_cur=1024, rlim_max=1024}) = 0
getrlimit(RLIMIT_RSS, {rlim_cur=RLIM_INFINITY, rlim_max=RLIM_INFINITY}) = 0
setrlimit(RLIMIT_RSS, {rlim_cur=1073741823, rlim_max=1073741823}) = 0
getrlimit(RLIMIT_RSS, {rlim_cur=1073741823, rlim_max=1073741823}) = 0