<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-gb">
	<link rel="self" type="application/atom+xml" href="https://forum.eggheads.org/app.php/feed/topic/17878" />

	<title>egghelp/eggheads community</title>
	<subtitle>Discussion of eggdrop bots, shell accounts and tcl scripts.</subtitle>
	<link href="https://forum.eggheads.org/index.php" />
	<updated>2013-08-27T06:22:52-04:00</updated>

	<author><name><![CDATA[egghelp/eggheads community]]></name></author>
	<id>https://forum.eggheads.org/app.php/feed/topic/17878</id>

		<entry>
		<author><name><![CDATA[Ofloo]]></name></author>
		<updated>2013-08-27T06:22:52-04:00</updated>

		<published>2013-08-27T06:22:52-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=102000#p102000</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=102000#p102000"/>
		<title type="html"><![CDATA[TCL with threads.]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=102000#p102000"><![CDATA[
an other thing i noticed is that the thread crashes when used after the timeout time, .. the second time first time i noticed it sometimes goes beyond.<br><br>Which made me wonder do i need additional things to keep the thread alive?<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=3151">Ofloo</a> — Tue Aug 27, 2013 6:22 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[Ofloo]]></name></author>
		<updated>2013-08-18T17:21:42-04:00</updated>

		<published>2013-08-18T17:21:42-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=101989#p101989</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=101989#p101989"/>
		<title type="html"><![CDATA[TCL with threads.]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=101989#p101989"><![CDATA[
for some reason, with current 1.8.x eggdrop and tcl8.6 it that tpool_test sample only works in when i run the eggdrop with -nt for some reason, can anyone make up why?<br><br>Also there seems to be a bug in the tpool create, cause when i set -minworkers 1 it seems to block and not create new threads, .. for example if i do tpool::post -nowait it wil not create a new thread it will just wait until the others are finished even if the block the queue, so a new thread doesn't spawn, it will keep the minimum of one thread rather then creating a new one even the max is set to 10, .. so for it to do what i wanted it to do i had to set the minimum to a higher number however i don't see the point on setting max and min if it's not spawning new threads by it self.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=3151">Ofloo</a> — Sun Aug 18, 2013 5:21 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[Ofloo]]></name></author>
		<updated>2010-07-24T19:40:30-04:00</updated>

		<published>2010-07-24T19:40:30-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=93660#p93660</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=93660#p93660"/>
		<title type="html"><![CDATA[TCL with threads.]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=93660#p93660"><![CDATA[
Well started to think what the problem could be about that scope, .. ttrace.tcl and i came up with that they just forgot a piece of code<br><br><br>variable version is missing in the namespace eval<br><br>so if you like to fix ttrace.tcl just add "variable version" right after/below, "namespace eval ttrace {" and everything should work.<br><div class="codebox"><p>Code: </p><pre><code>--- ttrace.tcl  2010-07-25 01:46:47.000000000 +0200+++ ttrace.tcl  2010-07-25 01:43:53.000000000 +0200@@ -46,6 +46,7 @@  namespace eval ttrace { +    variable version     # Setup some compatibility wrappers     if {[info commands nsv_set] != ""} {         variable tvers 0</code></pre></div><p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=3151">Ofloo</a> — Sat Jul 24, 2010 7:40 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[Ofloo]]></name></author>
		<updated>2010-07-23T18:01:04-04:00</updated>

		<published>2010-07-23T18:01:04-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=93648#p93648</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=93648#p93648"/>
		<title type="html"><![CDATA[TCL with threads.]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=93648#p93648"><![CDATA[
hey did same thing for tpool<br><br>while thread is multi thread it's still a single process if that makes any sense, meaning if the thread::send -async is waiting the next one waits as well<br><br>there for tpool you'll notice that after 10000 doesn't have any effect on it while it does on thread for those who want it.<br><br>you could say it is more parallel <br><div class="codebox"><p>Code: </p><pre><code>namespace eval tpool_test {  package require Thread  tsv::set THREAD master [thread::id]   if {![info exists pool]} {    variable pool [tpool::create -minworkers 1 -maxworkers 10 -idletime 120 -initcmd {      package require Thread      proc putserv {text {arg {}}}  {        thread::send -async [tsv::get THREAD master] [concat putserv [list ${text}] ${arg}]      }      proc tpool1_proc {nick host hand chan arg}  {        after 10000        putserv "PRIVMSG #support :REPLY_TPOOL1:[clock seconds]"      }      proc tpool2_proc {nick host hand chan arg}  {        putserv "PRIVMSG #support :REPLY_TPOOL2:[clock seconds]" -next      }    }]  }  proc tpool1_proc_pub {nick host hand chan arg}  {    variable pool    tpool::post -nowait $pool [list tpool1_proc $nick $host $hand $chan $arg]    putserv "PRIVMSG $chan :TPOOL1_DELAY:[clock seconds]"  }  proc tpool2_proc_pub {nick host hand chan arg}  {    variable pool    tpool::post -nowait $pool [list tpool2_proc $nick $host $hand $chan $arg]    putserv "PRIVMSG $chan :TPOOL2_NODELAY:[clock seconds]"  }  bind pub -|- !tpool1 [namespace current]::tpool1_proc_pub  bind pub -|- !tpool2 [namespace current]::tpool2_proc_pub}</code></pre></div><blockquote class="uncited"><div><a href="http://www.tcl.tk/doc/howto/thread_model.html" class="postlink">Tcl's threading model</a> is <strong class="text-strong">one interpreter per thread</strong>. An interpreter is like starting a fresh tclsh, without loading any extensions. I doesn't know about the "parent"s variables or commands, and so Thread interpreters don't know commands from the eggdrop extension or variables. You have to design your own message-passing ([thread::send -async]) so that the threads ask the main thread to do something eggdropish. Example:<div class="codebox"><p>Code: </p><pre><code>proc createusefulthread {} {  set t [thread::create {thread::wait}]  thread::send $t [list set ::mainthread [thread::id]]  thread::send $t {    proc putserv {text} {      thread::send -async $::mainthread [list putserv $text]    }  }  return $t}</code></pre></div>The returned thread knows how to putserv (by asking the mainthread asynchronously to do it).<br><br>Note: I set a variable in the "child" threads called $::mainthread instead of using thread-shared data, because it will always stay the same and will only ever be read, never written or changed. In general, you should consider using thread shared data if this is not the case, of course.</div></blockquote>great i'll give it a shot, one remark to transport variables you better, well better they made a lib to share it so and you never know when you're about to change it, ..so use tsv::set &amp; tsv::get and putserv "text" -next &lt;&lt; forgot this one <img class="smilies" src="https://forum.eggheads.org/images/smilies/icon_wink.gif" width="15" height="15" alt=";)" title="Wink"><br><div class="codebox"><p>Code: </p><pre><code>proc createusefulthread {} {  set t [thread::create {thread::wait}]  tsv::set thread main $t  thread::send $t {    proc putserv {text {arg {}}}  {      thread::send -async [tsv::get thread main] [concat putserv [list ${text}] ${arg}]    }  }  return $t}</code></pre></div><blockquote class="uncited"><div>This is a fault in ttrace.tcl, part of the Thread extension. While it perfectly makes sense for eggdrop to have a global version variable, it's inappropriate and arrogant for a script to abuse such a common name to store a temporary value for one-time use.<br><br> We won't change eggdrop's variable name due to compatibility reasons, so users should modify the ttrace.tcl script, which is easier than modifying eggdrop source anyway. We have filed a bug report for Ttrace in the hope that it will get fixed.</div></blockquote>well i posted it to eggdrop cause i wasn't sure if it belonged in eggdrop or ttrace, or tcl but it's great that you posted the problem in the right place, well i wasn't suggesting you change the source merely posted a quick hack to the problem.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=3151">Ofloo</a> — Fri Jul 23, 2010 6:01 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[thommey]]></name></author>
		<updated>2010-07-23T17:08:28-04:00</updated>

		<published>2010-07-23T17:08:28-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=93647#p93647</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=93647#p93647"/>
		<title type="html"><![CDATA[TCL with threads.]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=93647#p93647"><![CDATA[
<a href="http://www.tcl.tk/doc/howto/thread_model.html" class="postlink">Tcl's threading model</a> is <strong class="text-strong">one interpreter per thread</strong>. An interpreter is like starting a fresh tclsh, without loading any extensions. I doesn't know about the "parent"s variables or commands, and so Thread interpreters don't know commands from the eggdrop extension or variables. You have to design your own message-passing ([thread::send -async]) so that the threads ask the main thread to do something eggdropish. Example:<div class="codebox"><p>Code: </p><pre><code>proc createusefulthread {} {  set t [thread::create {thread::wait}]  thread::send $t [list set ::mainthread [thread::id]]  thread::send $t {    proc putserv {text} {      thread::send -async $::mainthread [list putserv $text]    }  }  return $t}</code></pre></div>The returned thread knows how to putserv (by asking the mainthread asynchronously to do it).<br><br>Note: I set a variable in the "child" threads called $::mainthread instead of using thread-shared data, because it will always stay the same and will only ever be read, never written or changed. In general, you should consider using thread shared data if this is not the case, of course.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=9830">thommey</a> — Fri Jul 23, 2010 5:08 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[pseudo]]></name></author>
		<updated>2010-07-23T15:45:22-04:00</updated>

		<published>2010-07-23T15:45:22-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=93644#p93644</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=93644#p93644"/>
		<title type="html"><![CDATA[TCL with threads.]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=93644#p93644"><![CDATA[
This is a fault in ttrace.tcl, part of the Thread extension. While it perfectly makes sense for eggdrop to have a global version variable, it's inappropriate and arrogant for a script to abuse such a common name to store a temporary value for one-time use.<br><br> We won't change eggdrop's variable name due to compatibility reasons, so users should modify the ttrace.tcl script, which is easier than modifying eggdrop source anyway. We have filed a bug report for Ttrace in the hope that it will get fixed.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=10974">pseudo</a> — Fri Jul 23, 2010 3:45 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[Ofloo]]></name></author>
		<updated>2010-07-22T16:30:58-04:00</updated>

		<published>2010-07-22T16:30:58-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=93629#p93629</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=93629#p93629"/>
		<title type="html"><![CDATA[TCL with threads.]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=93629#p93629"><![CDATA[
i found a solution, however it might not be the simpelest solution.. tried various things today played with it until i got a solution.<br><br>if anyone comes up with a better solution do let me know.<br><div class="codebox"><p>Code: </p><pre><code>package require Threadif {![info exists TID_1]} {  set TID_1 [thread::create {thread::wait}]}if {![info exists TID_2]} {  set TID_2 [thread::create {thread::wait}]}tsv::set MASTER thread [thread::id]proc test_proc {nick host hand chan arg}  {  set TM [tsv::get MASTER thread]  after 10000  thread::send -async $TM [list putserv "PRIVMSG $chan :DELAY 10 seconds"]}proc test_proc2 {nick host hand chan arg}  {  set TM [tsv::get MASTER thread]  thread::send -async $TM [list putserv "PRIVMSG $chan :NO DELAY"]}proc test_proc_pub {nick host hand chan arg}  {  global TID_1  thread::send -async $TID_1 [list test_proc $nick $host $hand $chan $arg]  putserv "PRIVMSG $chan :sending crap to thread 1"}proc test_proc2_pub {nick host hand chan arg}  {  global TID_2  thread::send -async $TID_2 [list test_proc2 $nick $host $hand $chan $arg]  putserv "PRIVMSG $chan :sending crap to thread 2"}bind pub -|- !test test_proc_pubbind pub -|- !test2 test_proc2_pub</code></pre></div>EDIT: bit more simplified version without Ttrace, also no need to edit tcl.c (version) unless you want to use Ttrace.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=3151">Ofloo</a> — Thu Jul 22, 2010 4:30 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[Ofloo]]></name></author>
		<updated>2010-07-22T11:51:58-04:00</updated>

		<published>2010-07-22T11:51:58-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=93622#p93622</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=93622#p93622"/>
		<title type="html"><![CDATA[TCL with threads.]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=93622#p93622"><![CDATA[
*** Ofloo joined the party line.<br>.tcl package require Ttrace<br>Tcl: 2.6.5<br><br><div class="codebox"><p>Code: </p><pre><code>static tcl_strings def_tcl_strings[] = {  {"botnet-nick",     botnetnick,     HANDLEN,                 0},  {"userfile",        userfile,       120,           STR_PROTECT},  {"motd",            motdfile,       120,           STR_PROTECT},  {"admin",           admin,          120,                     0},  {"help-path",       helpdir,        120, STR_DIR | STR_PROTECT},  {"temp-path",       tempdir,        120, STR_DIR | STR_PROTECT},  {"text-path",       textdir,        120, STR_DIR | STR_PROTECT},#ifndef STATIC  {"mod-path",        moddir,         120, STR_DIR | STR_PROTECT},#endif  {"notify-newusers", notify_new,     120,                     0},  {"owner",           owner,          120,           STR_PROTECT},  {"my-ip",           myip,           120,                     0},  {"my-hostname",     hostname,       120,                     0},  {"network",         network,        40,                      0},  {"whois-fields",    whois_fields,   1024,                    0},  {"nat-ip",          natip,          120,                     0},  {"username",        botuser,        10,                      0},  {"version",         egg_version,    0,                       0},  {"firewall",        firewall,       120,                     0},  {"config",          configfile,     0,                       0},  {"telnet-banner",   bannerfile,     120,           STR_PROTECT},  {"logfile-suffix",  logfile_suffix, 20,                      0},  {"timestamp-format",log_ts,         32,                      0},  {"pidfile",         pid_file,       120,           STR_PROTECT},  {NULL,              NULL,           0,                       0}};</code></pre></div>change<br><div class="codebox"><p>Code: </p><pre><code>{"version",         egg_version,    0,                       0},</code></pre></div>into<br><div class="codebox"><p>Code: </p><pre><code>{"versions",         egg_versions,    0,                       0},</code></pre></div>the variable verion doesn't exist then, however it has new name versions, ..<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=3151">Ofloo</a> — Thu Jul 22, 2010 11:51 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[Ofloo]]></name></author>
		<updated>2010-07-22T11:27:30-04:00</updated>

		<published>2010-07-22T11:27:30-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=93621#p93621</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=93621#p93621"/>
		<title type="html"><![CDATA[TCL with threads.]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=93621#p93621"><![CDATA[
an other observation is when i want to load Ttrace<br><div class="codebox"><p>Code: </p><pre><code>[14:21:15] #Ofloo# set errorInfoCurrently: couldn't save command result in variableCurrently:     while executingCurrently: "catch {package require Thread} version"Currently:     (in namespace eval "::ttrace" script line 9)Currently:     invoked from withinCurrently: "namespace eval ttrace {Currently:Currently:     # Setup some compatibility wrappersCurrently:     if {[info commands nsv_set] != ""} {Currently:         variable tvers 0Currently:         variable mu..."Currently:     (file "/usr/local/lib/thread2.6.5/ttrace.tcl" line 47)Currently:     invoked from withinCurrently: "source [file join $dir ttrace.tcl]"Currently:     (procedure "thread_source" line 8)Currently:     invoked from withinCurrently: "thread_source /usr/local/lib/thread2.6.5"Currently:     ("package ifneeded Ttrace 2.6.5" script)Currently:     invoked from withinCurrently: "package require Ttrace".tcl catch {package require Thread} versionTcl error: couldn't save command result in variable.tcl catchTcl error: wrong # args: should be "catch script ?resultVarName? ?optionVarName?".tcl catch {package require Thread} vers   Tcl: 0.set version[14:25:16] #Ofloo# set versionCurrently: 1.6.20+RC2 1062003 PRE-RELEASE 1279200246 RC2</code></pre></div>the problem is that the Ttrace script is trying to overwrite the version varialbe which makes the bot crash/core<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=3151">Ofloo</a> — Thu Jul 22, 2010 11:27 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[Ofloo]]></name></author>
		<updated>2010-07-22T10:07:39-04:00</updated>

		<published>2010-07-22T10:07:39-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=93620#p93620</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=93620#p93620"/>
		<title type="html"><![CDATA[TCL with threads.]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=93620#p93620"><![CDATA[
hi, I'm testing an eggdrop compiled with threads, .. and I was wondering how the namespace thing goes, .. or how it worked .. <br><br>variables and functions are not reconized, .. if i eval the script waits untill the thread is finished obviously this isn't what it is supposed to do.<br><br>basicly variables and functions don't work in this case putserv &amp; $chan.<br><div class="codebox"><p>Code: </p><pre><code>package require Threadset TID1 [thread::create]set TID2 [thread::create]proc test_proc {nick host hand chan arg}  {  global TID1  thread::send -async $TID1 {    after 10000    ::putserv "PRIVMSG $chan:DELAY 10 seconds"  }  putserv "PRIVMSG $chan :Sended to thread with after"}proc test_proc2 {nick host hand chan arg}  {  global TID2  thread::send -async $TID2 {    ::putserv "PRIVMSG $chan :NO DELAY"  }  putserv "PRIVMSG $chan : Sended to thread without after"}bind pub -|- !test test_procbind pub -|- !test2 test_proc2</code></pre></div><p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=3151">Ofloo</a> — Thu Jul 22, 2010 10:07 am</p><hr />
]]></content>
	</entry>
	</feed>
