Quick update: namespace route. I tried to import a namespace command from a namespace created in the RivetChildInit script into the TCL Thread and the import failed. That won't work either.
So I think the closest to a solution was if the RivetChildinit vwait forever did not hang the web server, then this would work. On Wed, Jun 13, 2018 at 11:27 AM, Brice Hamon <normandvik...@gmail.com> wrote: > Hi Massimo, > > I created a dummy library which can load in a tclsh. > > The code is attached. > This lib just create a new command called "ydotm" and does nothing > > If you compile this code and create a shared library libtesttclapi.so (the > name is important), you can then call in a tclsh: > > load libtesttclapi.so > puts [ydotm ok] > > You should see: > processCmd called > > Now that would be easier for getting this new command visible in a rvt > page, from this lib loaded in a TCL_Thread() from the RivetInitChild. > > I hope it helps, > > Thank you, > Brice. > > > On Tue, Jun 12, 2018 at 11:01 AM, Brice Hamon <normandvik...@gmail.com> > wrote: > >> Hi Massimo. >> >> Yes it is relevant as it is a command name, and not a variable. >> >> I think I understands what's going on with the Thread. >> >> The thread has its own interpreter created de facto. So my command is >> known only from that interpreter, and not from the Rivet's main interpreter. >> >> >> >> On Tue, Jun 12, 2018 at 10:22 AM, Massimo Manghi <massimo.man...@unipr.it >> > wrote: >> >>> In case I try to test this code I have a question: is the call to [ynet >>> new] relevant somehow? I guess it can be replaced by a function that >>> returns a random string >>> >>> -- Massimo >>> >>> >>> On 06/12/2018 01:40 PM, Brice Hamon wrote: >>> >>>> Hi Massimo, >>>> >>>> Ok we are getting somewhere. >>>> >>>> I started a TCL thread, which loads my lib, create a session and starts >>>> it, followed by a vwait forever. >>>> >>>> This worked. I see the readycmd procedure been called when all the c++ >>>> code is happy. >>>> >>>> It is not that easy to explain so here is what I do in the >>>> RivetChildInit: >>>> >>>> >>>> set tid [thread::create] >>>> >>>> thread::send -async $tid { >>>> >>>> proc ::readycmd {} { >>>> puts [info commands] >>>> puts [namespace children ::] >>>> puts [info procs] >>>> } >>>> >>>> proc ::errorcmd {txt} { >>>> log ERROR "SB: $err" >>>> } >>>> >>>> # Opening the link >>>> if {[catch {load -global libThreadTclApi.so threadtclapi} >>>> err]} { >>>> puts "Error loading the libThreadTclApi.so library: $err" >>>> } >>>> >>>> # Creating a session >>>> set ::sess_ [ynet new] >>>> $::sess_ configure -daemon y1 -port 2002 >>>> $::sess_ configure -readycmd ::readycmd >>>> $::sess_ configure -errorcmd ::errorcmd >>>> $::sess_ open >>>> vwait forever >>>> } >>>> >>>> This code works but still 2 things is happening: >>>> >>>> 1) If the proc readycmd is defined outside the thread's script, the >>>> library is not be able to call it and generates an error. >>>> >>>> 2) on the rvt page, I can't see the ::sess_ variable nor that I see my >>>> library's new command. >>>> >>>> So the there is still things not working as I was hoping they will. >>>> >>>> Thank you, >>>> Brice. >>>> >>>> >>>> >>> Firma il tuo 5 x mille all’Università di Parma e aiuta così i nostri >>> studenti che vogliono realizzare un’esperienza di studio all’estero – >>> Indica 00308780345 nella tua denuncia dei redditi. >>> >> >> >