Git Product home page Git Product logo

Comments (23)

ryantaplin avatar ryantaplin commented on May 16, 2024

If you then step into Disconnect(20) it then does the following which contradicts the previous piece of code?

e.g. if !Connected do Disconnect -> if !Connected return;

public void Disconnect(byte reason)
        {
            if (!Connected) return;

from crystal.

Suprcode avatar Suprcode commented on May 16, 2024

Disconnect method is cleaning up the server connection - the client.connected is the client connection

So once the client disconnects, the server needs to clean everything up and disconnect it from the server end.

from crystal.

ryantaplin avatar ryantaplin commented on May 16, 2024

So if client connection is null or disconnected then disconnect the server side socket for that client?

How does it determine if a client connection is disconnected? I assume the client sends a packet on termination to set the boolean to false otherwise it times out with lack of communication?

I'm very confused by the reference to line 0 in the error. I think he gets this error daily however it's I guess random so we can't identify the issue? It's also an issue that I've only seen from him.

My guess is that either Connections[i] or StatusConnections]i] is being set to null or being deleted just before .Process() is being run on it which has to be extremely unlucky? But to be getting this error several times a day (assuming it is this that keeps crashing his server) must be a a high probability of conflict.

from crystal.

ryantaplin avatar ryantaplin commented on May 16, 2024

Do you think adding the null checks will possibly prevent this? Although should it ever get to this point where they are null and still in the list?

    lock (Connections)
    {
        for (int i = Connections.Count - 1; i >= 0; i--)
        {
            if (Connections[i] != null)
                Connections[i].Process();
        }
    }

    lock (StatusConnections)
    {
        for (int i = StatusConnections.Count - 1; i >= 0; i--)
        {
            if (StatusConnections[i] != null)
                StatusConnections[i].Process();
        }
    }

from crystal.

Suprcode avatar Suprcode commented on May 16, 2024

i expect adding null checks is just hiding the real issue. and i dont know
enough about the issue to suggest how to fix it

On Mon, 14 Nov 2016, 6:59 p.m. Ryan, [email protected] wrote:

Do you think adding the null checks will possibly prevent this? Although
should it ever get to this point where they are null and still in the list?

lock (Connections)
{
for (int i = Connections.Count - 1; i >= 0; i--)
{
if (Connections[i] != null)
Connections[i].Process();
}
}

                        lock (StatusConnections)
                        {
                            for (int i = StatusConnections.Count - 1; i >= 0; i--)
                            {
                                **if (StatusConnections[i] != null)**
                                    StatusConnections[i].Process();
                            }
                        }


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#220 (comment), or mute
the thread
https://github.com/notifications/unsubscribe-auth/AJgJari7L-jkjTI4ED4QwiaWVyTxnj7Lks5q-K9-gaJpZM4Kxox6
.

from crystal.

ryantaplin avatar ryantaplin commented on May 16, 2024

Hmm the real issue, but what does that entail? The real issue at hand (i assume) is that it's trying to run .Process() on Connection that is null?

So maybe trying to look for where connections are set to null and work around that may be a better solution? However do you know if this .Process() can be running synchronously alongside other method calls? E.g. a method is being run that is setting the connection to null whilst the method to run .Process() is also running.

Maybe i'll ask Jamie if he's feeling generous enough to give me some info/tips 😃 thanks @Suprcode

from crystal.

Suprcode avatar Suprcode commented on May 16, 2024

i think you mean async, and no the server workloop runs on a single thread
so can only be called 1 at a time

On Mon, 14 Nov 2016, 7:10 p.m. Ryan, [email protected] wrote:

Hmm the real issue, but what does that entail? The real issue at hand (i
assume) is that it's trying to run .Process() on Connection that is null?

So maybe trying to look for where connections are set to null and work
around that may be a better solution? However do you know if this
.Process() can be running synchronously alongside other method calls? E.g.
a method is being run that is setting the connection to null whilst the
method to run .Process() is also running.

Maybe i'll ask Jamie if he's feeling generous enough to give me some
info/tips 😃 thanks @Suprcode https://github.com/Suprcode


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#220 (comment), or mute
the thread
https://github.com/notifications/unsubscribe-auth/AJgJagPvDaTXyZ3Yfxx6CozQkCGgrcOOks5q-LIOgaJpZM4Kxox6
.

from crystal.

ryantaplin avatar ryantaplin commented on May 16, 2024

After falling asleep and checking my PMs there was little progress. Jamie is unsure of the issue aswell however has given some pointers;

Possible causes:

  1. Either Multiple Threads are calling Process() at the same time.
  2. SMain.Envir is null

I can't be certain if the MirConnection is Null or there is a variable inside the Process() Method is null because the "at line 0" seems to be throwing me off.

