Modified: incubator/qpid/trunk/qpid/cpp/common/framing/src/Buffer.cpp URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/common/framing/src/Buffer.cpp?view=diff&rev=462834&r1=462833&r2=462834 ============================================================================== --- incubator/qpid/trunk/qpid/cpp/common/framing/src/Buffer.cpp (original) +++ incubator/qpid/trunk/qpid/cpp/common/framing/src/Buffer.cpp Wed Oct 11 08:50:15 2006 @@ -18,7 +18,7 @@ #include "Buffer.h" #include "FieldTable.h" -qpid::framing::Buffer::Buffer(int _size) : size(_size), position(0), limit(_size){ +qpid::framing::Buffer::Buffer(u_int32_t _size) : size(_size), position(0), limit(_size){ data = new char[size]; } @@ -37,7 +37,7 @@ } void qpid::framing::Buffer::compact(){ - int p = limit - position; + u_int32_t p = limit - position; //copy p chars from position to 0 memmove(data, data + position, p); limit = size; @@ -54,7 +54,7 @@ limit = r_limit; } -int qpid::framing::Buffer::available(){ +u_int32_t qpid::framing::Buffer::available(){ return limit - position; } @@ -62,7 +62,7 @@ return data + position; } -void qpid::framing::Buffer::move(int bytes){ +void qpid::framing::Buffer::move(u_int32_t bytes){ position += bytes; } @@ -123,29 +123,29 @@ void qpid::framing::Buffer::putShortString(const string& s){ - u_int8_t size = s.length(); - putOctet(size); - s.copy(data + position, size); - position += size; + u_int8_t len = s.length(); + putOctet(len); + s.copy(data + position, len); + position += len; } void qpid::framing::Buffer::putLongString(const string& s){ - u_int32_t size = s.length(); - putLong(size); - s.copy(data + position, size); - position += size; + u_int32_t len = s.length(); + putLong(len); + s.copy(data + position, len); + position += len; } void qpid::framing::Buffer::getShortString(string& s){ - u_int8_t size = getOctet(); - s.assign(data + position, size); - position += size; + u_int8_t len = getOctet(); + s.assign(data + position, len); + position += len; } void qpid::framing::Buffer::getLongString(string& s){ - u_int32_t size = getLong(); - s.assign(data + position, size); - position += size; + u_int32_t len = getLong(); + s.assign(data + position, len); + position += len; } void qpid::framing::Buffer::putFieldTable(const FieldTable& t){ @@ -157,12 +157,12 @@ } void qpid::framing::Buffer::putRawData(const string& s){ - u_int32_t size = s.length(); - s.copy(data + position, size); - position += size; + u_int32_t len = s.length(); + s.copy(data + position, len); + position += len; } -void qpid::framing::Buffer::getRawData(string& s, u_int32_t size){ - s.assign(data + position, size); - position += size; +void qpid::framing::Buffer::getRawData(string& s, u_int32_t len){ + s.assign(data + position, len); + position += len; }
Modified: incubator/qpid/trunk/qpid/cpp/common/framing/src/FieldTable.cpp URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/common/framing/src/FieldTable.cpp?view=diff&rev=462834&r1=462833&r2=462834 ============================================================================== --- incubator/qpid/trunk/qpid/cpp/common/framing/src/FieldTable.cpp (original) +++ incubator/qpid/trunk/qpid/cpp/common/framing/src/FieldTable.cpp Wed Oct 11 08:50:15 2006 @@ -27,12 +27,12 @@ FieldTable::~FieldTable() {} u_int32_t FieldTable::size() const { - u_int32_t size(4); + u_int32_t len(4); for(ValueMap::const_iterator i = values.begin(); i != values.end(); ++i) { // 2 = shortstr_len_byyte + type_char_byte - size += 2 + (i->first).size() + (i->second)->size(); + len += 2 + (i->first).size() + (i->second)->size(); } - return size; + return len; } int FieldTable::count() const { @@ -74,9 +74,6 @@ } namespace { -// TODO aconway 2006-09-26: This is messy. Revisit the field table -// and Value classes with a traits-based approach. -// template <class T> T default_value() { return T(); } template <> int default_value<int>() { return 0; } template <> u_int64_t default_value<u_int64_t>() { return 0; } @@ -117,9 +114,11 @@ } void FieldTable::decode(Buffer& buffer){ - u_int32_t size = buffer.getLong(); - int leftover = buffer.available() - size; - + u_int32_t len = buffer.getLong(); + u_int32_t available = buffer.available(); + if (available < len) + THROW_QPID_ERROR(FRAMING_ERROR, "Not enough data for field table."); + u_int32_t leftover = available - len; while(buffer.available() > leftover){ std::string name; buffer.getShortString(name); Added: incubator/qpid/trunk/qpid/cpp/common/framing/src/InitiationHandler.cpp URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/common/framing/src/InitiationHandler.cpp?view=auto&rev=462834 ============================================================================== --- incubator/qpid/trunk/qpid/cpp/common/framing/src/InitiationHandler.cpp (added) +++ incubator/qpid/trunk/qpid/cpp/common/framing/src/InitiationHandler.cpp Wed Oct 11 08:50:15 2006 @@ -0,0 +1,21 @@ +/* + * + * Copyright (c) 2006 The Apache Software Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#include "InitiationHandler.h" + +qpid::framing::InitiationHandler::~InitiationHandler() {} Propchange: incubator/qpid/trunk/qpid/cpp/common/framing/src/InitiationHandler.cpp ------------------------------------------------------------------------------ svn:eol-style = native Added: incubator/qpid/trunk/qpid/cpp/common/framing/src/InputHandler.cpp URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/common/framing/src/InputHandler.cpp?view=auto&rev=462834 ============================================================================== --- incubator/qpid/trunk/qpid/cpp/common/framing/src/InputHandler.cpp (added) +++ incubator/qpid/trunk/qpid/cpp/common/framing/src/InputHandler.cpp Wed Oct 11 08:50:15 2006 @@ -0,0 +1,21 @@ +/* + * + * Copyright (c) 2006 The Apache Software Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#include "InputHandler.h" + +qpid::framing::InputHandler::~InputHandler() {} Propchange: incubator/qpid/trunk/qpid/cpp/common/framing/src/InputHandler.cpp ------------------------------------------------------------------------------ svn:eol-style = native Added: incubator/qpid/trunk/qpid/cpp/common/framing/src/OutputHandler.cpp URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/common/framing/src/OutputHandler.cpp?view=auto&rev=462834 ============================================================================== --- incubator/qpid/trunk/qpid/cpp/common/framing/src/OutputHandler.cpp (added) +++ incubator/qpid/trunk/qpid/cpp/common/framing/src/OutputHandler.cpp Wed Oct 11 08:50:15 2006 @@ -0,0 +1,21 @@ +/* + * + * Copyright (c) 2006 The Apache Software Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#include "OutputHandler.h" + +qpid::framing::OutputHandler::~OutputHandler() {} Propchange: incubator/qpid/trunk/qpid/cpp/common/framing/src/OutputHandler.cpp ------------------------------------------------------------------------------ svn:eol-style = native Modified: incubator/qpid/trunk/qpid/cpp/common/framing/test/BodyHandlerTest.cpp URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/common/framing/test/BodyHandlerTest.cpp?view=diff&rev=462834&r1=462833&r2=462834 ============================================================================== --- incubator/qpid/trunk/qpid/cpp/common/framing/test/BodyHandlerTest.cpp (original) +++ incubator/qpid/trunk/qpid/cpp/common/framing/test/BodyHandlerTest.cpp Wed Oct 11 08:50:15 2006 @@ -17,11 +17,7 @@ */ #include <iostream> #include "amqp_framing.h" -#include <cppunit/TestCase.h> -#include <cppunit/TextTestRunner.h> -#include <cppunit/extensions/HelperMacros.h> -#include <cppunit/plugin/TestPlugIn.h> - +#include "qpid_test_plugin.h" using namespace qpid::framing; class BodyHandlerTest : public CppUnit::TestCase Modified: incubator/qpid/trunk/qpid/cpp/common/framing/test/field_table_test.cpp URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/common/framing/test/field_table_test.cpp?view=diff&rev=462834&r1=462833&r2=462834 ============================================================================== --- incubator/qpid/trunk/qpid/cpp/common/framing/test/field_table_test.cpp (original) +++ incubator/qpid/trunk/qpid/cpp/common/framing/test/field_table_test.cpp Wed Oct 11 08:50:15 2006 @@ -17,10 +17,7 @@ */ #include <iostream> #include "amqp_framing.h" -#include <cppunit/TestCase.h> -#include <cppunit/TextTestRunner.h> -#include <cppunit/extensions/HelperMacros.h> -#include <cppunit/plugin/TestPlugIn.h> +#include <qpid_test_plugin.h> using namespace qpid::framing; Modified: incubator/qpid/trunk/qpid/cpp/common/framing/test/framing_test.cpp URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/common/framing/test/framing_test.cpp?view=diff&rev=462834&r1=462833&r2=462834 ============================================================================== --- incubator/qpid/trunk/qpid/cpp/common/framing/test/framing_test.cpp (original) +++ incubator/qpid/trunk/qpid/cpp/common/framing/test/framing_test.cpp Wed Oct 11 08:50:15 2006 @@ -19,10 +19,7 @@ #include "ConnectionRedirectBody.h" #include <iostream> #include <sstream> -#include <cppunit/TestCase.h> -#include <cppunit/TextTestRunner.h> -#include <cppunit/extensions/HelperMacros.h> -#include <cppunit/plugin/TestPlugIn.h> +#include <qpid_test_plugin.h> #include <typeinfo> using namespace qpid::framing; Modified: incubator/qpid/trunk/qpid/cpp/common/framing/test/header_test.cpp URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/common/framing/test/header_test.cpp?view=diff&rev=462834&r1=462833&r2=462834 ============================================================================== --- incubator/qpid/trunk/qpid/cpp/common/framing/test/header_test.cpp (original) +++ incubator/qpid/trunk/qpid/cpp/common/framing/test/header_test.cpp Wed Oct 11 08:50:15 2006 @@ -17,10 +17,7 @@ */ #include <iostream> #include "amqp_framing.h" -#include <cppunit/TestCase.h> -#include <cppunit/TextTestRunner.h> -#include <cppunit/extensions/HelperMacros.h> -#include <cppunit/plugin/TestPlugIn.h> +#include <qpid_test_plugin.h> using namespace qpid::framing; Modified: incubator/qpid/trunk/qpid/cpp/common/io/Makefile URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/common/io/Makefile?view=diff&rev=462834&r1=462833&r2=462834 ============================================================================== --- incubator/qpid/trunk/qpid/cpp/common/io/Makefile (original) +++ incubator/qpid/trunk/qpid/cpp/common/io/Makefile Wed Oct 11 08:50:15 2006 @@ -16,10 +16,6 @@ QPID_HOME = ../../.. include ${QPID_HOME}/cpp/options.mk - -# Compiler flags -CXXFLAGS = ${DEBUG} ${OPT} -MMD -I inc -I ../concurrent/inc -I ../error/inc -I ../framing/inc -I ../framing/generated -I ${APR_HOME}/include/apr-1/ - SOURCES := $(wildcard src/*.cpp) OBJECTS := $(subst .cpp,.o,$(SOURCES)) DEPS := $(subst .cpp,.d,$(SOURCES)) Modified: incubator/qpid/trunk/qpid/cpp/common/io/inc/APRConnector.h URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/common/io/inc/APRConnector.h?view=diff&rev=462834&r1=462833&r2=462834 ============================================================================== --- incubator/qpid/trunk/qpid/cpp/common/io/inc/APRConnector.h (original) +++ incubator/qpid/trunk/qpid/cpp/common/io/inc/APRConnector.h Wed Oct 11 08:50:15 2006 @@ -68,7 +68,7 @@ void checkIdle(apr_status_t status); void writeBlock(qpid::framing::AMQDataBlock* data); - void writeToSocket(char* data, int available); + void writeToSocket(char* data, size_t available); void setSocketTimeout(); void run(); Modified: incubator/qpid/trunk/qpid/cpp/common/io/inc/ConnectorImpl.h URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/common/io/inc/ConnectorImpl.h?view=diff&rev=462834&r1=462833&r2=462834 ============================================================================== --- incubator/qpid/trunk/qpid/cpp/common/io/inc/ConnectorImpl.h (original) +++ incubator/qpid/trunk/qpid/cpp/common/io/inc/ConnectorImpl.h Wed Oct 11 08:50:15 2006 @@ -32,7 +32,7 @@ { public: - ConnectorImpl(bool debug = false, u_int32_t buffer_size = 1024):APRConnector(debug,buffer_size){}; + ConnectorImpl(bool _debug = false, u_int32_t buffer_size = 1024):APRConnector(_debug,buffer_size){}; virtual ~ConnectorImpl(){}; }; #else @@ -40,7 +40,7 @@ { public: - ConnectorImpl(bool debug = false, u_int32_t buffer_size = 1024):LConnector(debug, buffer_size){}; + ConnectorImpl(bool _debug = false, u_int32_t buffer_size = 1024):LConnector(_debug, buffer_size){}; virtual ~ConnectorImpl(){}; }; Modified: incubator/qpid/trunk/qpid/cpp/common/io/inc/LFProcessor.h URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/common/io/inc/LFProcessor.h?view=diff&rev=462834&r1=462833&r2=462834 ============================================================================== --- incubator/qpid/trunk/qpid/cpp/common/io/inc/LFProcessor.h (original) +++ incubator/qpid/trunk/qpid/cpp/common/io/inc/LFProcessor.h Wed Oct 11 08:50:15 2006 @@ -48,12 +48,12 @@ const apr_pollfd_t* signalledFDs; int count; const int workerCount; + bool hasLeader; qpid::concurrent::Thread** const workers; qpid::concurrent::APRMonitor leadLock; qpid::concurrent::APRMonitor countLock; qpid::concurrent::APRThreadFactory factory; std::vector<LFSessionContext*> sessions; - bool hasLeader; volatile bool stopped; const apr_pollfd_t* getNextEvent(); Modified: incubator/qpid/trunk/qpid/cpp/common/io/src/APRConnector.cpp URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/common/io/src/APRConnector.cpp?view=diff&rev=462834&r1=462833&r2=462834 ============================================================================== --- incubator/qpid/trunk/qpid/cpp/common/io/src/APRConnector.cpp (original) +++ incubator/qpid/trunk/qpid/cpp/common/io/src/APRConnector.cpp Wed Oct 11 08:50:15 2006 @@ -26,15 +26,18 @@ using namespace qpid::framing; using qpid::QpidError; -APRConnector::APRConnector(bool _debug, u_int32_t buffer_size) : closed(true), debug(_debug), - idleIn(0), idleOut(0), timeout(0), - timeoutHandler(0), - shutdownHandler(0), - lastIn(0), lastOut(0), - receive_buffer_size(buffer_size), - send_buffer_size(buffer_size), - inbuf(receive_buffer_size), - outbuf(send_buffer_size){ +APRConnector::APRConnector(bool _debug, u_int32_t buffer_size) : + debug(_debug), + receive_buffer_size(buffer_size), + send_buffer_size(buffer_size), + closed(true), + lastIn(0), lastOut(0), + timeout(0), + idleIn(0), idleOut(0), + timeoutHandler(0), + shutdownHandler(0), + inbuf(receive_buffer_size), + outbuf(send_buffer_size){ APRBase::increment(); @@ -104,7 +107,7 @@ writeLock->release(); } -void APRConnector::writeToSocket(char* data, int available){ +void APRConnector::writeToSocket(char* data, size_t available){ apr_size_t bytes(available); apr_size_t written(0); while(written < available && !closed){ Modified: incubator/qpid/trunk/qpid/cpp/common/io/src/APRSocket.cpp URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/common/io/src/APRSocket.cpp?view=diff&rev=462834&r1=462833&r2=462834 ============================================================================== --- incubator/qpid/trunk/qpid/cpp/common/io/src/APRSocket.cpp (original) +++ incubator/qpid/trunk/qpid/cpp/common/io/src/APRSocket.cpp Wed Oct 11 08:50:15 2006 @@ -17,7 +17,7 @@ */ #include "APRBase.h" #include "APRSocket.h" - +#include <assert.h> #include <iostream> using namespace qpid::io; @@ -45,6 +45,8 @@ do{ bytes = buffer.available(); apr_status_t s = apr_socket_send(socket, buffer.start(), &bytes); + // TODO aconway 2006-10-05: better error handling + assert(s == 0); buffer.move(bytes); }while(bytes > 0); } Modified: incubator/qpid/trunk/qpid/cpp/common/io/src/BlockingAPRAcceptor.cpp URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/common/io/src/BlockingAPRAcceptor.cpp?view=diff&rev=462834&r1=462833&r2=462834 ============================================================================== --- incubator/qpid/trunk/qpid/cpp/common/io/src/BlockingAPRAcceptor.cpp (original) +++ incubator/qpid/trunk/qpid/cpp/common/io/src/BlockingAPRAcceptor.cpp Wed Oct 11 08:50:15 2006 @@ -24,10 +24,11 @@ using namespace qpid::framing; using namespace qpid::io; -BlockingAPRAcceptor::BlockingAPRAcceptor(bool _debug, int c) : connectionBacklog(c), - threadFactory(new APRThreadFactory()), - debug(_debug){ - +BlockingAPRAcceptor::BlockingAPRAcceptor(bool _debug, int c) : + debug(_debug), + threadFactory(new APRThreadFactory()), + connectionBacklog(c) +{ APRBase::increment(); CHECK_APR_SUCCESS(apr_pool_create(&apr_pool, NULL)); } Modified: incubator/qpid/trunk/qpid/cpp/common/io/src/BlockingAPRSessionContext.cpp URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/common/io/src/BlockingAPRSessionContext.cpp?view=diff&rev=462834&r1=462833&r2=462834 ============================================================================== --- incubator/qpid/trunk/qpid/cpp/common/io/src/BlockingAPRSessionContext.cpp (original) +++ incubator/qpid/trunk/qpid/cpp/common/io/src/BlockingAPRSessionContext.cpp Wed Oct 11 08:50:15 2006 @@ -15,6 +15,7 @@ * limitations under the License. * */ +#include <assert.h> #include <iostream> #include "BlockingAPRSessionContext.h" #include "BlockingAPRAcceptor.h" @@ -32,10 +33,10 @@ bool _debug) : socket(_socket), debug(_debug), - inbuf(65536), - outbuf(65536), handler(0), acceptor(_acceptor), + inbuf(65536), + outbuf(65536), closed(false){ reader = new Reader(this); @@ -73,9 +74,9 @@ inbuf.flip(); if(!initiated){ - ProtocolInitiation* init = new ProtocolInitiation(); - if(init->decode(inbuf)){ - handler->initiated(init); + ProtocolInitiation* protocolInit = new ProtocolInitiation(); + if(protocolInit->decode(inbuf)){ + handler->initiated(protocolInit); if(debug) std::cout << "RECV: [" << &socket << "]: Initialised " << std::endl; initiated = true; } @@ -122,6 +123,7 @@ apr_size_t bytes = available; while(available > written){ apr_status_t s = apr_socket_send(socket, data + written, &bytes); + assert(s == 0); // TODO aconway 2006-10-05: Error Handling. written += bytes; bytes = available - written; } @@ -146,9 +148,8 @@ } } -void BlockingAPRSessionContext::init(SessionHandler* handler){ - this->handler = handler; - //start the threads +void BlockingAPRSessionContext::init(SessionHandler* _handler){ + handler = _handler; rThread->start(); wThread->start(); } Modified: incubator/qpid/trunk/qpid/cpp/common/io/src/LFAcceptor.cpp URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/common/io/src/LFAcceptor.cpp?view=diff&rev=462834&r1=462833&r2=462834 ============================================================================== --- incubator/qpid/trunk/qpid/cpp/common/io/src/LFAcceptor.cpp (original) +++ incubator/qpid/trunk/qpid/cpp/common/io/src/LFAcceptor.cpp Wed Oct 11 08:50:15 2006 @@ -21,12 +21,12 @@ using namespace qpid::concurrent; using namespace qpid::io; -LFAcceptor::LFAcceptor(bool _debug, int c, int worker_threads, int m) : processor(aprPool.pool, worker_threads, 1000, 5000000), - connectionBacklog(c), - max_connections_per_processor(m), - debug(_debug){ - -} +LFAcceptor::LFAcceptor(bool _debug, int c, int worker_threads, int m) : + processor(aprPool.pool, worker_threads, 1000, 5000000), + max_connections_per_processor(m), + debug(_debug), + connectionBacklog(c) +{ } void LFAcceptor::bind(int port, SessionHandlerFactory* factory){ Modified: incubator/qpid/trunk/qpid/cpp/common/io/src/LFProcessor.cpp URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/common/io/src/LFProcessor.cpp?view=diff&rev=462834&r1=462833&r2=462834 ============================================================================== --- incubator/qpid/trunk/qpid/cpp/common/io/src/LFProcessor.cpp (original) +++ incubator/qpid/trunk/qpid/cpp/common/io/src/LFProcessor.cpp Wed Oct 11 08:50:15 2006 @@ -25,15 +25,17 @@ using namespace qpid::concurrent; using qpid::QpidError; -LFProcessor::LFProcessor(apr_pool_t* pool, int _workers, int _size, int _timeout) : size(_size), - timeout(_timeout), - signalledCount(0), - current(0), - count(0), - hasLeader(false), - workerCount(_workers), - workers(new Thread*[_workers]), - stopped(false){ +LFProcessor::LFProcessor(apr_pool_t* pool, int _workers, int _size, int _timeout) : + size(_size), + timeout(_timeout), + signalledCount(0), + current(0), + count(0), + workerCount(_workers), + hasLeader(false), + workers(new Thread*[_workers]), + stopped(false) +{ CHECK_APR_SUCCESS(apr_pollset_create(&pollset, size, pool, APR_POLLSET_THREADSAFE)); //create & start the required number of threads @@ -87,17 +89,13 @@ } bool LFProcessor::full(){ - countLock.acquire(); - bool full = count == size; - countLock.release(); - return full; + Locker locker(countLock); + return count == size; } bool LFProcessor::empty(){ - countLock.acquire(); - bool empty = count == 0; - countLock.release(); - return empty; + Locker locker(countLock); + return count == 0; } void LFProcessor::poll(){ Modified: incubator/qpid/trunk/qpid/cpp/common/io/src/LFSessionContext.cpp URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/common/io/src/LFSessionContext.cpp?view=diff&rev=462834&r1=462833&r2=462834 ============================================================================== --- incubator/qpid/trunk/qpid/cpp/common/io/src/LFSessionContext.cpp (original) +++ incubator/qpid/trunk/qpid/cpp/common/io/src/LFSessionContext.cpp Wed Oct 11 08:50:15 2006 @@ -26,17 +26,19 @@ LFSessionContext::LFSessionContext(apr_pool_t* _pool, apr_socket_t* _socket, LFProcessor* const _processor, - bool _debug) : socket(_socket), - processor(_processor), - initiated(false), - processing(false), - closing(false), - in(32768), - out(32768), - reading(0), - writing(0), - debug(_debug){ - + bool _debug) : + debug(_debug), + socket(_socket), + initiated(false), + in(32768), + out(32768), + processor(_processor), + processing(false), + closing(false), + reading(0), + writing(0) +{ + fd.p = _pool; fd.desc_type = APR_POLL_SOCKET; fd.reqevents = APR_POLLIN; @@ -63,9 +65,9 @@ handler->received(&frame); } }else{ - ProtocolInitiation init; - if(init.decode(in)){ - handler->initiated(&init); + ProtocolInitiation protocolInit; + if(protocolInit.decode(in)){ + handler->initiated(&protocolInit); initiated = true; if(debug) std::cout << "INIT [" << &socket << "]" << std::endl; } @@ -173,8 +175,8 @@ handleClose(); } -void LFSessionContext::init(SessionHandler* handler){ - this->handler = handler; +void LFSessionContext::init(SessionHandler* _handler){ + handler = _handler; processor->add(&fd); } Modified: incubator/qpid/trunk/qpid/cpp/common/utils/src/Makefile URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/common/utils/src/Makefile?view=diff&rev=462834&r1=462833&r2=462834 ============================================================================== --- incubator/qpid/trunk/qpid/cpp/common/utils/src/Makefile (original) +++ incubator/qpid/trunk/qpid/cpp/common/utils/src/Makefile Wed Oct 11 08:50:15 2006 @@ -13,13 +13,10 @@ # See the License for the specific language governing permissions and # limitations under the License. # -##### Options ##### -QPID_HOME = ../../../.. - -include ${QPID_HOME}/cpp/options.mk -##### Compiler flags ##### -CXXFLAGS = -I ../inc -I ${APR_HOME}/include/apr-1/ +QPID_HOME = ../../../.. +include $(QPID_HOME)/cpp/options.mk +INCLUDES=$(TEST_INCLUDES) ##### Targets ##### # Add additional source files to SOURCE LIST to include them in the build. Modified: incubator/qpid/trunk/qpid/cpp/options.mk URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/options.mk?view=diff&rev=462834&r1=462833&r2=462834 ============================================================================== --- incubator/qpid/trunk/qpid/cpp/options.mk (original) +++ incubator/qpid/trunk/qpid/cpp/options.mk Wed Oct 11 08:50:15 2006 @@ -24,15 +24,26 @@ APR_HOME = /usr/local/apr # Compile flags -DEBUG = -ggdb3 +DEBUG = -ggdb3 -O0 +OPTIMIZE = # _USE_APR_IO_ set when APR IO build is desired. -OPT = -D _USE_APR_IO_ #-O3 +DEFINES = -D _USE_APR_IO_ APR_INCLUDES=-I ${APR_HOME}/include/apr-1/ COMMON_INCLUDES = -I ${COMMON_HOME}/framing/inc -I ${COMMON_HOME}/framing/generated -I ${COMMON_HOME}/concurrent/inc -I ${COMMON_HOME}/io/inc -I ${COMMON_HOME}/error/inc -I $(COMMON_HOME)/utils/inc ${APR_INCLUDES} SRC_INCLUDES = $(COMMON_INCLUDES) -I inc -TEST_INCLUDES = $(COMMON_INCLUDES) -I ../inc +TEST_INCLUDES = $(COMMON_INCLUDES) -I ../inc -I $(QPID_CPP_HOME)/test/include INCLUDES=$(SRC_INCLUDES) # Default to src -CXXFLAGS = $(DEBUG) $(OPT) -MMD -fpic $(INCLUDES) + +# Warnings: Enable as many as possible, keep the code clean. Please +# do not disable warnings or remove -Werror without discussing on +# qpid-dev list. +# +# The following warnings deliberately omitted, they warn on valid code. +# -Wno-unreachable-code -Wpadded +# +WARN = -Werror -pedantic -Wall -Wextra -Wshadow -Wpointer-arith -Wcast-qual -Wcast-align -Wno-long-long -Wvolatile-register-var -Winvalid-pch -Winline + +CXXFLAGS = $(DEBUG) $(OPTIMIZE) $(DEFINES) $(WARN) -MMD -fpic $(INCLUDES) # General link flags LDFLAGS= -L $(LIB_DIR) -L ${APR_HOME}/lib $(RPATH) Added: incubator/qpid/trunk/qpid/cpp/test/include/qpid_test_plugin.h URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/test/include/qpid_test_plugin.h?view=auto&rev=462834 ============================================================================== --- incubator/qpid/trunk/qpid/cpp/test/include/qpid_test_plugin.h (added) +++ incubator/qpid/trunk/qpid/cpp/test/include/qpid_test_plugin.h Wed Oct 11 08:50:15 2006 @@ -0,0 +1,40 @@ +#ifndef _qpid_test_plugin_ +#define _qpid_test_plugin_ + +/* + * + * Copyright (c) 2006 The Apache Software Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +/** + * Convenience to include cppunit headers needed by qpid test plugins and + * workaround for warning from superfluous main() declaration + * in cppunit/TestPlugIn.h + */ + +#include <cppunit/TestCase.h> +#include <cppunit/TextTestRunner.h> +#include <cppunit/extensions/HelperMacros.h> +#include <cppunit/plugin/TestPlugIn.h> + +// Redefine CPPUNIT_PLUGIN_IMPLEMENT_MAIN to a dummy typedef to avoid warnings. +// +#if defined(CPPUNIT_HAVE_UNIX_DLL_LOADER) || defined(CPPUNIT_HAVE_UNIX_SHL_LOADER) +#undef CPPUNIT_PLUGIN_IMPLEMENT_MAIN +#define CPPUNIT_PLUGIN_IMPLEMENT_MAIN() typedef char __CppUnitPlugInImplementMainDummyTypeDef +#endif + +#endif /*!_qpid_test_plugin_*/ Propchange: incubator/qpid/trunk/qpid/cpp/test/include/qpid_test_plugin.h ------------------------------------------------------------------------------ svn:eol-style = native
