YK_BOOL YKCreateMTOrderParamExtern::ClearSpilthMaintainWork()
{
	YK_ID workId(0);
	do 
	{
		workId = GetExistMTWork();
		YKWorkSPtr work = g_Application.Get<YKMapWork>()->GetObj(workId);
		if(work.ValidObj())
		{
			YKOrderSPtr order = work->GetOrder();
			if(order.ValidObj())
			{
				YKOrderExtern tmp(order);
				tmp.Delete();
			}
		}
	} while (workId > 0);

	return true;
}
Esempio n. 2
0
void SharedReceiveQueue::postBuffer(InfinibandBuffer& buffer, std::error_code& ec) {
    if (!buffer.valid()) {
        ec = error::invalid_buffer;
        return;
    }
    WorkRequestId workId(0x0u, buffer.id(), WorkType::RECEIVE);

    // Prepare work request
    struct ibv_recv_wr wr;
    memset(&wr, 0, sizeof(wr));
    wr.wr_id = workId.id();
    wr.sg_list = buffer.handle();
    wr.num_sge = 1;

    // Repost receives on shared queue
    struct ibv_recv_wr* bad_wr = nullptr;
    if (ibv_post_srq_recv(mQueue, &wr, &bad_wr)) {
        ec = std::error_code(errno, std::generic_category());
        return;
    }
}
Esempio n. 3
0
void CompletionContext::processWorkComplete(struct ibv_wc* wc) {
    LOG_TRACE("Processing WC with ID %1% on queue %2% with status %3% %4%", wc->wr_id, wc->qp_num, wc->status,
            ibv_wc_status_str(wc->status));

    WorkRequestId workId(wc->wr_id);
    std::error_code ec;

    auto i = mSocketMap.find(wc->qp_num);
    if (i == mSocketMap.end()) {
        LOG_ERROR("No matching socket for qp_num %1%", wc->qp_num);

        // In the case that we have no socket associated with the qp_num we just repost the buffer to the shared receive
        // queue or release the buffer in the case of send
        switch (workId.workType()) {

        // In the case the work request was a receive, we try to repost the shared receive buffer
        case WorkType::RECEIVE: {
            mDevice->postReceiveBuffer(workId.bufferId());
        } break;

        // In the case the work request was a send we just release the send buffer
        case WorkType::SEND: {
            releaseSendBuffer(workId.bufferId());
        } break;

        default:
            break;
        }

        return;
    }
    InfinibandSocketImpl* socket = i->second.get();

    if (wc->status != IBV_WC_SUCCESS) {
        ec = std::error_code(wc->status, error::get_work_completion_category());
    } else {
        assert(workId.workType() != WorkType::RECEIVE || wc->opcode & IBV_WC_RECV);
        assert(workId.workType() != WorkType::SEND || wc->opcode == IBV_WC_SEND);
        assert(workId.workType() != WorkType::READ || wc->opcode == IBV_WC_RDMA_READ);
        assert(workId.workType() != WorkType::WRITE || wc->opcode == IBV_WC_RDMA_WRITE);
    }

    switch (workId.workType()) {
    case WorkType::RECEIVE: {
        LOG_TRACE("Executing receive event of buffer %1%", workId.bufferId());
        auto buffer = mDevice->acquireReceiveBuffer(workId.bufferId());
        if (!buffer.valid()) {
            socket->onReceive(nullptr, 0x0u, error::invalid_buffer);
            break;
        }

        if (wc->opcode == IBV_WC_RECV_RDMA_WITH_IMM) {
            socket->onImmediate(ntohl(wc->imm_data));
        } else {
            socket->onReceive(buffer.data(), wc->byte_len, ec);
        }
        mDevice->postReceiveBuffer(buffer);
    } break;

    case WorkType::SEND: {
        LOG_TRACE("Executing send event of buffer %1%", workId.bufferId());
        socket->onSend(workId.userId(), ec);
        releaseSendBuffer(workId.bufferId());
    } break;

    case WorkType::READ: {
        LOG_TRACE("Executing read event of buffer %1%", workId.bufferId());
        socket->onRead(workId.userId(), workId.bufferId(), ec);
    } break;

    case WorkType::WRITE: {
        LOG_TRACE("Executing write event of buffer %1%", workId.bufferId());
        socket->onWrite(workId.userId(), workId.bufferId(), ec);
    } break;

    default: {
        LOG_TRACE("Unknown work type");
    } break;
    }
}