1# ==== Purpose ==== 2# 3# Execute a .inc file once for master-slave connection that was 4# configured by rpl_init.inc. For each connection, it sets the 5# following variables: 6# 7# $rpl_master, $rpl_slave 8# The server number of the master and of the slave. 9# 10# $rpl_channel_name 11# If $rpl_multi_source is set, the name of the channel by which 12# the slave connects to the master. Otherwise the empty string. 13# 14# $rpl_connection_number 15# 1 for the first connection, 2 for the second connection, etc. 16# 17# Moreover, the current connection will be set to server_$rpl_slave. 18# 19# ==== Usage ==== 20# 21# --let $rpl_source_file= FILE 22# [--let $rpl_multi_source= 1] 23# [--let $rpl_debug= 1] 24# --source include/rpl_for_each_connection.inc 25# 26# Parameters: 27# $rpl_source_file 28# The file that will be sourced. 29# 30# $rpl_multi_source 31# If this is set, $rpl_channel_name is set. 32# 33# $rpl_debug 34# See include/rpl_init.inc 35 36 37--let $include_filename= rpl_for_each_connection.inc [$rpl_source_file] 38--source include/begin_include_file.inc 39 40--let $rpl_connection_number= 1 41while ($rpl_connection_number <= $rpl_connection_count) 42{ 43 # 'mX sY mZ sW ...' 44 # ^ _rfec_offset points here in the second iteration 45 --let $_rfec_offset= 1 + ($rpl_connection_number - 1) * 2 * (2 + $rpl_server_count_length) 46 --let $rpl_master= `SELECT SUBSTRING('$rpl_connection_list', $_rfec_offset + 1, $rpl_server_count_length)` 47 --let $rpl_slave= `SELECT SUBSTRING('$rpl_connection_list', $_rfec_offset + 1 + $rpl_server_count_length + 2, $rpl_server_count_length)` 48 49 --let $rpl_channel_name= 50 if ($rpl_multi_source) 51 { 52 --let $rpl_channel_name= channel_$rpl_master 53 } 54 55 if ($rpl_debug) 56 { 57 --echo # debug: rpl_for_each_connection.inc: connection=$rpl_connection master=$rpl_master slave=$rpl_slave 58 } 59 60 --let $rpl_connection_name= server_$rpl_slave 61 --source include/rpl_connection.inc 62 --source $rpl_source_file 63 64 --inc $rpl_connection_number 65} 66 67--let $rpl_master= 68--let $rpl_slave= 69--let $rpl_connection_number= 70--let $rpl_channel_name= 71 72--let $include_filename= rpl_for_each_connection.inc [$rpl_source_file] 73--source include/end_include_file.inc 74