]> jfr.im git - solanum.git/commitdiff
target change: use fnv32 hash of UID instead of pointer to identify clients
authorJilles Tjoelker <redacted>
Sat, 15 Mar 2008 23:39:49 +0000 (00:39 +0100)
committerJilles Tjoelker <redacted>
Sat, 15 Mar 2008 23:39:49 +0000 (00:39 +0100)
This way, the information remains valid after a split.
For clients on TS5 servers, the nick is used; this is
not much of a problem because these are on pseudoservers
and not assumed to change nick much at all.

doc/tgchange.txt
include/client.h
modules/core/m_message.c

index 0669d67e0cb48929c7f227134eeaaf7ed0c967a2..50e648e5a72e2aadbd019e71649e1eee4b6f036f 100644 (file)
@@ -11,8 +11,8 @@ yourself.
 
 You will have a set number of 'slots', each different client you message
 will take up one slot.  A client doing a nick change will not use a new slot,
-however a client leaving the network and reconnecting will.  You will
-receive 1 new slot roughly every minute.
+however a client disconnecting from the server it is on and reconnecting
+will.  You will receive 1 new slot roughly every minute.
 
 When all slots are filled, messages to new clients will not be accepted.
 Messages to clients already filling a slot will be accepted.  If all slots
index a2d2a14ce0c2fe9bd603f04116e0d1b14e3200ec..2d17c601cf2c047d2d5ff531f88905ee29b1a7a4 100644 (file)
@@ -290,7 +290,7 @@ struct LocalUser
        auth_request_t  *auth_request;
 
        /* target change stuff */
-       void *targets[10];              /* targets were aware of */
+       uint32_t targets[10];           /* targets were aware of (fnv32(use_id(target_p))) */
        unsigned int targinfo[2];       /* cyclic array, no in use */
        time_t target_last;             /* last time we cleared a slot */
 
index 21c93af4923ddfc7ec4e068d006602307df000c7..8f6e7eb898b1545cef5aa2a68908b7b8be0bfc2d 100644 (file)
@@ -566,6 +566,7 @@ static int
 add_target(struct Client *source_p, struct Client *target_p)
 {
        int i, j;
+       uint32_t hashv;
 
        /* can msg themselves or services without using any target slots */
        if(source_p == target_p || IsService(target_p))
@@ -579,13 +580,15 @@ add_target(struct Client *source_p, struct Client *target_p)
        if(source_p->localClient->target_last > CurrentTime && IsOper(target_p))
                return 1;
 
+       hashv = fnv_hash_upper(use_id(target_p), 32);
+
        if(USED_TARGETS(source_p))
        {
                /* hunt for an existing target */
                for(i = PREV_FREE_TARGET(source_p), j = USED_TARGETS(source_p);
                    j; --j, PREV_TARGET(i))
                {
-                       if(source_p->localClient->targets[i] == target_p)
+                       if(source_p->localClient->targets[i] == hashv)
                                return 1;
                }
 
@@ -624,7 +627,7 @@ add_target(struct Client *source_p, struct Client *target_p)
                SetTGChange(source_p);
        }
 
-       source_p->localClient->targets[FREE_TARGET(source_p)] = target_p;
+       source_p->localClient->targets[FREE_TARGET(source_p)] = hashv;
        NEXT_TARGET(FREE_TARGET(source_p));
        ++USED_TARGETS(source_p);
        return 1;