fix cleanup of tcp-connect connection state

Repairs another regression due to the rktio conversion, where a
connection that takes a while can be mismanaged, especially if
multiple connection attempts run concurrently.
This commit is contained in:
Matthew Flatt 2017-11-17 13:01:45 -07:00
parent ff5f5ff2af
commit 29606b1e5e

View File

@ -766,6 +766,10 @@ static void connect_cleanup(Connect_Progress_Data *pd)
rktio_addrinfo_lookup_stop(scheme_rktio, pd->lookup);
pd->lookup = NULL;
}
if (pd->trying_s) {
(void)scheme_rktio_fd_to_semaphore(pd->trying_s, MZFD_REMOVE);
pd->trying_s = NULL;
}
if (pd->connect) {
rktio_connect_stop(scheme_rktio, pd->connect);
pd->connect = NULL;
@ -778,10 +782,6 @@ static void connect_cleanup(Connect_Progress_Data *pd)
rktio_addrinfo_free(scheme_rktio, pd->src_addr);
pd->src_addr = NULL;
}
if (pd->trying_s) {
(void)scheme_rktio_fd_to_semaphore(pd->trying_s, MZFD_REMOVE);
pd->trying_s = NULL;
}
if (pd->s) {
(void)scheme_rktio_fd_to_semaphore(pd->s, MZFD_REMOVE);
rktio_close(scheme_rktio, pd->s);
@ -1014,8 +1014,10 @@ static Scheme_Object *tcp_connect(int argc, Scheme_Object *argv[])
END_ESCAPEABLE();
}
if (pd->trying_s)
if (pd->trying_s) {
(void)scheme_rktio_fd_to_semaphore(pd->trying_s, MZFD_REMOVE);
pd->trying_s = NULL;
}
s = rktio_connect_finish(scheme_rktio, connect);