Skip to content

Commit

Permalink
6.22 release
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeremy Friesner authored and Jeremy Friesner committed Jun 11, 2015
1 parent 35cd7b1 commit e9ccb50
Show file tree
Hide file tree
Showing 39 changed files with 1,583 additions and 127 deletions.
18 changes: 17 additions & 1 deletion HISTORY.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,26 @@ key: - new feature
* bug fixed
o other

6.22 Released 6/11/2015
- Added an IsWaitingForEvents() method to ReflectServer class,
so that a (user-supplied) watchdog thread can observe when the
ReflectServer is blocked waiting for I/O vs when it is doing
something.
- Added Mika's vc++14 subdirectory, which contains Visual C++
project files for Visual Studio 2015.
- DataNode::GetAncestorNode() now takes an optional second argument
that tells it what to return if the ancestor node isn't found.
o Added some more Cygwin/MinGW compatibility changes contributed
by Mika Lindqvist.
o Rewrote some of the node-traversal callback methods so that they
no longer pass an integer argument by casting it to (void *).
* Tweaked various files to fix warnings reported by cppcheck 1.69.
* The stdout-display in qt_muscled wasn't read-only. Fixed.

6.21 Released 5/14/2015
o Merged in Mika Lindqvist's patch to make the StackWalker code
use less stack space.
o Merged in Mika Linkdqvist's patches for better Cygwin compatibility.
o Merged in Mika Lindqvist's patches for better Cygwin compatibility.
* Made the StackWalker code a bit more robust.
* Merged in Mika Lindqvist's patch to the VC++12 projects
to link debug builds against the MultiThreadedDebug
Expand Down
2 changes: 1 addition & 1 deletion README.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<H2>
MUSCLE: Crossbar Server, Portable Messaging and Support Classes<p>
5/14/2015 v6.21 jaf@meyersound.com<p>
6/11/2015 v6.22 jaf@meyersound.com<p>
Jeremy Friesner / Meyer Sound Laboratories Inc.<p>
Win32 compatibility contributions by Vitaliy Mikitchenko<p>
C# client code by Wilson Yeung<p>
Expand Down
4 changes: 2 additions & 2 deletions besupport/admin_gui/MuscleAdminView.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class MuscleAdminView : public BView {


protected:
MuscleAdminView(BMessage* archive);
explicit MuscleAdminView(BMessage* archive);

virtual void Update(bool force = false);

Expand All @@ -64,7 +64,7 @@ class MuscleAdminReplicant : public MuscleAdminView {
public:
MuscleAdminReplicant(BRect frame,
int32 resizingMode, bool inDeskbar = false);
MuscleAdminReplicant(BMessage* archive);
explicit MuscleAdminReplicant(BMessage* archive);
virtual ~MuscleAdminReplicant();

static MuscleAdminReplicant* Instantiate(BMessage* archive);
Expand Down
2 changes: 1 addition & 1 deletion html/Beginners Guide.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<HTML>
<HEAD>
<H1>MUSCLE Overview and Beginner's Guide</H1>
<H4>v6.21 / Jeremy Friesner / Meyer Sound Laboratories Inc (jaf@meyersound.com) 5/14/2015</H4>
<H4>v6.22 / Jeremy Friesner / Meyer Sound Laboratories Inc (jaf@meyersound.com) 6/22/2015</H4>
<A HREF="http://www.lcscanada.com/muscle/html/index.html">Click here for DOxygen class API documentation</A>
</HEAD>

Expand Down
2 changes: 1 addition & 1 deletion html/Custom Servers.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<HTML>
<HEAD>
<H1>Implementing a Custom Server with MUSCLE</H1>
<H4>v6.21 / Jeremy Friesner / Meyer Sound Laboratories Inc / jaf@meyersound.com 5/14/2015</H4>
<H4>v6.22 / Jeremy Friesner / Meyer Sound Laboratories Inc / jaf@meyersound.com 6/11/2015</H4>
</HEAD>
<BODY bgcolor=#ffffff>
<H2>Introduction</H2>
Expand Down
6 changes: 2 additions & 4 deletions micromessage/MicroMessage.c
Original file line number Diff line number Diff line change
Expand Up @@ -397,9 +397,7 @@ status_t UMAddData(UMessage * msg, const char * fieldName, uint32 dataType, cons
dataPtr += sizeof(uint32);

memcpy(dataPtr, dataBytes, numBytes);
#ifdef DISABLED_TO_SHUT_CLANGS_ANALYER_UP
dataPtr += numBytes;
#endif
//dataPtr += numBytes; // commented out to shut Clang static analyzer and cppcheck up

IncreaseCurrentFieldDataLength(msg, numDataBytes);
return B_NO_ERROR;
Expand Down Expand Up @@ -528,7 +526,7 @@ void UMIteratorAdvance(UMessageFieldNameIterator * iter)
{
while(iter->_currentField)
{
void * ftptr = GetFieldTypePointer(iter->_currentField);
uint8 * ftptr = GetFieldTypePointer(iter->_currentField);
uint32 fieldDataLen = GetFieldDataLength(ftptr);
iter->_currentField = ftptr+(sizeof(uint32)+sizeof(uint32)+fieldDataLen);
if (iter->_currentField > (iter->_message->_buffer+iter->_message->_numValidBytes))
Expand Down
2 changes: 1 addition & 1 deletion minimessage/MiniMessage.c
Original file line number Diff line number Diff line change
Expand Up @@ -786,7 +786,6 @@ status_t MMUnflattenMessage(MMessage * msg, const void * inBuf, uint32 inputBuff
{
uint32 i, readOffset = 0;
const uint8 * buffer = (const uint8 *) inBuf;
const uint8 * dataPtr;

/* Read and check protocol version number */
uint32 networkByteOrder, numEntries;
Expand Down Expand Up @@ -815,6 +814,7 @@ status_t MMUnflattenMessage(MMessage * msg, const void * inBuf, uint32 inputBuff
uint32 nameLength, tc, eLength;
MMessageField * newField = NULL;
MBool doAddField = MTrue;
const uint8 * dataPtr;

/* Read entry name length */
if (ReadData(buffer, inputBufferBytes, &readOffset, &networkByteOrder, sizeof(networkByteOrder)) != B_NO_ERROR) return B_ERROR;
Expand Down
2 changes: 1 addition & 1 deletion qtsupport/QMessageTransceiverThread.h
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ class QMessageTransceiverThreadPool : public IMessageTransceiverMaster, private
* @param maxSessionsPerThread The maximum number of sessions to add to each
* thread in the pool. Defaults to 32.
*/
QMessageTransceiverThreadPool(uint32 maxSessionsPerThread = 32);
explicit QMessageTransceiverThreadPool(uint32 maxSessionsPerThread = 32);

/** Destructor. Deletes all QMessageTransceiverThread objects in the pool.
* Any QMessageTransceiverHandlers still attached to those threads will be detached.
Expand Down
2 changes: 1 addition & 1 deletion qtsupport/qt_advanced_example/ThreadedInternalSession.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class ThreadedInternalSession : public AdvancedThreadWorkerSession, private Thre
/** Constructor
* @param args This can contain whatever information the thread will find useful when it starts up.
*/
ThreadedInternalSession(const MessageRef & args);
explicit ThreadedInternalSession(const MessageRef & args);

/** Called during setup. Overridden to start the internal thread running. */
virtual status_t AttachedToServer();
Expand Down
1 change: 1 addition & 0 deletions qtsupport/qt_muscled/qt_muscled.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ MuscledWindow :: MuscledWindow(const char * argv0) : _cpdio(false), _notifier(NU
bl->setSpacing(0);

_muscledStdoutText = new QPlainTextEdit;
_muscledStdoutText->setReadOnly(true);
bl->addWidget(_muscledStdoutText);

Queue<String> argv;
Expand Down
2 changes: 1 addition & 1 deletion qtsupport/qt_muscled/qt_muscled.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class MuscledWindow : public QWidget, public AbstractGatewayMessageReceiver
Q_OBJECT

public:
MuscledWindow(const char * argv0);
explicit MuscledWindow(const char * argv0);
virtual ~MuscledWindow();

private slots:
Expand Down
2 changes: 1 addition & 1 deletion qtsupport/qt_muscled_browser/Browser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ using namespace muscle;
class NodeTreeWidgetItem : public QTreeWidgetItem
{
public:
NodeTreeWidgetItem(QTreeWidget * parent) : QTreeWidgetItem(parent, QStringList("/")) {setChildIndicatorPolicy(QTreeWidgetItem::ShowIndicator);}
explicit NodeTreeWidgetItem(QTreeWidget * parent) : QTreeWidgetItem(parent, QStringList("/")) {setChildIndicatorPolicy(QTreeWidgetItem::ShowIndicator);}
NodeTreeWidgetItem(NodeTreeWidgetItem * parent, const String & name) : QTreeWidgetItem(parent, QStringList(name())), _name(name) {setChildIndicatorPolicy(QTreeWidgetItem::ShowIndicator);}

NodeTreeWidgetItem * GetChildByName(const String & name)
Expand Down
15 changes: 7 additions & 8 deletions reflector/DataNode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,26 +52,25 @@ void DataNode :: IncrementSubscriptionRefCount(const String & sessionID, long de

if (delta > 0)
{
uint32 res = 0;
if (_subscribers == NULL)
{
_subscribers = newnothrow Hashtable<const String *, uint32>;
if (_subscribers == NULL) WARN_OUT_OF_MEMORY;
}
if (_subscribers)
{
(void) _subscribers->Get(&sessionID, res);
(void) _subscribers->Put(&sessionID, res+delta); // I'm not sure how to cleanly handle out-of-mem here?? --jaf
uint32 * pCount = _subscribers->GetOrPut(&sessionID);
if (pCount) (*pCount) += delta;
}
}
else if (delta < 0)
{
uint32 res = 0;
if ((_subscribers)&&(_subscribers->Get(&sessionID, res) == B_NO_ERROR))
uint32 * pCount = _subscribers ? _subscribers->Get(&sessionID) : NULL;
if (pCount)
{
uint32 decBy = (uint32) -delta;
if (decBy >= res) (void) _subscribers->Remove(&sessionID);
else (void) _subscribers->Put(&sessionID, res-decBy); // out-of-mem shouldn't be possible
if (decBy >= *pCount) (void) _subscribers->Remove(&sessionID);
else (*pCount) -= decBy;
}
}
}
Expand Down Expand Up @@ -301,7 +300,7 @@ status_t DataNode :: GetNodePath(String & retPath, uint32 startDepth) const

char * dynBuf = NULL;
const uint32 stackAllocSize = 256;
char stackBuf[stackAllocSize]; // try to do this without a dynamic allocation...
char stackBuf[stackAllocSize] = ""; // try to do this without a dynamic allocation...
if (pathLen >= stackAllocSize) // but do a dynamic allocation if we have to (should be rare)
{
dynBuf = newnothrow_array(char, pathLen+1);
Expand Down
13 changes: 7 additions & 6 deletions reflector/DataNode.h
Original file line number Diff line number Diff line change
Expand Up @@ -237,19 +237,20 @@ class DataNode MUSCLE_FINAL_CLASS : public RefCountable, private CountedObject<D
DataNode * GetRootNode() const {DataNode * r = const_cast<DataNode *>(this); while(r->GetParent()) r = r->GetParent(); return r;}

/** Convenience function: Given a depth value less than or equal to our depth, returns a pointer to our ancestor node at that depth.
* @param depth The depth of the node we want returned, relative to the root of the tree. Zero would be the root node, one would be a child
* of the root node, and so on.
* @returns an ancestor DataNode, or NULL if such a node could not be found (most likely because (depth) is greater than this node's depth)
* @param depth The depth of the node we want returned, relative to the root of the tree. Zero would be the root node,
* one would be a child of the root node, and so on.
* @param defaultValue The value to return if an ancestor of the requested depth could not be found. Defaults to NULL.
* @returns an ancestor DataNode, or (defaultValue) if such a node could not be found (most likely because (depth) is greater than this node's depth)
*/
DataNode * GetAncestorNode(uint32 depth) const
DataNode * GetAncestorNode(uint32 depth, DataNode * defaultValue = NULL) const
{
DataNode * r = const_cast<DataNode *>(this);
while((r)&&(depth <= r->GetDepth()))
while((r)&&(r->GetDepth() >= depth))
{
if (depth == r->GetDepth()) return r;
r = r->GetParent();
}
return NULL;
return defaultValue;
}

/** Returns a checksum representing the state of this node and the nodes
Expand Down
14 changes: 10 additions & 4 deletions reflector/ReflectServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -541,11 +541,17 @@ ServerProcessLoop()
TCHECKPOINT;

// This block is the center of the MUSCLE server's universe -- where we sit and wait for the next event
if (_multiplexer.WaitForEvents(nextPulseAt) < 0)
{
if (_doLogging) LogTime(MUSCLE_LOG_CRITICALERROR, "WaitForEvents() failed, aborting!\n");
ClearLameDucks();
return B_ERROR;
_inWaitForEvents.AtomicIncrement(); // so a watchdog thread can know we're meant to be waiting at this point
int r = _multiplexer.WaitForEvents(nextPulseAt);
_inWaitForEvents.AtomicDecrement(); // so a watchdog thread can know we're done waiting at this point

if (r < 0)
{
if (_doLogging) LogTime(MUSCLE_LOG_CRITICALERROR, "WaitForEvents() failed, aborting!\n");
ClearLameDucks();
return B_ERROR;
}
}

// Each event-loop cycle officially "starts" as soon as WaitForEvents() returns
Expand Down
12 changes: 12 additions & 0 deletions reflector/ReflectServer.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

#include "reflector/AbstractReflectSession.h"
#include "support/NotCopyable.h"
#include "system/AtomicCounter.h"
#include "util/NestCount.h"
#include "util/SocketMultiplexer.h"

Expand Down Expand Up @@ -248,6 +249,15 @@ class ReflectServer : public RefCountable, public PulseNode, private PulseNodeMa
const ConstByteBufferRef & GetSSLPublicKeyCertificate() const {return _publicKey;}
#endif

/** Returns true iff our event loop is currently blocked inside the SocketMultiplexer::WaitForEvents() call.
* Note that calling this function from another thread is subject to race conditions, and that
* if you call it from the thread that is running the ReflectServer's event loop it will always
* return false, since if the thread was blocked inside WaitForEvents() you wouldn't have control
* of the thread to call it. This method is here to enable a separate watchdog thread to observe
* the operations of the main thread; in general it is not necessary to call this method.
*/
bool IsWaitingForEvents() const {return (_inWaitForEvents.GetCount() == 1);}

protected:
/**
* This version of AddNewSession (which is called by the previous
Expand Down Expand Up @@ -321,6 +331,8 @@ class ReflectServer : public RefCountable, public PulseNode, private PulseNodeMa
#endif
NestCount _inDoAccept;
NestCount _inDoConnect;

AtomicCounter _inWaitForEvents;
};
DECLARE_REFTYPES(ReflectServer);

Expand Down
Loading

0 comments on commit e9ccb50

Please sign in to comment.