Sharing globals btwn conns in outbound tcl interpreter

Homepage Clovertech Forums Read Only Archives Cloverleaf Cloverleaf Sharing globals btwn conns in outbound tcl interpreter

  • Creator
    Topic
  • #48082
    Roger Holmes
    Participant

    HP-UX 11.11

    QDX 5.2

    I have a process with 2 outbound connections that are using the same user defined tcl procedures.  That group of procedures access user defined global variables.  I thought that if I have 2 outbound connections running at the same time, both using the same procedures, that the globals would be shared by both connections.  i.e. if either connection changes the value of the globals, the other connection will see those changes.

    However, this has not been the case.  When both conns are running and changing the values of the globals and I print the values to the log, the values are unique to each conn.  This is what I want, but it is not how I understood it would work.  For example, one global is a counter.  As each thread increments this counter independently and I print out the value after each increment, the value is different for each conn.

    What am I misunderstanding here?

    Thanks,

    Roger

Viewing 2 reply threads
  • Author
    Replies
    • #57584
      Charlie Bursell
      Participant

      Global variables are only global within the same Tcl interpreter.  Each Cloverleaf process has its own interpreters.  There are three interpreters within a process, IB, Xlate, and OB.

      So a an ob_sms-data_proc could share a global with a reply proc for example.

      Take a look at the recover_33 proc, it is based on sharing of a global.  But note that all 3 procs are in the OB thread of the same process.

      Remember when you run a process, you are running a separate instance of the program.  An analogy would be to run ftp and then run another instance of ftp.  Niether is aware of the existance of the other.

    • #57585
      Dennis Pfeifer
      Participant

      One ‘way’ to share the globals across ‘outbound’ connections,

      is to place the proc in the “Xlate Route Details” in the “Post Proc” field.

      Then .. both instances share globals because they are in the same TCL interpreter.

      take care, as ALL Xlates in the process will also have this global.

      i.e. don’t re-use global names in the Pre Proc or Post Proc if they are in the same process. (unless you really want them to share across connections)

      .. just an explanation, each thread has one instance of the TCL interpreter.

      .. so each connection thread has it’s own interpreter.

      .. there is, however, only one translate thread per process, hence .. all Xlates in a process share the same globals ..

      (I haven’t tested this on 5.X .. but .. I don’t think that the design has changed …)

      If someone tests this .. please let the group know ..

      Dennis

    • #57586
      Roger Holmes
      Participant

      Thanks Charlie and Dennis,

      I thought that there was one interpreter for ALL outbound conns in a single process.  I knew separate processes didn’t share the same o/b interpreter.  Thanks for enlightening me about one per each o/b thread in the same process.

      Dennis,

      It does work the same in 5.x.  That is what prompted my mail.

      Thanks again!

Viewing 2 reply threads
  • The forum ‘Cloverleaf’ is closed to new topics and replies.

Forum Statistics

Registered Users
5,117
Forums
28
Topics
9,293
Replies
34,435
Topic Tags
286
Empty Topic Tags
10