diff --git a/src/main.c b/src/main.c index cfdaf6af..ab314176 100644 --- a/src/main.c +++ b/src/main.c @@ -665,7 +665,7 @@ struct sockaddr_storage cli_addr; struct sockaddr_storage our_addr; struct proc_st *proc_to_send = NULL; socklen_t cli_addr_size, our_addr_size; -uint8_t buffer[1024]; +uint8_t buffer[1536]; char tbuf[64]; uint8_t *session_id = NULL; int session_id_size = 0; @@ -780,10 +780,10 @@ int sfd = -1; if (match_ip_only != 0) { msg.hello = 0; } else { - msg.data.data = buffer; - msg.data.len = buffer_size; msg.has_data = 1; } + msg.data.data = buffer; + msg.data.len = buffer_size; ret = send_socket_msg_to_worker(s, proc_to_send, CMD_UDP_FD, sfd, diff --git a/src/worker-misc.c b/src/worker-misc.c index ce98cd31..fcd5c173 100644 --- a/src/worker-misc.c +++ b/src/worker-misc.c @@ -56,7 +56,8 @@ int handle_worker_commands(struct worker_st *ws) uint16_t length; int e; struct msghdr hdr; - uint8_t cmd_data[1024]; + uint8_t cmd_data[1536]; + UdpFdMsg *tmsg = NULL; union { struct cmsghdr cm; char control[CMSG_SPACE(sizeof(int))]; @@ -108,7 +109,6 @@ int handle_worker_commands(struct worker_st *ws) case CMD_TERMINATE: exit(0); case CMD_UDP_FD: { - UdpFdMsg *tmsg; unsigned hello = 1; int fd; @@ -119,12 +119,6 @@ int handle_worker_commands(struct worker_st *ws) tmsg = udp_fd_msg__unpack(NULL, length, cmd_data); if (tmsg) { hello = tmsg->hello; - if (hello) { - ws->dtls_tptr.msg = tmsg; - } else { - udp_fd_msg__free_unpacked(tmsg, NULL); - tmsg = NULL; - } } if ( (cmptr = CMSG_FIRSTHDR(&hdr)) != NULL && cmptr->cmsg_len == CMSG_LEN(sizeof(int))) { @@ -140,6 +134,7 @@ int handle_worker_commands(struct worker_st *ws) if ((ws->udp_state != UP_ACTIVE && ws->udp_state != UP_INACTIVE) || time(0) - ws->last_msg_udp < ACTIVE_SESSION_TIMEOUT) { oclog(ws, LOG_INFO, "received UDP fd message but our session is active!"); + udp_fd_msg__free_unpacked(tmsg, NULL); close(fd); return 0; } @@ -153,6 +148,8 @@ int handle_worker_commands(struct worker_st *ws) if (ws->udp_fd != -1) { close(ws->udp_fd); } + + ws->dtls_tptr.msg = tmsg; ws->udp_fd = fd; set_non_block(fd); @@ -173,6 +170,7 @@ int handle_worker_commands(struct worker_st *ws) return 0; udp_fd_fail: + udp_fd_msg__free_unpacked(tmsg, NULL); if (ws->udp_fd == -1) ws->udp_state = UP_DISABLED;