pSpaces / goSpace

Programming with Spaces in Go
MIT License
11 stars 5 forks source link

Remote Get/Query with pattern matching is buggy. #15

Closed albertolluch closed 6 years ago

albertolluch commented 6 years ago

Commands like s.Get(&x) on a remote space s seem to incorrectly block even if there are matching tuples in s.

Minimal example:

Server source:

package main

import (
    "fmt"
    . "github.com/pspaces/gospace"
)

func main() {
    fmt.Printf("Creating space...\n")
    space := NewSpace("tcp://localhost/space")
    space.Query("done")
}

Client source:

package main

import (
    "fmt"
    . "github.com/pspaces/gospace"
)

func main() {

    fmt.Printf("Connecting to remote space...\n")
    space := NewRemoteSpace("tcp://localhost/space")
    fmt.Printf("Connection established.\n")
    var x int
    x = 0
    space.Put(1)
    //space.Get(1) // this succeeds
    space.Get(&x) // this fails and blocks forever
    fmt.Printf("x is %d\n", x)
    fmt.Printf("Done testing.\n")
}
ghost commented 6 years ago

This is not a bug.

This is how TCP protocol works: only a single application can be bound to a port. The UDP protocol does not have this issue for example.

By default, both the client and server will try to bind to port 31415 as specified by the pSpace specification.

This can be circumvented in two ways by:

albertolluch commented 6 years ago

I see the problem. Let's discuss this when you start implementing repositories and gates.