]> the.earth.li Git - onak.git/blobdiff - keydb_pg.c
Add ability to drop overly large packets
[onak.git] / keydb_pg.c
index ca7e35bac0545796f4fe32c768a4b47af2ec78d0..0b58d28f6e753e4d1563db777105da0b8a9b99b3 100644 (file)
@@ -13,8 +13,7 @@
  * more details.
  *
  * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc., 51
- * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * this program.  If not, see <https://www.gnu.org/licenses/>.
  */
 
 #include <postgresql/libpq-fe.h>
@@ -666,7 +665,7 @@ static void pg_cleanupdb(struct onak_dbctx *dbctx)
  *     this file are called in order to allow the DB to be initialized ready
  *     for access.
  */
-struct onak_dbctx *keydb_pg_init(bool readonly)
+struct onak_dbctx *keydb_pg_init(struct onak_db_config *dbcfg, bool readonly)
 {
        struct onak_dbctx *dbctx;
        PGconn *dbconn;
@@ -675,14 +674,15 @@ struct onak_dbctx *keydb_pg_init(bool readonly)
        if (dbctx == NULL) {
                return NULL;
        }
+       dbctx->config = dbcfg;
 
-       dbconn = PQsetdbLogin(config.pg_dbhost, // host
+       dbconn = PQsetdbLogin(dbcfg->hostname, // host
                        NULL, // port
                        NULL, // options
                        NULL, // tty
-                       config.pg_dbname, // database
-                       config.pg_dbuser,  //login
-                       config.pg_dbpass); // password
+                       dbcfg->location, // database
+                       dbcfg->username,  //login
+                       dbcfg->password); // password
 
        if (PQstatus(dbconn) == CONNECTION_BAD) {
                logthing(LOGTHING_CRITICAL, "Connection to database failed.");