xdenser / node-firebird-libfbclient

Firebird SQL binding
MIT License
82 stars 34 forks source link

Multiple events issue #56

Closed jacobalberty closed 7 years ago

jacobalberty commented 9 years ago

Trying to listen for multiple events this program seems work fine if i pass just one event on the command line but when i pass mnultiple events i get multiple fires of random events that seemingly have no pattern, a couple fire right in the beginning and then some fire with each actual fire. Is there something broken in the code? or am I just crazy for trying to listen to multiple events in a single connection?

var fb = require("./node_modules/firebird");

var con = fb.createConnection();

var eventcb = function(event, count) {
    console.log("event: " + event + "(" + count + ")");
};

con.connect('fb:test.fdb', 'SYSDBA', 'masterkey', '', function(err) {
    if (err)
        throw err;
    console.log('connected');
    var events = process.argv.slice(2);

    events.forEach(function(event) {
        con.addFBevent(event);
    });

    con.on("fbevent", eventcb);
});

WaitForFinish(
    function(){ return finished; },
    function(){
        con.disconnect();
    },
    20000
);

var finished = false;

function WaitForFinish(finished,clean,timeout)
{   
    var timedout = false;

    var tid = setTimeout(
        function()
        {   
            timedout = true;
        },
        timeout
    );

    setTimeout(
        function loop()
        {
            if (finished.call() || timedout) {
                clearTimeout(tid);
                clean.call();
            } else {
                setTimeout(loop,100);
            }
        },
        100
    );
}
xdenser commented 9 years ago

I have made a test case for that. It does not seem to be failing. Or maybe I understand you wrong.

jacobalberty commented 9 years ago

Test case looks like its testing what i'm seeing in my system i'll have to test it on mine.

jacobalberty commented 9 years ago

Yep test case fails on mine tried on two different firebird servers (the one from wheezy and the one from jessie) both failed, both times using the client from jessie, any chance anyone has another jessie system handy to confirm its an issue with debian and not something weird about my setup?

xdenser commented 7 years ago

this should work now