projects
/
pazpar2-moved-to-github.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Using recursive session lock
[pazpar2-moved-to-github.git]
/
src
/
session.c
diff --git
a/src/session.c
b/src/session.c
index
f2acbaa
..
1dc3adf
100644
(file)
--- a/
src/session.c
+++ b/
src/session.c
@@
-35,6
+35,9
@@
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#if HAVE_UNISTD_H
#include <unistd.h>
#endif
#if HAVE_UNISTD_H
#include <unistd.h>
#endif
+#ifdef WIN32
+#include <windows.h>
+#endif
#include <signal.h>
#include <ctype.h>
#include <assert.h>
#include <signal.h>
#include <ctype.h>
#include <assert.h>
@@
-52,6
+55,7
@@
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#include <yaz/querytowrbuf.h>
#include <yaz/oid_db.h>
#include <yaz/snprintf.h>
#include <yaz/querytowrbuf.h>
#include <yaz/oid_db.h>
#include <yaz/snprintf.h>
+#include <yaz/gettimeofday.h>
#define USE_TIMING 0
#if USE_TIMING
#define USE_TIMING 0
#if USE_TIMING
@@
-142,7
+146,7
@@
void pull_terms(NMEM nmem, struct ccl_rpn_node *n, char **termlist, int *num)
}
}
-static void add_facet(struct session *s, const char *type, const char *value)
+void add_facet(struct session *s, const char *type, const char *value, int count)
{
int i;
{
int i;
@@
-164,7
+168,9
@@
static void add_facet(struct session *s, const char *type, const char *value)
= termlist_create(s->nmem, TERMLIST_HIGH_SCORE);
s->num_termlists = i + 1;
}
= termlist_create(s->nmem, TERMLIST_HIGH_SCORE);
s->num_termlists = i + 1;
}
- termlist_insert(s->termlists[i].termlist, value);
+ yaz_log(YLOG_DEBUG, "Session: facets for %s: %s (%d)", type, value, count);
+
+ termlist_insert(s->termlists[i].termlist, value, count);
}
static xmlDoc *record_to_xml(struct session_database *sdb, const char *rec)
}
static xmlDoc *record_to_xml(struct session_database *sdb, const char *rec)
@@
-537,7
+543,7
@@
enum pazpar2_error_code search(struct session *se,
}
se->reclist = reclist_create(se->nmem);
}
se->reclist = reclist_create(se->nmem);
- gettimeofday(&tval, 0);
+ yaz_gettimeofday(&tval);
tval.tv_sec += 5;
tval.tv_sec += 5;
@@
-718,7
+724,7
@@
struct session *new_session(NMEM nmem, struct conf_service *service,
}
session->normalize_cache = normalize_cache_create();
session->session_mutex = 0;
}
session->normalize_cache = normalize_cache_create();
session->session_mutex = 0;
- pazpar2_mutex_create(&session->session_mutex, name);
+ pazpar2_mutex_create_flag(&session->session_mutex, name, PTHREAD_MUTEX_RECURSIVE);
return session;
}
return session;
}
@@
-977,7
+983,10
@@
static int get_mergekey_from_doc(xmlDoc *doc, xmlNode *root, const char *name,
if (!strcmp((const char *) n->name, "metadata"))
{
xmlChar *type = xmlGetProp(n, (xmlChar *) "type");
if (!strcmp((const char *) n->name, "metadata"))
{
xmlChar *type = xmlGetProp(n, (xmlChar *) "type");
- if (!strcmp(name, (const char *) type))
+ if (type == NULL) {
+ yaz_log(YLOG_FATAL, "Missing type attribute on metadata element. Skipping!");
+ }
+ else if (!strcmp(name, (const char *) type))
{
xmlChar *value = xmlNodeListGetString(doc, n->children, 1);
if (value)
{
xmlChar *value = xmlNodeListGetString(doc, n->children, 1);
if (value)
@@
-1136,6
+1145,7
@@
static int ingest_to_cluster(struct client *cl,
\param cl client holds the result set for record
\param rec record buffer (0 terminated)
\param record_no record position (1, 2, ..)
\param cl client holds the result set for record
\param rec record buffer (0 terminated)
\param record_no record position (1, 2, ..)
+ \param nmem working NMEM
\retval 0 OK
\retval -1 failure
*/
\retval 0 OK
\retval -1 failure
*/
@@
-1367,22
+1377,23
@@
static int ingest_to_cluster(struct client *cl,
(char *) value, ser_md->rank,
ser_md->name);
(char *) value, ser_md->rank,
ser_md->name);
- // construct facets ...
- if (ser_md->termlist)
+ // construct facets ... unless the client already has reported them
+ if (ser_md->termlist && !client_has_facet(cl, (char *) type))
{
{
+
if (ser_md->type == Metadata_type_year)
{
char year[64];
sprintf(year, "%d", rec_md->data.number.max);
if (ser_md->type == Metadata_type_year)
{
char year[64];
sprintf(year, "%d", rec_md->data.number.max);
- add_facet(se, (char *) type, year);
+ add_facet(se, (char *) type, year, 1);
if (rec_md->data.number.max != rec_md->data.number.min)
{
sprintf(year, "%d", rec_md->data.number.min);
if (rec_md->data.number.max != rec_md->data.number.min)
{
sprintf(year, "%d", rec_md->data.number.min);
- add_facet(se, (char *) type, year);
+ add_facet(se, (char *) type, year, 1);
}
}
else
}
}
else
- add_facet(se, (char *) type, (char *) value);
+ add_facet(se, (char *) type, (char *) value, 1);
}
// cleaning up
}
// cleaning up