Alexander V. Klepikov wrote: >... If connection to DB fails, PQfinish(pg_sock->conn) is called, which frees > pg_sock->conn - need to do this is described in libpq docs. So even in case > of unsuccessefull connection we have good "database handle" sqlsocket->conn, > which should not be NULL.
If pg_sock->conn is freed, that pointer MUST be set to NULL. > According to this, I can make a conclusion that when database handle is > checked for connectivity (in rlm_sql module), sqlsocket->state should be > used. No. sqlsocket->state is redundant. If the "conn" handle exists, it MUST be a valid connection handle. If it's not valid, it's NULL, and therefore the socket is disconnected. > In theory, sqlsocket->state can equals to sockconnected when actually > it is disconnected. That's a bug. It's wrong and MUST be fixed. > It seemes to me, actually this can happen very rarely. > May be, state of connection should be checked before running every SQL query > to minimize risk of operation on disconnected DB, but I believe it's not > necessary yet. Besides, it will require to modify all sql drivers. Then we modify all of the SQL drivers. Alan DeKok. -- http://deployingradius.com - The web site of the book http://deployingradius.com/blog/ - The blog - List info/subscribe/unsubscribe? See http://www.freeradius.org/list/users.html