Branch: Tag:

2016-02-27

2016-02-27 23:31:16 by Stephen R. van den Berg <srb@cuci.nl>

pgsql: Move real close into the destructor.

Also destruct the conxion object directly, to make sure that the
filedescriptors actually get closed.

338:    }       final int close() { -  int ret=0; -  if(!closenext && nostash) -  { Thread.MutexKey lock=i->fillreadmux->lock(); +  if(!closenext && nostash) { +  closenext=1; +  Thread.MutexKey lock=i->fillreadmux->lock();    if(i->fillread) { // Delayed close() after flushing the output buffer    i->fillread.signal();    i->fillread=0;
348:    lock=0;    PD("%d>Delayed close, flush write\n",socket->query_fd());    i->read_cb(socket->query_id(),0); -  closenext=1; -  } else { +  return 0; +  } else +  return -1; +  } +  +  protected void destroy() { +  if(nostash) { +  catch {    destruct(nostash);    PD("%d>Close socket\n",socket->query_fd()); -  ret=socket->close(); +  socket->close();    foreach(closecallbacks;function(void|mixed:void) closecb;)    closecb();    closecallbacks=(<>); -  +  };    } -  return ret; -  } -  -  protected void destroy() { -  catch(close()); // Exceptions don't work inside destructors +     connectfail=0;    }