Correctly close tun lease descriptors prior to running worker.

That is, properly initialize them to -1, to avoid deinitializing
an unrelated descriptor.
This commit is contained in:
Nikos Mavrogiannopoulos
2014-04-13 14:04:55 +02:00
parent 70f82e72d3
commit be3920a08c
+3
View File
@@ -558,6 +558,8 @@ void clear_lists(main_server_st *s)
list_for_each_safe(&s->proc_list.head, ctmp, cpos, list) {
if (ctmp->fd >= 0)
close(ctmp->fd);
if (ctmp->tun_lease.fd >= 0)
close(ctmp->tun_lease.fd);
if (ctmp->auth_ctx != NULL)
proc_auth_deinit(s, ctmp);
list_del(&ctmp->list);
@@ -1036,6 +1038,7 @@ fork_failed:
memcpy(&ctmp->sid, &ws.sid, sizeof(ws.sid));
ctmp->pid = pid;
ctmp->tun_lease.fd = -1;
ctmp->conn_time = time(0);
ctmp->fd = cmd_fd[0];
set_cloexec_flag (cmd_fd[0], 1);