pike.git / lib / modules / Protocols.pmod / LysKOM.pmod / Raw.pike

version» Context lines:

pike.git/lib/modules/Protocols.pmod/LysKOM.pmod/Raw.pike:22:      //---------------- raw protocol --------------------------      /* connection object */   object con;      /* receive buffer */   string buf="";      /* outstanding calls */ - // static private + // private   mapping(int:function(string:void)) async=([]);   int ref=1;      /* asynchronous messages callback list */   mapping(int:array(function(string:void))) async_callbacks=([]);      /* max number of outstanding requests */   int max_out_req=4;      /* queue of send-objects */
pike.git/lib/modules/Protocols.pmod/LysKOM.pmod/Raw.pike:46:   int out_req;         /*--- send/recv ------------------------ */      protected inline int conwrite(string what)   {   #ifdef LYSKOM_DEBUG    werror("-> %O\n",what);   #endif +  if (!con) return 0;    int i=con->write(what)==sizeof(what);    if (!i) { werror("write failed!!!\n"); _exit(1); }    return i;   }      class Send   {    int ref;    string request;    function(string:void) callback;       void create(int rf,string r,function(string:void) c)    {    ref=rf;    request=r;    callback=c;    } -  int cast(string i) { return ref; } +  protected int cast(string type) +  { +  if( type=="int" ) +  return ref; +  return UNDEFINED; +  }    void write()    {    out_req++;    async[ref]=callback;    conwrite(ref+" "+request+"\r\n");   #ifdef LYSKOM_DEBUG   // werror("LYSKOM inserting callback %O for call %d\n",callback,ref);   // werror("async: %O\n",async);   #endif    }
pike.git/lib/modules/Protocols.pmod/LysKOM.pmod/Raw.pike:270:    string s;    while ((s=con->read(8192,1)))    {    if (s=="")    {    connection_lost();    return;    }    recv(0,s);    } +  connection_lost();   }      #if constant(thread_create) && !LYSKOM_UNTHREADED   Thread.Fifo call_fifo=Thread.Fifo();      void call_thread()   {    array a;    while ( (a=call_fifo->read()) )    a[0](a[1]);
pike.git/lib/modules/Protocols.pmod/LysKOM.pmod/Raw.pike:475:    }    }       return ({0,0}); // incomplete   }         void got_reply(int ref,object|array what)   {   // werror("got_reply(): async: %O\n",async); -  function call=async[ref]; +  function call = m_delete(async,ref); +    #ifdef LYSKOM_DEBUG   // werror("LYSKOM removing callback %O for call %d\n",call,ref);   #endif -  m_delete(async,ref); +     if (!call)    {    werror("LysKOM.Raw: lost callback for call %d %s\n",ref, -  zero_type(call)?"(lost from mapping??!)":"(zero value in mapping)"); +  undefinedp(call)?"(lost from mapping??!)":"(zero value in mapping)");    werror(master()->describe_backtrace(backtrace()));    return;    }   #if constant(thread_create) && !LYSKOM_UNTHREADED    call_fifo->write( ({call,what}) );   #else    call_out(call,0,what);   #endif   }      void delete_async(int ref)   {    m_delete(async,ref);   }      void add_async_callback(string which, function what, int dont_update)   {    int no=.ASync.name2no[which];    -  if (!no && zero_type(.ASync.name2no[which])) +  if (!no && !has_index(.ASync.name2no, which))    throw(LysKOMError( -1,"LysKOM: unsupported async",    sprintf("There is no supported async call named %O",    which) ));       if (!async_callbacks[no]) async_callbacks[no]=({what});    else async_callbacks[no]+=({what});   }      void remove_async_callback(string which, function what, void|int dont_update)   {    int no=.ASync.name2no[which];    -  if (!no && zero_type(.ASync.name2no[which])) +  if (!no && !has_index(.ASync.name2no, which))    throw(LysKOMError( -1,"LysKOM: unsupported async",    sprintf("There is no supported async call named %O",    which) ));       async_callbacks[no]-=({what});   }      array active_asyncs()   {    foreach (indices(async_callbacks),int z)