Skip to content
Snippets Groups Projects
Commit 2fe7c5c1 authored by Ivica Bukvic's avatar Ivica Bukvic
Browse files

fixed segfault with netsend/receive using tcp packets where netreceive is...

fixed segfault with netsend/receive using tcp packets where netreceive is deleted while netreceive is connected to it (after which sending data to netreceive would result in a segfault)
parent 875e220c
No related branches found
No related tags found
No related merge requests found
...@@ -188,6 +188,7 @@ typedef struct _netreceive ...@@ -188,6 +188,7 @@ typedef struct _netreceive
t_object x_obj; t_object x_obj;
t_outlet *x_msgout; t_outlet *x_msgout;
t_outlet *x_connectout; t_outlet *x_connectout;
int x_acceptsocket;
int x_connectsocket; int x_connectsocket;
int x_nconnections; int x_nconnections;
int x_udp; int x_udp;
...@@ -244,6 +245,7 @@ static void netreceive_connectpoll(t_netreceive *x) ...@@ -244,6 +245,7 @@ static void netreceive_connectpoll(t_netreceive *x)
(t_socketnotifier)netreceive_notify, (t_socketnotifier)netreceive_notify,
(x->x_msgout ? netreceive_doit : 0), 0); (x->x_msgout ? netreceive_doit : 0), 0);
sys_addpollfn(fd, (t_fdpollfn)socketreceiver_read, y); sys_addpollfn(fd, (t_fdpollfn)socketreceiver_read, y);
x->x_acceptsocket = fd;
outlet_float(x->x_connectout, ++x->x_nconnections); outlet_float(x->x_connectout, ++x->x_nconnections);
} }
} }
...@@ -308,6 +310,8 @@ static void *netreceive_new(t_symbol *compatflag, ...@@ -308,6 +310,8 @@ static void *netreceive_new(t_symbol *compatflag,
} }
else x->x_msgout = outlet_new(&x->x_obj, &s_anything); else x->x_msgout = outlet_new(&x->x_obj, &s_anything);
x->x_acceptsocket = -1;
if (udp) /* datagram protocol */ if (udp) /* datagram protocol */
{ {
t_socketreceiver *y = socketreceiver_new((void *)x, t_socketreceiver *y = socketreceiver_new((void *)x,
...@@ -343,6 +347,8 @@ static void netreceive_free(t_netreceive *x) ...@@ -343,6 +347,8 @@ static void netreceive_free(t_netreceive *x)
if (x->x_connectsocket >= 0) if (x->x_connectsocket >= 0)
{ {
sys_rmpollfn(x->x_connectsocket); sys_rmpollfn(x->x_connectsocket);
if (x->x_acceptsocket >= 0)
sys_rmpollfn(x->x_acceptsocket);
sys_closesocket(x->x_connectsocket); sys_closesocket(x->x_connectsocket);
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment