Module: kamailio
Branch: master
Commit: 0bb166deb7fcbc5f0c7aa1bf12fba24ca1d34cf8
URL: 
https://github.com/kamailio/kamailio/commit/0bb166deb7fcbc5f0c7aa1bf12fba24ca1d34cf8

Author: Victor Seva <linuxman...@torreviejawireless.org>
Committer: Victor Seva <linuxman...@torreviejawireless.org>
Date: 2025-08-28T16:00:03+02:00

db_mongodb: support mongo-c-driver version 2

related #4378

---

Modified: src/modules/db_mongodb/Makefile
Modified: src/modules/db_mongodb/mongodb_connection.h

---

Diff:  
https://github.com/kamailio/kamailio/commit/0bb166deb7fcbc5f0c7aa1bf12fba24ca1d34cf8.diff
Patch: 
https://github.com/kamailio/kamailio/commit/0bb166deb7fcbc5f0c7aa1bf12fba24ca1d34cf8.patch

---

diff --git a/src/modules/db_mongodb/Makefile b/src/modules/db_mongodb/Makefile
index 075766ffa7b..07c0bb307a6 100644
--- a/src/modules/db_mongodb/Makefile
+++ b/src/modules/db_mongodb/Makefile
@@ -9,12 +9,17 @@ ifeq ($(CROSS_COMPILE),)
 MONGODBC_BUILDER=$(shell \
        if pkg-config --exists libmongoc-1.0; then \
                echo 'pkg-config libmongoc-1.0'; \
+       elif pkg-config --exists mongoc2; then \
+               echo 'pkg-config mongoc2'; \
        fi)
 endif
 
 ifneq ($(MONGODBC_BUILDER),)
        DEFS += $(shell $(MONGODBC_BUILDER) --cflags)
        LIBS += $(shell $(MONGODBC_BUILDER) --libs)
+       ifneq ($(findstring libmongoc-1.0,$(MONGODBC_BUILDER)),)
+               DEFS += -DHAVE_LIBMONGOC1
+       endif
 else
        DEFS += -I$(LOCALBASE)/include
        LIBS= -L$(LOCALBASE)/lib -lmongoc
diff --git a/src/modules/db_mongodb/mongodb_connection.h 
b/src/modules/db_mongodb/mongodb_connection.h
index 4952619bb82..1ab78476144 100644
--- a/src/modules/db_mongodb/mongodb_connection.h
+++ b/src/modules/db_mongodb/mongodb_connection.h
@@ -25,8 +25,13 @@
 #ifndef _MONGODB_CONNECTION_H_
 #define _MONGODB_CONNECTION_H_
 
+#ifdef HAVE_LIBMONGOC1
 #include <mongoc.h>
 #include <bson.h>
+#else
+#include <mongoc/mongoc.h>
+#include <bson/bson.h>
+#endif
 
 #include "../../lib/srdb1/db_pool.h"
 #include "../../lib/srdb1/db_id.h"

_______________________________________________
Kamailio - Development Mailing List -- sr-dev@lists.kamailio.org
To unsubscribe send an email to sr-dev-le...@lists.kamailio.org
Important: keep the mailing list in the recipients, do not reply only to the 
sender!

Reply via email to