Module: sip-router
Branch: 3.1
Commit: d173cc2dab95dba6ededdaa352bf1e2bde1faa0f
URL:
http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=d173cc2…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: Wed Dec 1 23:30:34 2010 +0100
srdb1: keep PID per DB connection
- print warning when PID mismatches - it is cross-process shared DB
connection
- initial patch by Robert Verspuy
(cherry picked from commit f138cce2c0968872f26538983e06a128a1b41344)
---
lib/srdb1/db_id.c | 6 ++++++
lib/srdb1/db_id.h | 1 +
2 files changed, 7 insertions(+), 0 deletions(-)
diff --git a/lib/srdb1/db_id.c b/lib/srdb1/db_id.c
index d55c586..c8db30f 100644
--- a/lib/srdb1/db_id.c
+++ b/lib/srdb1/db_id.c
@@ -30,6 +30,7 @@
#include "db_id.h"
#include "../../dprint.h"
#include "../../mem/mem.h"
+#include "../../pt.h"
#include "../../ut.h"
#include <stdlib.h>
#include <string.h>
@@ -241,6 +242,7 @@ struct db_id* new_db_id(const str* url)
LM_ERR("error while parsing database URL: '%.*s' \n", url->len,
url->s);
goto err;
}
+ ptr->pid = my_pid();
return ptr;
@@ -274,6 +276,10 @@ unsigned char cmp_db_id(const struct db_id* id1, const struct db_id*
id2)
}
if (strcasecmp(id1->host, id2->host)) return 0;
if (strcmp(id1->database, id2->database)) return 0;
+ if(id1->pid!=id2->pid) {
+ LM_WARN("identical DB URLs, but different DB connection pid\n");
+ return 0;
+ }
return 1;
}
diff --git a/lib/srdb1/db_id.h b/lib/srdb1/db_id.h
index 025855f..20ab846 100644
--- a/lib/srdb1/db_id.h
+++ b/lib/srdb1/db_id.h
@@ -40,6 +40,7 @@ struct db_id {
char* host; /**< Host or IP, case insensitive */
unsigned short port; /**< Port number */
char* database; /**< Database, case sensitive */
+ int pid; /**< Process ID (detect cross connections) */
};