X-Git-Url: http://git.sameswireless.fr/l2tpns.git/blobdiff_plain/ce928583b47102056e28201bd677f4813fada3c6..7fd68b1daeab9a2a1a3ee8f0652c25fc37bf3549:/cluster.c diff --git a/cluster.c b/cluster.c index b54ae0c..67d8d5e 100644 --- a/cluster.c +++ b/cluster.c @@ -1002,6 +1002,36 @@ static int type_changed(int type, int id) return 1; } +// The deleted session, must be before the new session +int cluster_listinvert_session(int sidnew, int sidtodel) +{ + int i, inew = 0; + + for (i = 0 ; i < config->cluster_num_changes ; ++i) + { + if ( cluster_changes[i].id == sidtodel && cluster_changes[i].type == C_CSESSION) + return 0; // Deleted session already before the new session. + + if ( cluster_changes[i].id == sidnew && cluster_changes[i].type == C_CSESSION) + { + inew = i; + break; + } + } + + for ( ; i < config->cluster_num_changes ; ++i) + { + if ( cluster_changes[i].id == sidtodel && cluster_changes[i].type == C_CSESSION) + { + // Reverse position + cluster_changes[i].id = sidnew; + cluster_changes[inew].id = sidtodel; + return 1; + } + } + + return 0; +} // A particular session has been changed! int cluster_send_session(int sid)