Switch to unified view

a/src/index/bglfetcher.cpp b/src/index/bglfetcher.cpp
...
...
14
 *   Free Software Foundation, Inc.,
14
 *   Free Software Foundation, Inc.,
15
 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
15
 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
16
 */
16
 */
17
#include "autoconfig.h"
17
#include "autoconfig.h"
18
18
19
#include <mutex>
20
19
#include "rcldoc.h"
21
#include "rcldoc.h"
20
#include "fetcher.h"
22
#include "fetcher.h"
21
#include "bglfetcher.h"
23
#include "bglfetcher.h"
22
#include "log.h"
24
#include "log.h"
23
#include "ptmutex.h"
24
#include "beaglequeuecache.h"
25
#include "beaglequeuecache.h"
25
26
26
// We use a single beagle cache object to access beagle data. We protect it 
27
// We use a single beagle cache object to access beagle data. We protect it 
27
// against multiple thread access.
28
// against multiple thread access.
28
static PTMutexInit o_beagler_mutex;
29
static std::mutex o_beagler_mutex;
29
30
30
bool BGLDocFetcher::fetch(RclConfig* cnf, const Rcl::Doc& idoc, RawDoc& out)
31
bool BGLDocFetcher::fetch(RclConfig* cnf, const Rcl::Doc& idoc, RawDoc& out)
31
{
32
{
32
    string udi;
33
    string udi;
33
    if (!idoc.getmeta(Rcl::Doc::keyudi, &udi) || udi.empty()) {
34
    if (!idoc.getmeta(Rcl::Doc::keyudi, &udi) || udi.empty()) {
34
    LOGERR("BGLDocFetcher:: no udi in idoc\n" );
35
    LOGERR("BGLDocFetcher:: no udi in idoc\n" );
35
    return false;
36
    return false;
36
    }
37
    }
37
    Rcl::Doc dotdoc;
38
    Rcl::Doc dotdoc;
38
    {
39
    {
39
  PTMutexLocker locker(o_beagler_mutex);
40
        std::unique_lock<std::mutex> locker(o_beagler_mutex);
40
    // Retrieve from our webcache (beagle data). The beagler
41
    // Retrieve from our webcache (beagle data). The beagler
41
    // object is created at the first call of this routine and
42
    // object is created at the first call of this routine and
42
    // deleted when the program exits.
43
    // deleted when the program exits.
43
    static BeagleQueueCache o_beagler(cnf);
44
    static BeagleQueueCache o_beagler(cnf);
44
    if (!o_beagler.getFromCache(udi, dotdoc, out.data)) {
45
    if (!o_beagler.getFromCache(udi, dotdoc, out.data)) {