Exemplo n.º 1
0
MojErr MojService::dispatchReply(MojServiceMessage* msg)
{
	MojAssert(msg);
	MojAssertMutexUnlocked(m_mutex);
	MojLogTrace(s_log);

	// parse payload
	MojObjectBuilder builder;
	MojObject payload;
	MojErr err = MojErrNone;
	MojInt64 errCode = MojErrNone;
	errCode = err = msg->payload(builder);
	MojErrCatchAll(err);
	if (errCode == MojErrNone)
		payload = builder.object();

	// get errCode
	bool retVal = false;
	if (payload.get(MojServiceMessage::ReturnValueKey, retVal) && !retVal) {
		if (!payload.get(MojServiceMessage::ErrorCodeKey, errCode))
			errCode = MojErrUnknown;
	}
	// find request
	MojRefCountedPtr<MojServiceRequest> req;
	err = getRequest(msg, req);
	MojErrCheck(err);

	// do the dispatch
	err = dispatchReplyImpl(req.get(), msg, payload, (MojErr) errCode);
	MojErrCatchAll(err);

	return MojErrNone;
}
Exemplo n.º 2
0
MojDbBerkeleyEngine::~MojDbBerkeleyEngine()
{
	MojLogTrace(s_log);

	MojErr err =  close();
	MojErrCatchAll(err);
}
Exemplo n.º 3
0
MojDb::~MojDb()
{
	MojLogTrace(s_log);

	MojErr err = close();
	MojErrCatchAll(err);
}
Exemplo n.º 4
0
MojErr serviceThread(void*)
{
	MojErr err = MojErrNone;
	bool stop = false;

#ifdef USE_SOCKET_SERVICE
	MojEpollReactor reactor;
	MojSocketService msgService(reactor);
	err = reactor.init();
	MojErrCheck(err);
#else
	MojGmainReactor reactor;
	err = reactor.init();
	MojErrCheck(err);
	MojLunaService msgService;
#endif

	MojRefCountedPtr<MojLunaTestService> service(new MojLunaTestService(stop, msgService));
	MojAllocCheck(service.get());
	err = service->open(ServiceName);
	MojErrCheck(err);
	err = msgService.attach(reactor.impl());
	MojErrCheck(err);

	while (!stop) {
		err = msgService.dispatch();
		MojErrCatchAll(err);
	}
	err = msgService.close();
	MojErrCheck(err);

	return MojErrNone;
}
Exemplo n.º 5
0
gboolean MojGmainReactor::dispatch(GSource* gsource, GSourceFunc callback, gpointer user_data)
{
	Source* source = (Source*) gsource;
	MojAssert(source && source->m_info);

	MojErr err = source->m_info->dispatch();
	MojErrCatchAll(err);

	return true;
}
Exemplo n.º 6
0
MojDbKind::~MojDbKind()
{
	MojLogTrace(s_log);

	MojErr err = close();
	MojErrCatchAll(err);

	MojAssert(m_supers.empty());
	MojAssert(m_subs.empty());
}
Exemplo n.º 7
0
MojErr MojDbWatcher::fireImpl()
{
	MojAssertMutexLocked(m_mutex);

	MojErr err = invalidate();
	MojErrCheck(err);
	err = m_signal.fire();
	MojErrCatchAll(err);
	
	MojLogDebug(MojDb::s_log, _T("Watcher_fired!!: err = %d; state= %d; index name = %s; domain = %s\n"), (int)err, (int)m_state,
				((m_index) ? m_index->name().data() : NULL), ((m_domain) ? m_domain.data() : NULL));
	return MojErrNone;
}
Exemplo n.º 8
0
bool MojLunaService::handleResponse(LSHandle* sh, LSMessage* msg, void* ctx)
{
    LOG_TRACE("Entering function %s", __FUNCTION__);
	MojAssert(sh && msg && ctx);
	MojLunaService* service = static_cast<MojLunaService*>(ctx);

	MojRefCountedPtr<MojLunaMessage> request(new MojLunaMessage(service, msg, NULL, true));
	MojAllocCheck(request.get());
    LOG_DEBUG("[db_lunaService] response received: %s", request->payload());
	MojErr err = service->handleReply(request.get());
	MojErrCatchAll(err);

	return true;
}
Exemplo n.º 9
0
MojErr MojService::dispatchCancel(const SubscriptionKey& key)
{
	MojAssertMutexUnlocked(m_mutex);
	MojLogTrace(s_log);
	MojThreadGuard guard(m_mutex);

	SubscriptionMap::ConstIterator i = m_subscriptions.find(key);
	if (i != m_subscriptions.end()) {
		MojRefCountedPtr<MojServiceMessage> msg = *i;
		guard.unlock();

		MojErr err = msg->dispatchCancel();
		MojErrCatchAll(err);
	}
	return MojErrNone;
}
Exemplo n.º 10
0
void MojSignalBase::cancel(MojSlotBase* slot)
{
    MojThreadGuard guard(m_mutex);
    if(slot->m_connected == false)
        return;

    guard.unlock();

    // add ref to make sure that handler isn't destroyed before handleCancel returns.
    MojRefCountedPtr<MojSignalHandler> handler(m_handler);
    MojErr err = m_handler->handleCancel();
    MojErrCatchAll(err);

    guard.lock();
    // Not sure if it's possible but who knows what might happened once we unlock the mutex
    if(slot->m_connected == false)
        return;
    MojAssert(slot && m_slots.contains(slot));
    m_slots.erase(slot);
    slot->disconnect();
    guard.unlock();
}
Exemplo n.º 11
0
bool MojLunaService::handleRequest(LSHandle* sh, LSMessage* msg, void* ctx)
{
    LOG_TRACE("Entering function %s", __FUNCTION__);
	MojAssert(sh && msg && ctx);
	MojLunaService::Category* category = static_cast<Category*>(ctx);
	MojLunaService* service = static_cast<MojLunaService*>(category->m_service);

	MojRefCountedPtr<MojLunaMessage> request(new MojLunaMessage(service, msg, category));
	MojAllocCheck(request.get());
    LOG_DEBUG("[db_lunaService] request received: %s", request->payload());

	MojErr reqErr;
	MojErr err = reqErr = request->processSubscriptions();
	MojErrCatchAll(err) {
		(void) request->replyError(reqErr);
		return true;
	}

	err = service->MojService::handleRequest(request.get());
	MojErrCatchAll(err);

	return true;
}
Exemplo n.º 12
0
MojDbSandwichEngine::~MojDbSandwichEngine()
{
    MojErr err =  close();
    MojErrCatchAll(err);
}
Exemplo n.º 13
0
MojDbIsamQuery::~MojDbIsamQuery()
{
	MojErr err = close();
	MojErrCatchAll(err);
}
Exemplo n.º 14
0
MojDbSandwichDatabase::~MojDbSandwichDatabase()
{
    MojErr err =  close();
    MojErrCatchAll(err);
}
Exemplo n.º 15
0
MojLunaService::~MojLunaService()
{
	MojErr err = close();
	MojErrCatchAll(err);
}
Exemplo n.º 16
0
MojDbLevelIndex::~MojDbLevelIndex()
{
    MojErr err =  close();
    MojErrCatchAll(err);
}
Exemplo n.º 17
0
MojDbLevelQuery::~MojDbLevelQuery()
{
	MojErr err = close();
	MojErrCatchAll(err);
}
Exemplo n.º 18
0
MojDbLevelDatabase::~MojDbLevelDatabase()
{
    MojErr err =  close();
    MojErrCatchAll(err);
}