This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

CPU-draining Proc

Old posts that have not been replied to for several years.
Locked
C
ClubCX
Voice
Posts: 35
Joined: Mon Nov 19, 2001 8:00 pm
Location: Bournemouth, UK
Contact:

Post by ClubCX »

I'm having a problem with a proc in my script. It's causing the bots to put a strain on the cpu, so I was wondering if there is a way I could phrase it better in order to be kinder to the shell. I have dozens of bots running the script and can't afford for them to be so crude with resources.


bind time - "*0 * * * *" si_logcheck

proc si_logcheck {min hour day month year} {
foreach logged [userlist L] {
chattr $logged -LD
if {[matchattr $logged B]} {
chattr $logged +L
}
foreach channel [channels] {
if {[handonchan $logged $channel]} {
chattr $logged +L
}
}
}
unset logged
return 1
}


Basically, I want to periodically (no less often than every 15 minutes) make sure that no user retains flag L unless they are online. This is a security flag, and should allow time for the user to quit and return. I'd appreciate any suggestions.

- Tom
http://www.botservice.net
W
Wcc
Master
Posts: 278
Joined: Sun Oct 28, 2001 8:00 pm
Location: USA
Contact:

Post by Wcc »

Change

Code: Select all

if {[handonchan $logged $channel]} { 
	chattr $logged +L
}
to

Code: Select all

if {[handonchan $logged $channel]} { 
	chattr $logged +L
        break
}
You don't need to continue the loop if that if is true. It won't save a whole lot of CPU, but it should help a little.
p
ppslim
Revered One
Posts: 3914
Joined: Sun Sep 23, 2001 8:00 pm
Location: Liverpool, England

Post by ppslim »

Try the following
bind time - "0 * * * *" si_logcheck
proc si_logcheck {min hour day month year} {
foreach user [userlist L] {
set m "LD"
if {[matchattr $user B]} { set m "D" }
foreach chan [channels] {
if {[handonchan $user $chan]} {
set m "D"
break
}
}
chattr $user "-${m}"
}
return 1
}
There should be no need to unset the variables used, as they are automaticaly destroyed upon leaving the proc.

Forum has a little bug slennox.

<font size=-1>[ This Message was edited by: ppslim on 2001-11-25 20:25 ]</font>
Locked