Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some minor cosmetic fixes. #147

Merged
merged 3 commits into from
Mar 20, 2017
Merged

Some minor cosmetic fixes. #147

merged 3 commits into from
Mar 20, 2017

Conversation

Mag-nus
Copy link
Member

@Mag-nus Mag-nus commented Mar 19, 2017

Some possible threading issues fixed.
This also forces the build for ACE to x64 only.

Some possible threading issues fixed.
}

public void HandlePacket(ClientPacket packet)
{
lastReceivedSequence = packet.Header.Sequence;
lock (lockObject)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I really don't see the need for this lock. If stuff has to Enqueue as a response, it will hit those locks accordingly. This lock could significantly degrade performance.

@@ -12,110 +13,124 @@ namespace ACE.Network
{
public class NetworkSession
{
private readonly Object lockObject = new Object();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I strongly prefer lock objects to be "[objectBeingLocked]Lock" and directly adjacent to it. This appears to be a functional lock for both HandlePacket and EnqueueSend, and I dont' see the necessity of those sharing a lock. In this case, I would have named it "currentBundleLock" or "currentBundleMutex" - either are good.

@@ -168,24 +181,22 @@ private void FlushBundle()

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FlushBundle, above, needs a lock but GitHub won't let me comment on it since you didn't change it. It's what actually wipes out the bundle and resets it. If this is being called within a lock, then it really should be doc'ed to state that the lock is a requirement for calling it. If it's only being called in one place, just move the code to where it's called in the lock.

}

public void EnqueueSend(params ServerPacket[] packets)
{
foreach (var packet in packets)
PacketQueue.Enqueue(packet);
lock (lockObject)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this needs to be a different/new lock/mutex - "packetQueueLock" or "packetQueueMutex" would both be good.

@@ -168,24 +181,22 @@ private void FlushBundle()

private void FlushPackets()
{
while (PacketQueue.Count > 0)
while (packetQueue.Count > 0)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

needs to lock packetQueueLock and copy out the items to be sent and/or "new" up the queue from within the lock, then continue.

@@ -342,7 +353,7 @@ private void SendBundle(NetworkBundle bundle)
}
}

PacketQueue.Enqueue(packet);
packetQueue.Enqueue(packet);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

needs to lock "packetQueueLock"

@Mogwai-TheFurry Mogwai-TheFurry merged commit c99d12f into ACEmulator:master Mar 20, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants