- // The socket engine will clean up their ident request for us when it completes,
- // either due to timeout or due to closing, so, we just hold them until they dont
- // have an ident field any more.
- RFC1413* ident = (RFC1413*)user->GetExt("ident_data");
- return (!ident);
- }
-
- virtual void OnUserDisconnect(userrec* user)
- {
- // when the user quits tidy up any ident lookup they have pending to keep things tidy.
- // When we call RemoveSocket, the abstractions tied into the system evnetually work their
- // way to RFC1459::OnClose(), which shrinks off the ident_data for us, so we dont need
- // to do it here. If we don't tidy this up, there may still be lingering idents for users
- // who have quit, as class RFC1459 is only loosely bound to userrec* via a pair of pointers
- // and this would leave at least one of the invalid ;)
- RFC1413* ident = (RFC1413*)user->GetExt("ident_data");
- if (ident)
- {
+ /*
+ * The socket engine will clean up their ident request for us when it completes,
+ * either due to timeout or due to closing, so, we just hold them until they dont
+ * have an ident field any more.
+ */
+ RFC1413* ident;
+ return (!user->GetExt("ident_data", ident));
+ }
+
+ virtual void OnCleanup(int target_type, void* item)
+ {
+ if (target_type == TYPE_USER)
+ {
+ userrec* user = (userrec*)item;
+ RFC1413* ident;
+ if (user->GetExt("ident_data", ident))
+ {
+ // FIX: If the user record is deleted, the socket wont be removed
+ // immediately so there is chance of the socket trying to write to
+ // a user which has now vanished! To prevent this, set ident::u
+ // to NULL and check it so that we dont write users who have gone away.
+ ident->u = NULL;
+ Srv->RemoveSocket(ident);
+ }
+ }
+ }
+
+ virtual void OnUserDisconnect(userrec* user)
+ {
+ /*
+ * when the user quits tidy up any ident lookup they have pending to keep things tidy.
+ * When we call RemoveSocket, the abstractions tied into the system evnetually work their
+ * way to RFC1459::OnClose(), which shrinks off the ident_data for us, so we dont need
+ * to do it here. If we don't tidy this up, there may still be lingering idents for users
+ * who have quit, as class RFC1459 is only loosely bound to userrec* via a pair of pointers
+ * and this would leave at least one of the invalid ;)
+ */
+ RFC1413* ident;
+ if (user->GetExt("ident_data", ident))
+ {
+ ident->u = NULL;