I'm not sure if SMain.Envir could ever be null? I assumed not as this is in effect removing your entire data from the server whilst people are mid using it? Unless the actual issue is in relation to..

public static Envir EditEnvir = null;

So going forward from here; possibly add a null check within the loop as I have done above alongside some server side logging/debugging so we can check if we ever get into a state were we receive a null Connection which it is trying to process. We can then see if this temporarily / permanently fixes the issue. Otherwise I'm not sure where to go forward; any other suggestions @Suprcode ?

from crystal.

ryantaplin avatar ryantaplin commented on May 16, 2024

@Suprcode are you sure it's not asynchronous? In the config.ini there is settings for more than one thread. Which is also reflected in the WorkLoop() method which is where we are getting the error. I think it's only for monsters.

Or are these individual threads for monsters (meaning that a thread is for one specific object and shouldn't conflict with other threads.

MobThread Info = MobThreads[j];
                        if (j > 0) //dont start up 0 
                        {
                            MobThreading[j] = new Thread(() => ThreadLoop(Info));
                            MobThreading[j].IsBackground = true;
                            MobThreading[j].Start();
                        }
Multithreaded=True
ThreadLimit=2

from crystal.

Suprcode avatar Suprcode commented on May 16, 2024

threading is used purely on monsters, everything else running on the same thread

from crystal.

ryantaplin avatar ryantaplin commented on May 16, 2024

I've added a bunch of logging in a separate branch around WorkLoop() and all Process() method calls I could find in it. I'll ask the NoName server gm to implement it and send me the log file when the server crashes to see if it catches any nulls anywhere.

from crystal.

ryantaplin avatar ryantaplin commented on May 16, 2024

Is it normal that we are running Process() on a tonne of empty maps? It's not causing any issues on my local server but is it normal? @Suprcode

P.S. the log is wrong it's at MirEnvir.Envir

15/11/2016 21:32:00: MapList[i] where i = 373 was null [Line 628 MirNetwork.MirConnection]
15/11/2016 21:32:00: MapList[i] where i = 374 was null [Line 628 MirNetwork.MirConnection]
15/11/2016 21:32:00: MapList[i] where i = 375 was null [Line 628 MirNetwork.MirConnection]
15/11/2016 21:32:00: MapList[i] where i = 376 was null [Line 628 MirNetwork.MirConnection]
15/11/2016 21:32:00: MapList[i] where i = 377 was null [Line 628 MirNetwork.MirConnection]
15/11/2016 21:32:00: MapList[i] where i = 378 was null [Line 628 MirNetwork.MirConnection]
15/11/2016 21:32:00: MapList[i] where i = 379 was null [Line 628 MirNetwork.MirConnection]
15/11/2016 21:32:00: MapList[i] where i = 380 was null [Line 628 MirNetwork.MirConnection]
15/11/2016 21:32:00: MapList[i] where i = 381 was null [Line 628 MirNetwork.MirConnection]
15/11/2016 21:32:00: MapList[i] where i = 382 was null [Line 628 MirNetwork.MirConnection]
15/11/2016 21:32:00: MapList[i] where i = 383 was null [Line 628 MirNetwork.MirConnection]
15/11/2016 21:32:00: MapList[i] where i = 384 was null [Line 628 MirNetwork.MirConnection]
15/11/2016 21:32:00: MapList[i] where i = 385 was null [Line 628 MirNetwork.MirConnection]
15/11/2016 21:32:00: MapList[i] where i = 0 was null [Line 628 MirNetwork.MirConnection]
15/11/2016 21:32:00: MapList[i] where i = 1 was null [Line 628 MirNetwork.MirConnection]
15/11/2016 21:32:00: MapList[i] where i = 2 was null [Line 628 MirNetwork.MirConnection]
15/11/2016 21:32:00: MapList[i] where i = 3 was null [Line 628 MirNetwork.MirConnection]
15/11/2016 21:32:00: MapList[i] where i = 4 was null [Line 628 MirNetwork.MirConnection]

from crystal.

Suprcode avatar Suprcode commented on May 16, 2024

empty maps still have to processed like everything else. there are already
checks in the suitable methods to skip over parts which dont need to run
when empty

On Tue, 15 Nov 2016, 9:34 p.m. Ryan, [email protected] wrote:

Is it normal that we are running Process() on a tonne of empty maps?

P.S. the log is wrong it's at MirEnvir.Envir

15/11/2016 21:32:00: MapList[i] where i = 373 was null [Line 628 MirNetwork.MirConnection]
15/11/2016 21:32:00: MapList[i] where i = 374 was null [Line 628 MirNetwork.MirConnection]
15/11/2016 21:32:00: MapList[i] where i = 375 was null [Line 628 MirNetwork.MirConnection]
15/11/2016 21:32:00: MapList[i] where i = 376 was null [Line 628 MirNetwork.MirConnection]
15/11/2016 21:32:00: MapList[i] where i = 377 was null [Line 628 MirNetwork.MirConnection]
15/11/2016 21:32:00: MapList[i] where i = 378 was null [Line 628 MirNetwork.MirConnection]
15/11/2016 21:32:00: MapList[i] where i = 379 was null [Line 628 MirNetwork.MirConnection]
15/11/2016 21:32:00: MapList[i] where i = 380 was null [Line 628 MirNetwork.MirConnection]
15/11/2016 21:32:00: MapList[i] where i = 381 was null [Line 628 MirNetwork.MirConnection]
15/11/2016 21:32:00: MapList[i] where i = 382 was null [Line 628 MirNetwork.MirConnection]
15/11/2016 21:32:00: MapList[i] where i = 383 was null [Line 628 MirNetwork.MirConnection]
15/11/2016 21:32:00: MapList[i] where i = 384 was null [Line 628 MirNetwork.MirConnection]
15/11/2016 21:32:00: MapList[i] where i = 385 was null [Line 628 MirNetwork.MirConnection]
15/11/2016 21:32:00: MapList[i] where i = 0 was null [Line 628 MirNetwork.MirConnection]
15/11/2016 21:32:00: MapList[i] where i = 1 was null [Line 628 MirNetwork.MirConnection]
15/11/2016 21:32:00: MapList[i] where i = 2 was null [Line 628 MirNetwork.MirConnection]
15/11/2016 21:32:00: MapList[i] where i = 3 was null [Line 628 MirNetwork.MirConnection]
15/11/2016 21:32:00: MapList[i] where i = 4 was null [Line 628 MirNetwork.MirConnection]


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#220 (comment), or mute
the thread
https://github.com/notifications/unsubscribe-auth/AJgJatqKV81AWNB9s8GX__P137OJCMgWks5q-iVzgaJpZM4Kxox6
.

from crystal.

ryantaplin avatar ryantaplin commented on May 16, 2024

So doing the lightning / lava effects on an empty map is necessary? I find it odd a little.

I'm not sure if my understanding of 'an empty map' correct. I thought an empty map would be a Map that has no file associated to it or something along those lines. In this context MapList holds Map objects which means there is nothing defined for that Map object. No file; no name; no respawns etc.

from crystal.

Suprcode avatar Suprcode commented on May 16, 2024

things like lava effects take little to no processing time. only the main
processes are paused on empty maps.

if a map has no file then it wont be loaded at all i expect. empty maps are
those with no players.

On Tue, 15 Nov 2016, 9:42 p.m. Ryan, [email protected] wrote:

So doing the lightning / lava effects on an empty map is necessary? I find
it odd a little.

I'm not sure if my understanding of 'an empty map' correct. I thought an
empty map would be a Map that has no file associated to it or something
along those lines.


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#220 (comment), or mute
the thread
https://github.com/notifications/unsubscribe-auth/AJgJauC0teHsjISwOuMklnjUOna-9QEHks5q-idFgaJpZM4Kxox6
.

from crystal.

ryantaplin avatar ryantaplin commented on May 16, 2024

Hmm interesting; so how is that defined? I assume when Map = null it would mean all of the following fields are undefined. Not just players.

It's kind of like saying that Object Car = null; = no people in the car when in fact I read it as = Car does not exist (there is no car at all). How do you come to this conclusion? Sorry if it's a noob question 😭

        public MapInfo Info;
        public int Thread = 0;

        public int Width, Height;
        public Cell[,] Cells;
        public List<Point> WalkableCells;
        public Door[,] DoorIndex;
        public List<Door> Doors = new List<Door>();
        public MineSpot[,] Mine;
        public long LightningTime, FireTime, InactiveTime;
        public int MonsterCount, InactiveCount;

        public List<NPCObject> NPCs = new List<NPCObject>();
        public List<PlayerObject> Players = new List<PlayerObject>();
        public List<MapRespawn> Respawns = new List<MapRespawn>();
        public List<DelayedAction> ActionList = new List<DelayedAction>();

        public List<ConquestObject> Conquest = new List<ConquestObject>();
        public ConquestObject tempConquest;

from crystal.

Suprcode avatar Suprcode commented on May 16, 2024

ive no idea what you mean. if the map file doesnt exist the map object wont
get created.

On Tue, 15 Nov 2016, 9:51 p.m. Ryan, [email protected] wrote:

Hmm interesting; so how is that defined? I assume when Map = null it would
mean all of the following fields are undefined. Not just players.

It's kind of like saying that Object Car = null; means it has no people in
the car when in fact I read it as - Car does not exist (there is no car).
How do you come to this conclusion? Sorry if it's a noob question 😭

    public MapInfo Info;
    public int Thread = 0;

    public int Width, Height;
    public Cell[,] Cells;
    public List<Point> WalkableCells;
    public Door[,] DoorIndex;
    public List<Door> Doors = new List<Door>();
    public MineSpot[,] Mine;
    public long LightningTime, FireTime, InactiveTime;
    public int MonsterCount, InactiveCount;

    public List<NPCObject> NPCs = new List<NPCObject>();
    public List<PlayerObject> Players = new List<PlayerObject>();
    public List<MapRespawn> Respawns = new List<MapRespawn>();
    public List<DelayedAction> ActionList = new List<DelayedAction>();

    public List<ConquestObject> Conquest = new List<ConquestObject>();
    public ConquestObject tempConquest;


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#220 (comment), or mute
the thread
https://github.com/notifications/unsubscribe-auth/AJgJaos3n0_FZ7Su6wlplD1NJigvZJ3Nks5q-ilngaJpZM4Kxox6
.

from crystal.

ryantaplin avatar ryantaplin commented on May 16, 2024

So let me break down my thoughts. Maybe there is some miscommunication; i'm sure this will sound really patronizing however I hope it will make it a bit clearer,

MapList is defined here as a List of Map Objects
public List<Map> MapList = new List<Map>();

So MapList[i] is an instance of Map Object
MapList[i] = MapObject

If MapList[i] = null then we have a null/ non existant Map Object.
MapList[i] = null <- Means that the MapObject is non existant?

So we shouldn't have any of these but for some reason we do?

from crystal.

Suprcode avatar Suprcode commented on May 16, 2024

map should never be null. not sure how it would even be possible since its
only added to the list after an instance is created

On Tue, 15 Nov 2016, 9:58 p.m. Ryan, [email protected] wrote:

So let me break down my thoughts. Maybe there is some miscommunication;
i'm sure this will sound really patronizing however I hope it will make it
a bit clearer,

MapList is defined here as a List of Map Objects
public List MapList = new List();

So MapList[i] is an instance of Map Object
MapList[i] = Map Object

If MapList[i] = null then we have a null/ non existant Map Object. So we
shouldn't have any of these but for some reason we do?

MapList[i] = null <- Means that the mapObject is non existant?


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#220 (comment), or mute
the thread
https://github.com/notifications/unsubscribe-auth/AJgJauA7MEiJ9OTuwGLnZzWmEGqHBenEks5q-isEgaJpZM4Kxox6
.

from crystal.

ryantaplin avatar ryantaplin commented on May 16, 2024

Hmm i'm not sure either; the only instances of MapList.Add(map) i found are as follows.

            Map map = new Map(this);

            if (!map.Load()) return;

            SMain.Envir.MapList.Add(map);

I assume the !map.Load() should catch any errors; if thhe map is null it shouldn't allow map.Load() to run on it anyway. Not really familiar with try { } catch { } so couldn't tell if it's working as intended.

from crystal.

Suprcode avatar Suprcode commented on May 16, 2024

id double check your debugging. map cannot be null and in the maplist

On Tue, 15 Nov 2016, 10:12 p.m. Ryan, [email protected] wrote:

Hmm i'm not sure either; the only instances of MapList.Add(map) i found
are as follows.

        Map map = new Map(this);

        if (!map.Load()) return;

        SMain.Envir.MapList.Add(map);

I assume the !map.Load() should catch any errors; if thhe map is null it
shouldn't allow map.Load() to run on it anyway. Not really familiar with
try { } catch { } so couldn't tell if it's working as intended.


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#220 (comment), or mute
the thread
https://github.com/notifications/unsubscribe-auth/AJgJajBkrHFO1pqarUxQE0iooLFSoLxwks5q-i4zgaJpZM4Kxox6
.

from crystal.

ryantaplin avatar ryantaplin commented on May 16, 2024
for (int i = 0; i < MapList.Count; i++)
                        {
                            //File.AppendAllText(@".\DebuggingError.txt", String.Format("{0}: MapList[i] where i = {1} was null [Line 628 MirNetwork.MirConnection]", DateTime.Now, i) + Environment.NewLine);
                            MapList[i].Process();
                        }

Lols dumbo me; I think someone forgot to put the if() statement in 🤓 👊

Sorry. I'm being stupid today 😢

from crystal.

ryantaplin avatar ryantaplin commented on May 16, 2024

Doesn't seem to have happened for a while. I'll close the issue; if it reoccurs I can reopen it.

from crystal.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.