<commit_before>package main

import (
	"net"
	"os/exec"
	"strconv"
	"time"
)

func generator() {
	generatorLock.Lock()
	defer generatorLock.Unlock()
	logger.Info("updating new list...")
	for _, tunnel := range tunnels {
		ipt.ClearChain("mangle", tunnel.ChainName)
	}
	var weightSum, i int
	for _, tunnel := range tunnels {
		if tunnel.status {
			weightSum += tunnel.Weight
		}
	}
	for _, tunnel := range tunnels {
		if tunnel.status {
			for j := 0; j < tunnel.Weight; j++ {
				logger.Debug("iptables -t mangle -A %s -m statistic --mode nth --every %s --packet %s -j MARK --set-xmark %s", tunnel.ChainName, strconv.Itoa(weightSum), strconv.Itoa(i), tunnel.Mark)
				ipt.Append("mangle", tunnel.ChainName, "-m", "statistic", "--mode", "nth", "--every", strconv.Itoa(weightSum), "--packet", strconv.Itoa(i), "-j", "MARK", "--set-xmark", tunnel.Mark)
				i++
			}
		}
	}<commit_msg>fix balance serial in different chain<commit_after>package main

import (
	"net"
	"os/exec"
	"strconv"
	"time"
)

func generator() {
	generatorLock.Lock()
	defer generatorLock.Unlock()
	logger.Info("updating new list...")
	for _, tunnel := range tunnels {
		ipt.ClearChain("mangle", tunnel.ChainName)
	}
	var weightSum, i int
	var chainSerials map[string]int
	var chainSerialsTotal map[string]int
	chainSerials = make(map[string]int)
	chainSerialsTotal = make(map[string]int)
	for _, tunnel := range tunnels {
		if tunnel.status {
			weightSum += tunnel.Weight
		}
	}
	for _, tunnel := range tunnels {
		if tunnel.status {
			for j := 0; j < tunnel.Weight; j++ {
				_, exists := chainSerialsTotal[tunnel.ChainName]
				if !exists {
					chainSerialsTotal[tunnel.ChainName] = 0
				}
				chainSerialsTotal[tunnel.ChainName]++
				i++
			}
		}
	}
	for _, tunnel := range tunnels {
		if tunnel.status {
			for j := 0; j < tunnel.Weight; j++ {
				_, exists := chainSerials[tunnel.ChainName]
				if !exists {
					chainSerials[tunnel.ChainName] = 0
				}
				logger.Debug("iptables -t mangle -A %s -m statistic --mode nth --every %s --packet %s -j MARK --set-xmark %s", tunnel.ChainName, strconv.Itoa(weightSum), strconv.Itoa(i), tunnel.Mark)
				ipt.Append("mangle", tunnel.ChainName, "-m", "statistic", "--mode", "nth", "--every", strconv.Itoa(chainSerialsTotal[tunnel.ChainName]), "--packet", strconv.Itoa(chainSerials[tunnel.ChainName]), "-j", "MARK", "--set-xmark", tunnel.Mark)
				chainSerials[tunnel.ChainName]++
				i++
			}
		}
	}
{'fraction_non_alphanumeric': 0.1670111616370401, 'fraction_numerical': 0.002066969822240595, 'mean_word_length': 3.5403377110694185, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3332633', 'n_tokens_mistral': 963, 'n_tokens_neox': 864, 'n_words': 204}