| 397 | /************************************************************************/ |
| 398 | |
| 399 | void msConnPoolRelease( layerObj *layer, void *conn_handle ) |
| 400 | |
| 401 | { |
| 402 | int i; |
| 403 | |
| 404 | if( layer->debug ) |
| 405 | msDebug( "msConnPoolRelease(%s,%s,%p)\n", |
| 406 | layer->name, layer->connection, conn_handle ); |
| 407 | |
| 408 | if( layer->connection == NULL ) |
| 409 | return; |
| 410 | |
| 411 | msAcquireLock( TLOCK_POOL ); |
| 412 | for( i = 0; i < connectionCount; i++ ) |
| 413 | { |
| 414 | connectionObj *conn = connections + i; |
| 415 | |
| 416 | if( layer->connectiontype == conn->connectiontype |
| 417 | && strcasecmp( layer->connection, conn->connection ) == 0 |
| 418 | && conn->conn_handle == conn_handle ) |
| 419 | { |
| 420 | conn->ref_count--; |
| 421 | conn->last_used = time(NULL); |
| 422 | |
| 423 | if( conn->ref_count == 0 ) |
| 424 | conn->thread_id = 0; |
| 425 | |
| 426 | if( conn->ref_count == 0 && (conn->lifespan == MS_LIFE_ZEROREF || conn->lifespan == MS_LIFE_SINGLE) ) |
| 427 | msConnPoolClose( i ); |
| 428 | |
| 429 | msReleaseLock( TLOCK_POOL ); |
| 430 | return; |
| 431 | } |
| 432 | } |
| 433 | |
| 434 | msReleaseLock( TLOCK_POOL ); |
| 435 | |
| 436 | msDebug( "%s: Unable to find handle for layer '%s'.\n", |
| 437 | "msConnPoolRelease()", |
| 438 | layer->name ); |
| 439 | |
| 440 | msSetError( MS_MISCERR, |
| 441 | "Unable to find handle for layer '%s'.", |
| 442 | "msConnPoolRelease()", |
| 443 | layer->name ); |
| 444 | } |
| 445 | |
| 446 | /************************************************************************/ |
| 447 | /* msConnPoolMapCloseUnreferenced() */ |
no test coverage detected