Navigation


Changeset 772:c6969f1af9f3 in freeDiameter for extensions/app_acct


Ignore:
Timestamp:
Nov 1, 2011, 6:12:18 PM (12 years ago)
Author:
Sebastien Decugis <sdecugis@nict.go.jp>
Branch:
default
Phase:
public
Message:

Fix app_acct and associated test

File:
1 edited

Legend:

Unmodified
Added
Removed
  • extensions/app_acct/acct_db.c

    r771 r772  
    5959#endif /* TEST_DEBUG */
    6060pthread_key_t connk;
     61static char * sql = NULL;   /* The buffer that will contain the SQL query */
     62static int nbrecords = 0;
    6163
    6264
     
    6668        struct acct_record_list emptyrecords;
    6769        struct fd_list * li;
    68         char * sql=NULL;   /* The buffer that will contain the SQL query */
    6970        size_t sql_allocd = 0; /* The malloc'd size of the buffer */
    7071        size_t sql_offset = 0; /* The actual data already written in this buffer */
     
    197198        }
    198199        PQclear(res);
    199        
    200         free(sql);
     200        nbrecords = emptyrecords.nball;
     201       
    201202        acct_rec_empty(&emptyrecords);
    202203       
     
    212213{       
    213214        CHECK_POSIX_DO(pthread_key_delete(connk) , );
     215        free(sql);
    214216}
    215217
     
    225227        struct fd_list *li;
    226228        PGconn *conn;
     229        int new = 0;
    227230       
    228231        TRACE_ENTRY("%p", records);
     
    233236                conn = PQconnectdb(acct_config->conninfo);
    234237                CHECK_POSIX( pthread_setspecific(connk, conn) );
     238               
     239                new = 1;
    235240        }
    236241       
     
    244249                        return ENOTCONN;
    245250                }
     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);
    246263        }
    247264       
Note: See TracChangeset for help on using the changeset viewer.