Mantis Bugtracker

Viewing Issue Simple Details Jump to Notes ] View Advanced ] Issue History ] Print ]
ID Category Severity Reproducibility Date Submitted Last Update
0000334 [Yate - Yet Another Telephony Engine] module major always 2013-02-20 21:37 2013-04-16 12:13
Reporter asymetrixs View Status public  
Assigned To oana
Priority normal Resolution fixed  
Status resolved   Product Version 4.x
Summary 0000334: JS Handler runs SQL not on first but following calls (Engine.enqueue, Engine.dispatch)
Description javascript.conf
[scripts]
cdr_handler=cdr_handler.js

content of cdr_handler.js


function onCDR(message)
{
    var ended = '';
    
    if (message.operation == 'initialize')
    {
        ended = 'false';
    }
    else if (message.operation == 'finalize')
    {
        ended = 'true';
    }
    else
    {
        Engine.debug("UPDATE, NOTHING TO DO HERE");
        return false;
    }
    
    var db = new Message("database");
    db.account = "dbmain";
    
    db.query = "SELECT 0;";
    Engine.debug("QUERY: " + db.query);
    
    if (!db.enqueue())
    {
        Engine.debug("ERROR COULD NOT UPDATE NODE STATISTIC: " + message.billid + " IS " + ended);
        
        Engine.debug("ERR: " + db.error);
    }
    else
    {
        Engine.debug("NODE STATISTIC UPDATE: " + message.billid + " IS " + ended);
    }
    
    return false;
}

Message.install(onCDR, "call.cdr", 90);

Result:
First run (initialize):
<javascript:NOTE> QUERY: SELECT 0;
<JsCode:WARN> Evaluator error: Function 'db.enqueue' call failed in line 25


Following runs (update):
<javascript:NOTE> UPDATE, NOTHING TO DO HERE
...few times

Last run (finalize):
<javascript:NOTE> QUERY: SELECT 0;
<javascript:NOTE> NODE STATISTIC UPDATE: 1361388447-1 IS true


So the first query does not work, the last does. Engine.dispatch shows same behavior. Using "PostgreSQL 9.2.3 on x86_64-unknown-linux-gnu, compiled by gcc (Ubuntu/Linaro 4.6.3-1ubuntu5) 4.6.3, 64-bit" on Ubuntu, Yate Revision is r5413
Additional Information
Tags No tags attached.
Attached Files

- Relationships

-  Notes
(0000515)
asymetrixs (reporter)
2013-02-27 16:27

Added another test:

function onCDR(message)
{
        Engine.debug("==========================================================");
        Engine.debug("==========================================================");
        Engine.debug("==========================================================");

        var ended = '';

        if (message.operation == 'initialize')
        {
                ended = 'false';
        }
        else if (message.operation == 'finalize')
        {
                ended = 'true';
        }
        else
        {
                Engine.debug("UPDATE, nothing to do here");
                return false;
        }

        var db = new Message("database");
        db.account = "dbmain";

        Engine.debug("==========================================================");
        Engine.debug("==========================================================");
        Engine.debug("==========================================================");
        Engine.debug("DB OBJECT OUTPUT:");
        Engine.print_r(db);

        if(db.dispatch())
        {
                Engine.debug("OK");
        }
        else
        {
                Engine.debug("ERROR: " + db.error);
        }

        return false;
}

Message.install(onCDR, "call.cdr", 31);


At First:

20130227142501.782921 <javascript:NOTE> DB OBJECT OUTPUT:
'db' = '' (Undefined)
20130227142501.783684 <JsCode:WARN> Evaluator error: Function 'db.dispatch' call failed in line 32

Then...
20130227142501.812962 <javascript:NOTE> UPDATE, nothing to do here
20130227142501.818776 <javascript:NOTE> UPDATE, nothing to do here
20130227142503.237684 <javascript:NOTE> UPDATE, nothing to do here
20130227142508.581507 <javascript:NOTE> UPDATE, nothing to do here

At last:
20130227142510.856759 <javascript:NOTE> DB OBJECT OUTPUT:
'db' = '[object Message]' (JsObject)
  'freeze' = '[function freeze()]' (ExpFunction)
  'isFrozen' = '[function isFrozen()]' (ExpFunction)
  'toString' = '[function toString()]' (ExpFunction)
  'hasOwnProperty' = '[function hasOwnProperty()]' (ExpFunction)
  'enqueue' = '[function enqueue()]' (ExpFunction)
  'dispatch' = '[function dispatch()]' (ExpFunction)
  'name' = '[function name()]' (ExpFunction)
  'broadcast' = '[function broadcast()]' (ExpFunction)
  'retValue' = '[function retValue()]' (ExpFunction)
  'getColumn' = '[function getColumn()]' (ExpFunction)
  'getRow' = '[function getRow()]' (ExpFunction)
  'getResult' = '[function getResult()]' (ExpFunction)
  '__proto__' = '[object Message]' (JsObject)
    'freeze' = '[function freeze()]' (ExpFunction)
    'isFrozen' = '[function isFrozen()]' (ExpFunction)
    'toString' = '[function toString()]' (ExpFunction)
    'hasOwnProperty' = '[function hasOwnProperty()]' (ExpFunction)
  'account' = 'dbmain' (NamedString)
20130227142510.857166 <javascript:NOTE> OK
(0000516)
paulc (administrator)
2013-03-04 13:29

This is really a parsing error, the instruction

    var db = new Message("database");

is parsed as part of the "else" of the first "if"
(0000518)
paulc (administrator)
2013-04-16 12:13

The issue was solved in SVN Revision 5464 (2013-04-12).

- Issue History
Date Modified Username Field Change
2013-02-20 21:37 asymetrixs New Issue
2013-02-27 16:27 asymetrixs Note Added: 0000515
2013-03-04 13:29 paulc Note Added: 0000516
2013-03-04 13:29 paulc Status new => acknowledged
2013-04-12 18:20 oana Status acknowledged => resolved
2013-04-12 18:20 oana Resolution open => fixed
2013-04-12 18:20 oana Additional Information Updated
2013-04-16 12:13 paulc Note Added: 0000518
2013-04-16 12:13 paulc Assigned To => oana
2013-04-16 12:13 paulc Additional Information Updated


Copyright © 2000 - 2008 Mantis Group
Powered by Mantis Bugtracker