Changeset 772:c6969f1af9f3 in freeDiameter for extensions/app_acct
- Timestamp:
- Nov 1, 2011, 6:12:18 PM (12 years ago)
- Branch:
- default
- Phase:
- public
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/app_acct/acct_db.c
r771 r772 59 59 #endif /* TEST_DEBUG */ 60 60 pthread_key_t connk; 61 static char * sql = NULL; /* The buffer that will contain the SQL query */ 62 static int nbrecords = 0; 61 63 62 64 … … 66 68 struct acct_record_list emptyrecords; 67 69 struct fd_list * li; 68 char * sql=NULL; /* The buffer that will contain the SQL query */69 70 size_t sql_allocd = 0; /* The malloc'd size of the buffer */ 70 71 size_t sql_offset = 0; /* The actual data already written in this buffer */ … … 197 198 } 198 199 PQclear(res); 199 200 free(sql);200 nbrecords = emptyrecords.nball; 201 201 202 acct_rec_empty(&emptyrecords); 202 203 … … 212 213 { 213 214 CHECK_POSIX_DO(pthread_key_delete(connk) , ); 215 free(sql); 214 216 } 215 217 … … 225 227 struct fd_list *li; 226 228 PGconn *conn; 229 int new = 0; 227 230 228 231 TRACE_ENTRY("%p", records); … … 233 236 conn = PQconnectdb(acct_config->conninfo); 234 237 CHECK_POSIX( pthread_setspecific(connk, conn) ); 238 239 new = 1; 235 240 } 236 241 … … 244 249 return ENOTCONN; 245 250 } 251 } 252 253 if (new) { 254 /* Create the prepared statement for this ocnnection, it is not shared */ 255 res = PQprepare(conn, stmt, sql, nbrecords, NULL); 256 if (PQresultStatus(res) != PGRES_COMMAND_OK) { 257 TRACE_DEBUG(INFO, "Preparing statement '%s' failed: %s", 258 sql, PQerrorMessage(conn)); 259 PQclear(res); 260 return EINVAL; 261 } 262 PQclear(res); 246 263 } 247 264
Note: See TracChangeset
for help on using the changeset viewer.