Exemplo n.º 1
0
void msConnPoolFinalCleanup()

{
  /* this really needs to be commented out before commiting.  */
  /* msDebug( "msConnPoolFinalCleanup()\n" ); */

  msAcquireLock( TLOCK_POOL );
  while( connectionCount > 0 )
    msConnPoolClose( 0 );
  msReleaseLock( TLOCK_POOL );
}
Exemplo n.º 2
0
void msConnPoolRelease( layerObj *layer, void *conn_handle )

{
    int  i;

    if( layer->debug )
        msDebug( "msConnPoolRelease(%s,%s,%p)\n",
                 layer->name, layer->connection, conn_handle );

    if( layer->connection == NULL )
        return;

    msAcquireLock( TLOCK_POOL );
    for( i = 0; i < connectionCount; i++ )
    {
        connectionObj *conn = connections + i;

        if( layer->connectiontype == conn->connectiontype
            && strcasecmp( layer->connection, conn->connection ) == 0 
            && conn->conn_handle == conn_handle )
        {
            conn->ref_count--;
            conn->last_used = time(NULL);

            if( conn->ref_count == 0 )
                conn->thread_id = 0;

            if( conn->ref_count == 0 && (conn->lifespan == MS_LIFE_ZEROREF || conn->lifespan == MS_LIFE_SINGLE) )
                msConnPoolClose( i );

            msReleaseLock( TLOCK_POOL );
            return;
        }
    }

    msReleaseLock( TLOCK_POOL );

    msDebug( "%s: Unable to find handle for layer '%s'.\n",
             "msConnPoolRelease()",
             layer->name );

    msSetError( MS_MISCERR, 
                "Unable to find handle for layer '%s'.",
                "msConnPoolRelease()",
                layer->name );
}
Exemplo n.º 3
0
void msConnPoolCloseUnreferenced()

{
  int  i;

  /* this really needs to be commented out before commiting.  */
  /* msDebug( "msConnPoolCloseUnreferenced()\n" ); */

  msAcquireLock( TLOCK_POOL );
  for( i = connectionCount - 1; i >= 0; i-- ) {
    connectionObj *conn = connections + i;

    if( conn->ref_count == 0 ) {
      /* for now we don't assume the locks are re-entrant, so release */
      /* it so msConnPoolClose() can get it.  */
      msConnPoolClose( i );
    }
  }
  msReleaseLock( TLOCK_POOL );
}