diff --git a/indra/llcommon/llmemory.cpp b/indra/llcommon/llmemory.cpp index d284952d6..4939a44ce 100644 --- a/indra/llcommon/llmemory.cpp +++ b/indra/llcommon/llmemory.cpp @@ -162,6 +162,7 @@ void LLMemory::logMemoryInfo(BOOL update) if(update) { updateMemoryInfo() ; + LLPrivateMemoryPoolManager::getInstance()->updateStatistics() ; } llinfos << "Current allocated physical memory(KB): " << sAllocatedMemInKB << llendl ; diff --git a/indra/llinventory/lleconomy.cpp b/indra/llinventory/lleconomy.cpp index 4366d1eb2..d643ea6ed 100644 --- a/indra/llinventory/lleconomy.cpp +++ b/indra/llinventory/lleconomy.cpp @@ -1,31 +1,25 @@ /** * @file lleconomy.cpp * - * $LicenseInfo:firstyear=2002&license=viewergpl$ - * - * Copyright (c) 2002-2009, Linden Research, Inc. - * + * $LicenseInfo:firstyear=2002&license=viewerlgpl$ * Second Life Viewer Source Code - * The source code in this file ("Source Code") is provided by Linden Lab - * to you under the terms of the GNU General Public License, version 2.0 - * ("GPL"), unless you have obtained a separate licensing agreement - * ("Other License"), formally executed by you and Linden Lab. Terms of - * the GPL can be found in doc/GPL-license.txt in this distribution, or - * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2 + * Copyright (C) 2010, Linden Research, Inc. * - * There are special exceptions to the terms and conditions of the GPL as - * it is applied to this Source Code. View the full text of the exception - * in the file doc/FLOSS-exception.txt in this software distribution, or - * online at - * http://secondlifegrid.net/programs/open_source/licensing/flossexception + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. * - * By copying, modifying or distributing this software, you acknowledge - * that you have read and understood your obligations described above, - * and agree to abide by those obligations. + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. * - * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO - * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, - * COMPLETENESS OR PERFORMANCE. + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA * $/LicenseInfo$ */ @@ -54,6 +48,31 @@ LLGlobalEconomy::LLGlobalEconomy() LLGlobalEconomy::~LLGlobalEconomy() { } +void LLGlobalEconomy::addObserver(LLEconomyObserver* observer) +{ + mObservers.push_back(observer); +} + +void LLGlobalEconomy::removeObserver(LLEconomyObserver* observer) +{ + std::list::iterator it = + std::find(mObservers.begin(), mObservers.end(), observer); + if (it != mObservers.end()) + { + mObservers.erase(it); + } +} + +void LLGlobalEconomy::notifyObservers() +{ + for (std::list::iterator it = mObservers.begin(); + it != mObservers.end(); + ++it) + { + (*it)->onEconomyDataChange(); + } +} + // static void LLGlobalEconomy::processEconomyData(LLMessageSystem *msg, LLGlobalEconomy* econ_data) { @@ -94,6 +113,8 @@ void LLGlobalEconomy::processEconomyData(LLMessageSystem *msg, LLGlobalEconomy* econ_data->setTeleportPriceExponent(f); msg->getS32Fast(_PREHASH_Info, _PREHASH_PriceGroupCreate, i); econ_data->setPriceGroupCreate(i); + + econ_data->notifyObservers(); } S32 LLGlobalEconomy::calculateTeleportCost(F32 distance) const diff --git a/indra/llinventory/lleconomy.h b/indra/llinventory/lleconomy.h index e48008545..eb2ecf71b 100644 --- a/indra/llinventory/lleconomy.h +++ b/indra/llinventory/lleconomy.h @@ -1,31 +1,25 @@ /** * @file lleconomy.h * - * $LicenseInfo:firstyear=2002&license=viewergpl$ - * - * Copyright (c) 2002-2009, Linden Research, Inc. - * + * $LicenseInfo:firstyear=2002&license=viewerlgpl$ * Second Life Viewer Source Code - * The source code in this file ("Source Code") is provided by Linden Lab - * to you under the terms of the GNU General Public License, version 2.0 - * ("GPL"), unless you have obtained a separate licensing agreement - * ("Other License"), formally executed by you and Linden Lab. Terms of - * the GPL can be found in doc/GPL-license.txt in this distribution, or - * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2 + * Copyright (C) 2010, Linden Research, Inc. * - * There are special exceptions to the terms and conditions of the GPL as - * it is applied to this Source Code. View the full text of the exception - * in the file doc/FLOSS-exception.txt in this software distribution, or - * online at - * http://secondlifegrid.net/programs/open_source/licensing/flossexception + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. * - * By copying, modifying or distributing this software, you acknowledge - * that you have read and understood your obligations described above, - * and agree to abide by those obligations. + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. * - * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO - * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, - * COMPLETENESS OR PERFORMANCE. + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA * $/LicenseInfo$ */ @@ -37,6 +31,16 @@ class LLMessageSystem; class LLVector3; +/** + * Register an observer to be notified of economy data updates coming from server. + */ +class LLEconomyObserver +{ +public: + virtual ~LLEconomyObserver() {} + virtual void onEconomyDataChange() = 0; +}; + class LLGlobalEconomy { public: @@ -52,6 +56,10 @@ public: virtual void print(); + void addObserver(LLEconomyObserver* observer); + void removeObserver(LLEconomyObserver* observer); + void notifyObservers(); + static void processEconomyData(LLMessageSystem *msg, LLGlobalEconomy* econ_data); S32 calculateTeleportCost(F32 distance) const; @@ -95,6 +103,8 @@ private: S32 mTeleportMinPrice; F32 mTeleportPriceExponent; S32 mPriceGroupCreate; + + std::list mObservers; }; diff --git a/indra/llinventory/llsaleinfo.cpp b/indra/llinventory/llsaleinfo.cpp index e51e35e6e..b7afb28ad 100644 --- a/indra/llinventory/llsaleinfo.cpp +++ b/indra/llinventory/llsaleinfo.cpp @@ -30,8 +30,8 @@ * $/LicenseInfo$ */ -#include "linden_common.h" #include +#include "linden_common.h" #include "llsaleinfo.h" diff --git a/indra/llmessage/llhttpassetstorage.cpp b/indra/llmessage/llhttpassetstorage.cpp index 859842a15..66a6c00d1 100644 --- a/indra/llmessage/llhttpassetstorage.cpp +++ b/indra/llmessage/llhttpassetstorage.cpp @@ -128,6 +128,7 @@ LLHTTPAssetRequest::LLHTTPAssetRequest(LLHTTPAssetStorage *asp, : LLAssetRequest(uuid, type), mZInitialized(false) { + memset(&mZStream, 0, sizeof(mZStream)); // we'll initialize this later, but for now zero the whole C-style struct to avoid debug/coverity noise mAssetStoragep = asp; mCurlHandle = NULL; mCurlMultiHandle = curl_multi; diff --git a/indra/llmessage/llhttpclientadapter.h b/indra/llmessage/llhttpclientadapter.h index 7d61357a7..7f76390d0 100644 --- a/indra/llmessage/llhttpclientadapter.h +++ b/indra/llmessage/llhttpclientadapter.h @@ -34,7 +34,7 @@ #define LL_HTTPCLIENTADAPTER_H #include "llhttpclientinterface.h" -#include "llmemory.h" // LLSingleton<> +#include "llsingleton.h" // LLSingleton<> class LLHTTPClientAdapter : public LLHTTPClientInterface, public LLSingleton { diff --git a/indra/llmessage/lliohttpserver.cpp b/indra/llmessage/lliohttpserver.cpp index eb9fd80b8..aff3a7adf 100644 --- a/indra/llmessage/lliohttpserver.cpp +++ b/indra/llmessage/lliohttpserver.cpp @@ -4,31 +4,25 @@ * @date 2005-10-05 * @brief Implementation of the http server classes * - * $LicenseInfo:firstyear=2005&license=viewergpl$ - * - * Copyright (c) 2005-2009, Linden Research, Inc. - * + * $LicenseInfo:firstyear=2005&license=viewerlgpl$ * Second Life Viewer Source Code - * The source code in this file ("Source Code") is provided by Linden Lab - * to you under the terms of the GNU General Public License, version 2.0 - * ("GPL"), unless you have obtained a separate licensing agreement - * ("Other License"), formally executed by you and Linden Lab. Terms of - * the GPL can be found in doc/GPL-license.txt in this distribution, or - * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2 + * Copyright (C) 2010, Linden Research, Inc. * - * There are special exceptions to the terms and conditions of the GPL as - * it is applied to this Source Code. View the full text of the exception - * in the file doc/FLOSS-exception.txt in this software distribution, or - * online at - * http://secondlifegrid.net/programs/open_source/licensing/flossexception + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. * - * By copying, modifying or distributing this software, you acknowledge - * that you have read and understood your obligations described above, - * and agree to abide by those obligations. + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. * - * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO - * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, - * COMPLETENESS OR PERFORMANCE. + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA * $/LicenseInfo$ */ @@ -972,7 +966,9 @@ private: // static LLHTTPNode& LLIOHTTPServer::create(LLPumpIO& pump, U16 port) { - LLSocket::ptr_t socket = LLSocket::create(LLSocket::STREAM_TCP, port); + LLSocket::ptr_t socket = LLSocket::create( + LLSocket::STREAM_TCP, + port); if(!socket) { llerrs << "Unable to initialize socket" << llendl; diff --git a/indra/llmessage/lliosocket.cpp b/indra/llmessage/lliosocket.cpp index d80ca402c..2aa44b8fd 100644 --- a/indra/llmessage/lliosocket.cpp +++ b/indra/llmessage/lliosocket.cpp @@ -114,11 +114,21 @@ LLSocket::ptr_t LLSocket::create(EType type, U16 port) if(STREAM_TCP == type) { - status = apr_socket_create(&rv->mSocket, APR_INET, SOCK_STREAM, APR_PROTO_TCP, rv->mPool()); + status = apr_socket_create( + &rv->mSocket, + APR_INET, + SOCK_STREAM, + APR_PROTO_TCP, + rv->mPool()); } else if(DATAGRAM_UDP == type) { - status = apr_socket_create(&rv->mSocket, APR_INET, SOCK_DGRAM, APR_PROTO_UDP, rv->mPool()); + status = apr_socket_create( + &rv->mSocket, + APR_INET, + SOCK_DGRAM, + APR_PROTO_UDP, + rv->mPool()); } else { diff --git a/indra/llmessage/llpacketring.cpp b/indra/llmessage/llpacketring.cpp index 60359dfc5..abafaa511 100644 --- a/indra/llmessage/llpacketring.cpp +++ b/indra/llmessage/llpacketring.cpp @@ -239,15 +239,23 @@ S32 LLPacketRing::receivePacket (S32 socket, char *datap) // no delay, pull straight from net if (LLSocks::isEnabled()) { - proxywrap_t * header; - datap = datap-10; - header = (proxywrap_t *)datap; - packet_size = receive_packet(socket, datap); - mLastSender.setAddress(header->addr); - mLastSender.setPort(ntohs(header->port)); - if (packet_size > 10) + const U8 SOCKS_HEADER_SIZE = 10; + U8 buffer[NET_BUFFER_SIZE + SOCKS_HEADER_SIZE]; + packet_size = receive_packet(socket, static_cast(static_cast(buffer))); + + if (packet_size > SOCKS_HEADER_SIZE) { - packet_size -= 10; + // *FIX We are assuming ATYP is 0x01 (IPv4), not 0x03 (hostname) or 0x04 (IPv6) + memcpy(datap, buffer + SOCKS_HEADER_SIZE, packet_size - SOCKS_HEADER_SIZE); + proxywrap_t * header = static_cast(static_cast(buffer)); + mLastSender.setAddress(header->addr); + mLastSender.setPort(ntohs(header->port)); + + packet_size -= SOCKS_HEADER_SIZE; // The unwrapped packet size + } + else + { + packet_size = 0; } } else @@ -285,7 +293,7 @@ BOOL LLPacketRing::sendPacket(int h_socket, char * send_buffer, S32 buf_size, LL if (!mUseOutThrottle) { - return doSendPacket(h_socket, send_buffer, buf_size, host ); + return sendPacketImpl(h_socket, send_buffer, buf_size, host ); } else { @@ -306,7 +314,7 @@ BOOL LLPacketRing::sendPacket(int h_socket, char * send_buffer, S32 buf_size, LL mOutBufferLength -= packetp->getSize(); packet_size = packetp->getSize(); - status = doSendPacket(h_socket, packetp->getData(), packet_size, packetp->getHost()); + status = sendPacketImpl(h_socket, packetp->getData(), packet_size, packetp->getHost()); delete packetp; // Update the throttle @@ -315,7 +323,7 @@ BOOL LLPacketRing::sendPacket(int h_socket, char * send_buffer, S32 buf_size, LL else { // If the queue's empty, we can just send this packet right away. - status = doSendPacket(h_socket, send_buffer, buf_size, host ); + status = sendPacketImpl(h_socket, send_buffer, buf_size, host ); packet_size = buf_size; // Update the throttle @@ -354,7 +362,7 @@ BOOL LLPacketRing::sendPacket(int h_socket, char * send_buffer, S32 buf_size, LL return status; } -BOOL LLPacketRing::doSendPacket(int h_socket, const char * send_buffer, S32 buf_size, LLHost host) +BOOL LLPacketRing::sendPacketImpl(int h_socket, const char * send_buffer, S32 buf_size, LLHost host) { if (!LLSocks::isEnabled()) @@ -362,14 +370,21 @@ BOOL LLPacketRing::doSendPacket(int h_socket, const char * send_buffer, S32 buf_ return send_packet(h_socket, send_buffer, buf_size, host.getAddress(), host.getPort()); } - proxywrap_t *socks_header = (proxywrap_t *)&mProxyWrappedSendBuffer; + const U8 SOCKS_HEADER_SIZE = 10; + char headered_send_buffer[NET_BUFFER_SIZE + SOCKS_HEADER_SIZE]; + + proxywrap_t *socks_header = static_cast(static_cast(&headered_send_buffer)); socks_header->rsv = 0; socks_header->addr = host.getAddress(); socks_header->port = htons(host.getPort()); socks_header->atype = ADDRESS_IPV4; socks_header->frag = 0; - memcpy(mProxyWrappedSendBuffer+10, send_buffer, buf_size); + memcpy(headered_send_buffer + SOCKS_HEADER_SIZE, send_buffer, buf_size); - return send_packet(h_socket,(const char*) mProxyWrappedSendBuffer, buf_size+10, LLSocks::getInstance()->getUDPPproxy().getAddress(), LLSocks::getInstance()->getUDPPproxy().getPort()); + return send_packet( h_socket, + headered_send_buffer, + buf_size + SOCKS_HEADER_SIZE, + LLSocks::getInstance()->getUDPPproxy().getAddress(), + LLSocks::getInstance()->getUDPPproxy().getPort()); } diff --git a/indra/llmessage/llpacketring.h b/indra/llmessage/llpacketring.h index 355113e1a..c0f386d96 100644 --- a/indra/llmessage/llpacketring.h +++ b/indra/llmessage/llpacketring.h @@ -88,8 +88,8 @@ protected: LLHost mLastSender; LLHost mLastReceivingIF; - BOOL doSendPacket(int h_socket, const char * send_buffer, S32 buf_size, LLHost host); - U8 mProxyWrappedSendBuffer[NET_BUFFER_SIZE]; +private: + BOOL sendPacketImpl(int h_socket, const char * send_buffer, S32 buf_size, LLHost host); }; diff --git a/indra/llmessage/llsdmessagereader.cpp b/indra/llmessage/llsdmessagereader.cpp index 845a12d23..ffcf3dc3c 100644 --- a/indra/llmessage/llsdmessagereader.cpp +++ b/indra/llmessage/llsdmessagereader.cpp @@ -297,9 +297,10 @@ S32 getElementSize(const LLSD& llsd) case LLSD::TypeMap: case LLSD::TypeArray: case LLSD::TypeUndefined: + default: // TypeLLSDTypeEnd, TypeLLSDNumTypes, etc. return 0; } - return 0; + //return 0; } //virtual diff --git a/indra/llmessage/message.cpp b/indra/llmessage/message.cpp index b89b6ee2c..723fc6592 100644 --- a/indra/llmessage/message.cpp +++ b/indra/llmessage/message.cpp @@ -556,11 +556,11 @@ BOOL LLMessageSystem::checkMessages( S64 frame_count, bool faked_message, U8 fak S32 acks = 0; S32 true_rcv_size = 0; - U8* buffer = mTrueReceiveBuffer.buffer; + U8* buffer = mTrueReceiveBuffer; if(!faked_message) { - mTrueReceiveSize = mPacketRing.receivePacket(mSocket, (char *)mTrueReceiveBuffer.buffer); + mTrueReceiveSize = mPacketRing.receivePacket(mSocket, (char *)mTrueReceiveBuffer); receive_size = mTrueReceiveSize; mLastSender = mPacketRing.getLastSender(); mLastReceivingIF = mPacketRing.getLastReceivingInterface(); @@ -635,7 +635,7 @@ BOOL LLMessageSystem::checkMessages( S64 frame_count, bool faked_message, U8 fak for(S32 i = 0; i < acks; ++i) { true_rcv_size -= sizeof(TPACKETID); - memcpy(&mem_id, &buffer[true_rcv_size], /* Flawfinder: ignore*/ + memcpy(&mem_id, &mTrueReceiveBuffer[true_rcv_size], /* Flawfinder: ignore*/ sizeof(TPACKETID)); packet_id = ntohl(mem_id); //LL_INFOS("Messaging") << "got ack: " << packet_id << llendl; @@ -3405,7 +3405,7 @@ void LLMessageSystem::dumpPacketToLog() { S32 offset = cur_line_pos * 3; snprintf(line_buffer + offset, sizeof(line_buffer) - offset, - "%02x ", mTrueReceiveBuffer.buffer[i]); /* Flawfinder: ignore */ + "%02x ", mTrueReceiveBuffer[i]); /* Flawfinder: ignore */ cur_line_pos++; if (cur_line_pos >= 16) { diff --git a/indra/llmessage/message.h b/indra/llmessage/message.h index 759dafca4..8fd428fd5 100644 --- a/indra/llmessage/message.h +++ b/indra/llmessage/message.h @@ -778,18 +778,7 @@ private: LLMessagePollInfo *mPollInfop; U8 mEncodedRecvBuffer[MAX_BUFFER_SIZE]; - -// Push current alignment to stack and set alignment to 1 byte boundary -#pragma pack(push,1) - - struct ReceiveBuffer_t - { - proxywrap_t header; - U8 buffer[MAX_BUFFER_SIZE]; - } mTrueReceiveBuffer; - -#pragma pack(pop) /* restore original alignment from stack */ - + U8 mTrueReceiveBuffer[MAX_BUFFER_SIZE]; S32 mTrueReceiveSize; // Must be valid during decode diff --git a/indra/newview/llviewerobject.h b/indra/newview/llviewerobject.h index 857906949..d1ee94a3e 100644 --- a/indra/newview/llviewerobject.h +++ b/indra/newview/llviewerobject.h @@ -39,7 +39,7 @@ #include "llhudtext.h" #include "llhudicon.h" #include "llinventory.h" -#include "llmemory.h" +#include "llrefcount.h" #include "llmemtype.h" #include "llprimitive.h" #include "lluuid.h" @@ -49,6 +49,7 @@ #include "v3dmath.h" #include "v3math.h" #include "llvertexbuffer.h" +#include "llbbox.h" class LLAgent; // TODO: Get rid of this. class LLAudioSource;