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.

files not closing

Help for those learning Tcl or writing their own scripts.
Post Reply
S
ShavdApe
Halfop
Posts: 46
Joined: Mon Dec 15, 2003 5:22 pm

files not closing

Post by ShavdApe »

Having problems with my eggdrops not closing files to the point that they end up reaching the maximum allowed currently set at 1024

using pretty much this code

set found 0
set fs [open $db r]
while {![eof $fs]} {
gets $fs line
if {$line == $word} {
set found 1
}
}
close $fs

if {!$found} {
set wfile [open $db a]
puts $wfile $word
close $wfile
putquick "PRIVMSG .....

}

Did I do something wrong ? Or should I just find another way?
n
nml375
Revered One
Posts: 2860
Joined: Fri Aug 04, 2006 2:09 pm

Post by nml375 »

That code looks perfectly fine, I see one { missing in the beginning, but I guess that's just the proc-head.

Could you add something like this at the end of the proc?

Code: Select all

putlog "Files opened: [file channels]"
NML_375
S
ShavdApe
Halfop
Posts: 46
Joined: Mon Dec 15, 2003 5:22 pm

Post by ShavdApe »

Ok heres what happened in a few minutes
Files opened: stdin stdout stderr
Files opened: file17 stdin file18 stdout file20 file19 stderr file16

Files opened: file22 file17 stdin file18 stdout file20 file19 stderr file21 file16

Files opened: stdin file17 stdout file18 stderr file19 file20 file21 file22 file23 file24 file25 file26 file27 file28 file30 file29 file16

Files opened: file35 stdin file17 stdout file18 stderr file19 file20 file21 file22 file23 file24 file25 file26 file27 file28 file30 file29 file31 file32 file33 file34 file16

You can see how this will quicly become a problem
n
nml375
Revered One
Posts: 2860
Joined: Fri Aug 04, 2006 2:09 pm

Post by nml375 »

Indeed!

What strikes me, however, is that the number of opened files increases by more than 2 for each invocation.. And especially that the number of opened files increases in a non-linear way.

Since you only open the file twice, this suggests that there is some other script in play here that does not clean up file handles properly.
NML_375
S
ShavdApe
Halfop
Posts: 46
Joined: Mon Dec 15, 2003 5:22 pm

Post by ShavdApe »

There is more than one process opening and supposedly closing files but it doesnt appear to do so I have made sure that all the processes call the files by different names so as not to get them confused in any way but nothing I do seems to fix this problem
I have tried just the one process so as to be sure and still I end up with this problem.
n
nml375
Revered One
Posts: 2860
Joined: Fri Aug 04, 2006 2:09 pm

Post by nml375 »

Best advice I can give you right now, is to remove all scripts, and then load them one at a time until the issue returns. That, atleast, should tell you which script is at fault.

Next step would then be to add some putlog's whenever you open or close a file in a script, to keep track of which files are left opened, and where..
NML_375
Post Reply