Changeset 772:c6969f1af9f3 in freeDiameter
- Timestamp:
- Nov 1, 2011, 6:12:18 PM (13 years ago)
- Branch:
- default
- Phase:
- public
- Files:
-
- 2 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 -
tests/testappacct.c
r771 r772 253 253 { 254 254 PGresult * res; 255 char * s; 255 uint8_t * bs; 256 char * es; 257 size_t l; 258 int i; 256 259 res = PQexec(conn, "SELECT \"Session-Id\" from " TABLE ";"); 257 260 CHECK( PGRES_TUPLES_OK, PQresultStatus(res) ); 258 261 259 262 /* We also check that the Session-Id we retrieve is the same as what we generated earlier (not trashed in the process) */ 260 s = PQgetvalue(res, 0, 0); 261 CHECK( 0, strcmp(s, (char *)sess_bkp) ); 263 es = PQgetvalue(res, 0, 0); 264 bs = PQunescapeBytea((uint8_t *)es, &l); 265 266 CHECK( 0, fd_os_cmp(bs, l, sess_bkp, sess_bkp_len) ); 262 267 263 268 PQclear(res); 269 PQfreemem(bs); 264 270 } 265 271
Note: See TracChangeset
for help on using the changeset viewer.