Theory
When deleting a node from a linked list, pointers to the first node in the list will need to be updated if the node being deleted from the list is the first one.
Background
Libevent: how to close all open sockets on shutdown?
Situation
In my server application, a pointer to the first node in a linked list of socket connections is held in a struct holding data related to the context of the running instance, such as listening socket port and so on. When a connection is closed, the related node in the linked list must be removed which means that the function which deletes the node must also access to the instance context struct.
My first ideas were:
Each connection node in the linked list has a pointer to the instance context struct. (Messy.)
Global variable pointer to instance context struct. (Evil.)
Then I had the idea to make the first node in the linked list a sentinel node thereby avoiding the possibility that the first node would ever be removed and therefore side-stepping the need for the socket close function to have access to the instance context.
Question
Is this a suitable use of sentinel nodes or is there a better way to solve this problem?