Tcl Library Source Code

View Ticket
Login
Ticket UUID: d9be31a488f644839811f7addf0da80f047f1a27
Title: smtp::initialize fails with "<-- 421 4.3.2 Service not available"
Type: Bug Version: 1.18
Submitter: boegge Created on: 2018-04-23 09:23:56
Subsystem: smtp Assigned To: aku
Priority: 9 Immediate Severity: Important
Status: Closed Last Modified: 2018-06-19 04:15:12
Resolution: Fixed Closed By: aku
    Closed on: 2018-06-19 04:15:12
Description:
smtp::initialize does not work correctly when using a server list and a port list in combination.

In my opinion smtp::initialize should iterate over the server-list while using the port with the same index as server in list. (See code in line 626 in smtp.tcl)

626 - set index 0 
627 -  foreach server $options(-servers) { ....

If connection init on the first port of ports fails, a connection with next server in list is tried to be opened but the index is not increased, so that connection establishment is only tried with the first port in list. 

BUGFIX: Insert "incr index" before each continue in "iterate" loop or use two iterates combined. 

foreach server  $options(-servers) { 
  foreach port $options(-ports) { ... } 
}
User Comments: aku added on 2018-06-19 04:15:12:

Merged with commit [f8b74f465b].


aku added on 2018-06-19 03:56:26:
no response for a month. assuming that the change is ok.
merge asap.

aku added on 2018-05-18 04:34:05:

Committed a tentative fix to branch [smtp-init-tkt-d9be31a488].

This is commit [9c0c77acf0].

Please get this branch or commit and check if that fixes the problem you have with the command.


aku added on 2018-05-17 19:53:41:

Comments in the code:

https://core.tcl.tk/tcllib/artifact/a4ca98d41fd10afe?ln=592-595

indicate that ports should be matched to servers, i.e. indeed be iterated together.

The increment at https://core.tcl.tk/tcllib/artifact/a4ca98d41fd10afe?ln=677 looks indeed to be much too late, what with the two `continue`s at https://core.tcl.tk/tcllib/artifact/a4ca98d41fd10afe?ln=652 and https://core.tcl.tk/tcllib/artifact/a4ca98d41fd10afe?ln=669

Moving the increment just after https://core.tcl.tk/tcllib/artifact/a4ca98d41fd10afe?ln=633 should work

The proposed nested iteration will not match servers and ports as documented. It would try each port with each server, i.e do a cartesian product of both, like a SQL join.

However

foreach server $options(-servers) $port $options(-ports) { ... }

might do what we want, if it fills missing elements with the empty string when on of the lists is too short.

That would avoid all the index calculations entirely.