#139 Creating empty nsv fails in AOLserver 4

closed-fixed
API: Tcl (36)
5
2003-08-08
2003-03-30
No

In AOLserver 3.x, you can create an empty nsv with no
keys (e.g. with
"nsv_array set mynsvname [list]"), and the nsv would
exist. This also
matches the behavior of Tcl Arrays, which is good.

However in AOLserver 4 (I tested beta2 and beta4), it
seems that it is
impossible to create an empty nsv, and when you delete
the last key in
an nsv, the nsv itself is also deleted. This is BAD!

Discussion

  • Andrew Piskorski

    Logged In: YES
    user_id=43168

    This changed nsv behavior is easy to demonstrate like so:

    # Page to test some AOLserver nsv stuff. Seems that
    creating an empty
    # nsv is different between AOLserver 3.x and 4.0.

    set body "\nAOLserver version: [ns_info version]"
    append body "\nTest creating empty nsv:\n"
    set nsv {atp_test_empty_nsv}

    append body "\nnsv should not yet exist:"
    if { ![nsv_array exists $nsv] } {
    append body "\nnsv does NOT exist."
    append body "\nCreating empty nsv with:\n nsv_array set
    $nsv \[list\]"
    nsv_array set $nsv [list]
    } else {
    append body "\nnsv exists."
    }
    append body "\nnsv now SHOULD exist:"
    if { ![nsv_array exists $nsv] } {
    append body "\nnsv does NOT exist."
    } else {
    append body "\nnsv exists."
    }
    append body "\nUnsetting nsv now.\n"
    nsv_unset $nsv

    append body "\nnsv should not yet exist:"
    if { ![nsv_array exists $nsv] } {
    append body "\nnsv does NOT exist."
    append body "\nCreating empty nsv with:\n nsv_set $nsv
    foo bar ; nsv_unset $nsv foo"
    nsv_set $nsv foo bar ; nsv_unset $nsv foo
    } else {
    append body "\nnsv exists."
    }
    append body "\nnsv now SHOULD exist:"
    if { ![nsv_array exists $nsv] } {
    append body "\nnsv does NOT exist."
    } else {
    append body "\nnsv exists."
    }
    append body "\nUnsetting nsv now.\n"
    nsv_unset $nsv

    append body "\n"
    ns_return 200 text/plain $body

     
  • Andrew Piskorski

    Logged In: YES
    user_id=43168

    Output of the above test case will be:

    AOLserver version: 4.0
    Test creating empty nsv:

    nsv should not yet exist:
    nsv does NOT exist.
    Creating empty nsv with:
    nsv_array set atp_test_empty_nsv [list]
    nsv now SHOULD exist:
    nsv does NOT exist.
    Unsetting nsv now.

    nsv should not yet exist:
    nsv does NOT exist.
    Creating empty nsv with:
    nsv_set atp_test_empty_nsv foo bar ; nsv_unset
    atp_test_empty_nsv foo
    nsv now SHOULD exist:
    nsv does NOT exist.
    Unsetting nsv now.

    AOLserver version: 3.3.1+ad13
    Test creating empty nsv:

    nsv should not yet exist:
    nsv does NOT exist.
    Creating empty nsv with:
    nsv_array set atp_test_empty_nsv [list]
    nsv now SHOULD exist:
    nsv exists.
    Unsetting nsv now.

    nsv should not yet exist:
    nsv does NOT exist.
    Creating empty nsv with:
    nsv_set atp_test_empty_nsv foo bar ; nsv_unset
    atp_test_empty_nsv foo
    nsv now SHOULD exist:
    nsv exists.
    Unsetting nsv now.

     
  • Andrew Piskorski

    Logged In: YES
    user_id=43168

    Question: What is the behavior of the Tcl Threading
    Extension with
    respect to this bug? If we load it instead of AOLserver's
    native nsv
    support into AOLserver 4.0, do we get correct behavior?

     
  • Mark Page

    Mark Page - 2003-04-25
    • assigned_to: nobody --> mpagenva
     
  • Mark Page

    Mark Page - 2003-04-25

    Logged In: YES
    user_id=605103

    Problem seems to actually be in the implementation of
    [nsv_array exists varname], which is returning false for
    existing but empty nsvs. This is now fixed in the head
    version of nsd/tclvar.c (and will be included into the next
    tag).

     
  • Elizabeth Thomas

    • status: open --> closed-fixed
     
  • Elizabeth Thomas

    Logged In: YES
    user_id=620872

    Fixed in Aolserver 4.0 (beta 6)

     

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks