Exemplo n.º 1
0
void Assert(char const *file, int line, char const *function, char const *message)
{
    ACE_Stack_Trace st;
    fprintf(stderr, "\n%s:%i in %s ASSERTION FAILED:\n  %s\n%s\n",
            file, line, function, message, st.c_str());
    *((volatile int*)NULL) = 0;
}
Exemplo n.º 2
0
void Log::outErrorST(const char * str, ...)
{
    va_list ap;
    va_start(ap, str);
    char nnew_str[MAX_QUERY_LEN];
    vsnprintf(nnew_str, MAX_QUERY_LEN, str, ap);
    va_end(ap);

    ACE_Stack_Trace st;
    outError("%s [Stacktrace: %s]", nnew_str, st.c_str());
}
Exemplo n.º 3
0
ByteBufferPositionException::ByteBufferPositionException(bool add, size_t pos,
                                                         size_t size, size_t valueSize)
{
    std::ostringstream ss;
    ACE_Stack_Trace trace;

    ss << "Attempted to " << (add ? "put" : "get") << " value with size: "
       << valueSize << " in ByteBuffer (pos: " << pos << " size: " << size
       << ")\n\n" << trace.c_str();

    message().assign(ss.str());
}
Exemplo n.º 4
0
/// Send a packet to the client
void WorldSession::SendPacket (WorldPacket const* packet)
{
    if (!m_Socket)
        return;
    if (sWorld->debugOpcode != 0 && packet->GetOpcode() != sWorld->debugOpcode)
        return;

    if (packet->GetOpcode() == UNKNOWN_OPCODE)
    {
        sLog->outError("Sending unknown opcode - prevented. Trace:");
        ACE_Stack_Trace trace;
        sLog->outError("%s", trace.c_str());
        return;
    }

#ifdef ARKCORE_DEBUG

    // Code for network use statistic
    static uint64 sendPacketCount = 0;
    static uint64 sendPacketBytes = 0;

    static time_t firstTime = time(NULL);
    static time_t lastTime = firstTime;// next 60 secs start time

    static uint64 sendLastPacketCount = 0;
    static uint64 sendLastPacketBytes = 0;

    time_t cur_time = time(NULL);

    if ((cur_time - lastTime) < 60)
    {
        sendPacketCount+=1;
        sendPacketBytes+=packet->size();

        sendLastPacketCount+=1;
        sendLastPacketBytes+=packet->size();
    }
    else
    {
        uint64 minTime = uint64(cur_time - lastTime);
        uint64 fullTime = uint64(lastTime - firstTime);
        sLog->outDetail("Send all time packets count: " UI64FMTD " bytes: " UI64FMTD " avr.count/sec: %f avr.bytes/sec: %f time: %u", sendPacketCount, sendPacketBytes, float(sendPacketCount)/fullTime, float(sendPacketBytes)/fullTime, uint32(fullTime));
        sLog->outDetail("Send last min packets count: " UI64FMTD " bytes: " UI64FMTD " avr.count/sec: %f avr.bytes/sec: %f", sendLastPacketCount, sendLastPacketBytes, float(sendLastPacketCount)/minTime, float(sendLastPacketBytes)/minTime);

        lastTime = cur_time;
        sendLastPacketCount = 1;
        sendLastPacketBytes = packet->wpos();          // wpos is real written size
    }

#endif                                                  // !ARKCORE_DEBUG
    if (m_Socket->SendPacket(*packet) == -1)
        m_Socket->CloseSocket();
}
Exemplo n.º 5
0
void ByteBufferException::PrintPosError() const
{
    char const* traceStr;

    ACE_Stack_Trace trace;
    traceStr = trace.c_str();

    sLog.outError(
        "Attempted to %s in ByteBuffer (pos: " SIZEFMTD " size: " SIZEFMTD ") "
        "value with size: " SIZEFMTD "%s%s",
        (add ? "put" : "get"), pos, size, esize,
        traceStr ? "\n" : "", traceStr ? traceStr : "");
}
Exemplo n.º 6
0
ByteBufferSourceException::ByteBufferSourceException(size_t pos, size_t size,
                                                     size_t valueSize)
{
    std::ostringstream ss;
    ACE_Stack_Trace trace;

    ss << "Attempted to put a "
       << (valueSize > 0 ? "NULL-pointer" : "zero-sized value")
       << " in ByteBuffer (pos: " << pos << " size: " << size << ")\n\n"
       << trace.c_str();

    message().assign(ss.str());
}
Exemplo n.º 7
0
/// Send a packet to the client
void WorldSession::SendPacket(WorldPacket const *packet, bool nocheck)
{
    if (!m_Socket)
        return;

    if (packet->GetOpcode() == UNKNOWN_OPCODE)
    {
        sLog->outError("Sending unknown opcode - prevented. Trace:");
        ACE_Stack_Trace trace;
        sLog->outError("%s", trace.c_str());
        return;
    }

#ifdef TRILLIUM_DEBUG
    // Code for network use statistic
    static uint64 sendPacketCount = 0;
    static uint64 sendPacketBytes = 0;

    static time_t firstTime = time(NULL);
    static time_t lastTime = firstTime;                     // next 60 secs start time

    static uint64 sendLastPacketCount = 0;
    static uint64 sendLastPacketBytes = 0;

    time_t cur_time = time(NULL);

    if ((cur_time - lastTime) < 60)
    {
        sendPacketCount+=1;
        sendPacketBytes+=packet->size();

        sendLastPacketCount+=1;
        sendLastPacketBytes+=packet->size();
    }
    else
    {
        uint64 minTime = uint64(cur_time - lastTime);
        uint64 fullTime = uint64(lastTime - firstTime);
        sLog->outDetail("Send all time packets count: " UI64FMTD " bytes: " UI64FMTD " avr.count/sec: %f avr.bytes/sec: %f time: %u", sendPacketCount, sendPacketBytes, float(sendPacketCount)/fullTime, float(sendPacketBytes)/fullTime, uint32(fullTime));
        sLog->outDetail("Send last min packets count: " UI64FMTD " bytes: " UI64FMTD " avr.count/sec: %f avr.bytes/sec: %f", sendLastPacketCount, sendLastPacketBytes, float(sendLastPacketCount)/minTime, float(sendLastPacketBytes)/minTime);

        lastTime = cur_time;
        sendLastPacketCount = 1;
        sendLastPacketBytes = packet->wpos();               // wpos is real written size
    }
#endif       
                                               // !TRILLIUM_DEBUG
    sLog->outString("SESSION: Try to SEND opcode %s (0x%.4X)", LookupOpcodeName(packet->GetOpcode()), packet->GetOpcode());
    
    if (nocheck)
    {
        if (m_Socket->SendPacket (*packet) == -1)
            m_Socket->CloseSocket ();
    }
    else
    {
        if (packet->GetOpcode() > NUM_OPCODE_HANDLERS)
            return;

        const OpcodeHandler* handler = opcodeTable[packet->GetOpcode()];
        try
        {
            switch (handler->blockout)
            {
                case ROUTE_NULL:
                    return;
                case ROUTE_ALWAYS:
                {
                    if (m_Socket->SendPacket (*packet) == -1)
                        m_Socket->CloseSocket ();
                    break;
                }
                case ROUTE_NO_NODE:
                {
                    if (!m_redirected)
                    {
                        if (m_Socket->SendPacket (*packet) == -1)
                            m_Socket->CloseSocket ();
                    }
                }
            }
        }
        catch(ByteBufferException &)
        {
            sLog->outString("ERROR BY PACKET");
        }
        
    }
}