Example #1
0
void webserver_loop() {
    dmd_log(LOG_INFO, "in function %s, starting webserver main loop.\n",
            __func__);

    int serverfd = newSocket();
    webserver_serverAddr = newAddress();
    bindAddress(serverfd, webserver_serverAddr);
    listenAddress(serverfd);

    struct epoll_event events[MAX_EPOLL_EVENT];
    int epollfd = newEpollSocket();

    dmd_log(LOG_DEBUG, "in function %s, begin to work\n", __func__);
    addSockfd(epollfd, serverfd);
    while (1) {
        int ret = epoll_wait(epollfd, events, MAX_EPOLL_EVENT, -1);
        dmd_log(LOG_DEBUG, "in function %s, after epoll wait\n", __func__);
        if (ret < 0) {
            dmd_log(LOG_ERR, "in function %s, epoll failure\n", __func__);
        } else {
            handleEvent(epollfd, serverfd, events, ret);
        }
    }  // while

    closeSocket(serverfd);
    releaseAddress(webserver_serverAddr);
}
Example #2
0
void PointerDataInformation::delayedReadData(Okteta::AbstractByteArrayModel *input, Okteta::Address address)
{
    Q_UNUSED(address); //TODO offsets
    Q_ASSERT(mHasBeenUpdated); //update must have been called prior to reading
    Q_ASSERT(mWasAbleToRead);
    quint8 childBitOffset = 0;
    // Compute the destination offset
    const quint64 pointer = mValue->value().value<quint64>();
    if (pointer > quint64(std::numeric_limits<Okteta::Address>::max()))
    {
        logError() << "Pointer" << mValue->valueString() << "does not point to an existing address.";
        return;
    }
    Okteta::Address newAddress(pointer);
    // If the computed destination it's outside the boundaries of the input ignore it
    if (newAddress < 0 || newAddress >= input->size())
    {
        logError() << "Pointer" << mValue->valueString() << "does not point to an existing address.";
        return;
    }
    //update the child now
    DataInformation* oldTarget = mPointerTarget.data();
    topLevelDataInformation()->scriptHandler()->updateDataInformation(mPointerTarget.data());
    // Let the child do the work (maybe different than before now)
    if (mPointerTarget.data() != oldTarget)
    {
        logInfo() << "Pointer target was replaced.";
        topLevelDataInformation()->setChildDataChanged();
    }
    mPointerTarget->readData(input, newAddress, BitCount64(input->size() - newAddress) * 8, &childBitOffset);
}