Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
tcp: a little optimization in tcp_server_done() and more debug msgs
  • Loading branch information
perexg committed Apr 24, 2015
1 parent 2b00b88 commit 536736d
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/tcp.c
Expand Up @@ -903,6 +903,7 @@ tcp_server_done(void)
{
tcp_server_launch_t *tsl;
char c = 'E';
int64_t t;

tcp_server_running = 0;
tvh_write(tcp_server_pipe.wr, &c, 1);
Expand All @@ -912,8 +913,7 @@ tcp_server_done(void)
if (tsl->ops.cancel)
tsl->ops.cancel(tsl->opaque);
if (tsl->fd >= 0)
close(tsl->fd);
tsl->fd = -1;
shutdown(tsl->fd, SHUT_RDWR);
pthread_kill(tsl->tid, SIGTERM);
}
pthread_mutex_unlock(&global_lock);
Expand All @@ -922,8 +922,13 @@ tcp_server_done(void)
tvh_pipe_close(&tcp_server_pipe);
tvhpoll_destroy(tcp_server_poll);

while (LIST_FIRST(&tcp_server_active) != NULL)
t = getmonoclock();
while (LIST_FIRST(&tcp_server_active) != NULL) {
if (getmonoclock() - t > 5000000)
tvhtrace("tcp", "tcp server %p active too long", LIST_FIRST(&tcp_server_active));
usleep(20000);
}

pthread_mutex_lock(&global_lock);
while ((tsl = LIST_FIRST(&tcp_server_join)) != NULL) {
LIST_REMOVE(tsl, jlink);
Expand Down

0 comments on commit 536736d

Please sign in to comment.