<p>There is currently a bug with dialog persistency using postgres database. If OpenSIPS is restarted, all dialogs variables are lost (not read from database at start-up).<br>
The bug comes from this block of code (line 1616 in dlg_db_handler.c)<br>
if (!VAL_NULL(values+18))<br>
read_dialog_vars( VAL_STR(values+18).s,<br>
VAL_STR(values+18).len, known_dlg);<br>
As the DB type for string in db_postgres module is DB_STRING (NULL terminated string), VAL_STR(values+18).len is always 0 (or undefined), hence dialog variables are never read from database.</p>
<p>This bug could be fix by replacing VAL_STR(values+18).len by strlen(VAL_STR(values+18)). However, I think it's better to change DB type for string to DB_STR to avoid this kind of bug in the future.</p>
<hr>
<h4>You can view, comment on, or merge this pull request online at:</h4>
<p> <a href='https://github.com/OpenSIPS/opensips/pull/618'>https://github.com/OpenSIPS/opensips/pull/618</a></p>
<h4>Commit Summary</h4>
<ul>
<li>change default database type for postgres to DB_STR instead of DB_STRING so that code in dialog module that use VAL_STR().len will work. This should be safe as postgres module always put the '\0' at the end of string value so STR value can always be accessed as by STRING type</li>
</ul>
<h4>File Changes</h4>
<ul>
<li>
<strong>M</strong>
<a href="https://github.com/OpenSIPS/opensips/pull/618/files#diff-0">modules/db_postgres/res.c</a>
(6)
</li>
</ul>
<h4>Patch Links:</h4>
<ul>
<li><a href='https://github.com/OpenSIPS/opensips/pull/618.patch'>https://github.com/OpenSIPS/opensips/pull/618.patch</a></li>
<li><a href='https://github.com/OpenSIPS/opensips/pull/618.diff'>https://github.com/OpenSIPS/opensips/pull/618.diff</a></li>
</ul>
<p style="font-size:small;-webkit-text-size-adjust:none;color:#666;">—<br>Reply to this email directly or <a href="https://github.com/OpenSIPS/opensips/pull/618">view it on GitHub</a>.<img alt="" height="1" src="https://github.com/notifications/beacon/AFOcid2jD9MtTsYXhHYr-3GjJfFiIm2-ks5orakvgaJpZM4FygNU.gif" width="1" /></p>
<div itemscope itemtype="http://schema.org/EmailMessage">
<div itemprop="action" itemscope itemtype="http://schema.org/ViewAction">
<link itemprop="url" href="https://github.com/OpenSIPS/opensips/pull/618"></link>
<meta itemprop="name" content="View Pull Request"></meta>
</div>
<meta itemprop="description" content="View this Pull Request on GitHub"></meta>
</div>