pike.git / lib / modules / Sql.pmod / pgsql_util.pmod

version» Context lines:

pike.git/lib/modules/Sql.pmod/pgsql_util.pmod:236:    final inline object read_buffer(int w) { return i::read_buffer(w); }    final inline int read_sint(int w) { return i::read_sint(w); }    final inline int read_int8() { return i::read_int8(); }    final inline int read_int16() { return i::read_int16(); }    final inline int read_int32() { return i::read_int32(); }    final inline string read_cstring() { return i::read_cstring(); }       final void sendcmd(void|sctype mode,void|pgsql_result portal) {    if(portal)    queueup(portal); -  if(mode==flushlogsend) { -  mode=flushsend; qportals->write(synctransact++); + nosync: +  do { +  switch(mode) { +  default: +  break nosync; +  case syncsend: +  PD(">Sync %d %d Queue\n",synctransact,++queueoutidx); +  add(PGSYNC); +  mode=sendout; +  break; +  case flushlogsend:    PD(">%O %d Queue simplequery %d bytes\n",portal._portalname,    ++queueoutidx,sizeof(this)); -  +  mode=flushsend;    } -  +  qportals->write(synctransact++); +  } while(0);    if(started) {    Thread.MutexKey lock=stashupdate->lock();    if(sizeof(stash)) {    add(stash); stash->clear();    foreach(stashqueue->try_read_array();;pgsql_result portal)    queueup(portal);    }    mode=mergemode(this,mode);    stashflushmode=keep;    lock=0;    }    catch {   outer:    do {    switch(mode) {    default:    break outer; -  case syncsend: -  PD(">Sync %d %d Queue\n",synctransact,++queueoutidx); -  qportals->write(synctransact++); add(PGSYNC); -  break; +     case flushsend:    PD("Flush\n");    add(PGFLUSH);    case sendout:;    }    if(towrite=sizeof(this)) {    PD(">Sendcmd %O\n",((string)this)[..towrite-1]);    towrite-=output_to(socket,towrite);    }    } while(0);
pike.git/lib/modules/Sql.pmod/pgsql_util.pmod:715:    }    _state=closed;    lock=0;    }       final sctype _closeportal(PGplugbuffer plugbuffer) {    sctype retval=keep;    PD("%O Try Closeportal %d\n",_portalname,_state);    Thread.MutexKey lock=closemux->lock();    _fetchlimit=0; // disables further Executes +  int alreadyfilled=sizeof(plugbuffer); +  /* alreadyfilled will be non-zero if a parse request has been queued +  * before the close was initiated. +  * It's a bit of a tricky race, but this check should be sufficient. +  */    switch(_state) {    case portalinit:    _state=closed;    break;    case copyinprogress:    PD("CopyDone\n");    plugbuffer->add("c\0\0\0\4");    case bound:    _state=closed;    lock=0;    PD("Close portal %O\n",_portalname);    if(sizeof(_portalname)) {    plugbuffer->add_int8('C')->add_hstring(({'P',_portalname,0}),4,4);    retval=flushsend;    } else    _unnamedportalkey=0; -  if(!--pgsqlsess->_portalsinflight) { +  if(!--pgsqlsess->_portalsinflight && !alreadyfilled) {    pgsqlsess->_readyforquerycount++;    pgsqlsess->_pportalcount=0;    retval=syncsend;    }    }    lock=0;    return retval;    }       final void _processdataready() {