defensive programming in case connections get tidied while there is activity on both file descriptors (fix #355)

This commit is contained in:
Yves Rűtschlé 2022-11-09 17:48:14 +01:00
parent 02573eb44b
commit 555717e345

View File

@ -83,6 +83,11 @@ void tcp_read_process(struct loop_info* fd_info,
{
cnx_collection* collection = fd_info->collection;
struct connection* cnx = collection_get_cnx_from_fd(collection, fd);
/* connection can get tidied if there is an error on the other file
* descriptor -- then cnx is NULL */
if (!cnx) return;
/* Determine active queue (0 or 1): if fd is that of q[1], active_q = 1,
* otherwise it's 0 */
int active_q = active_queue(cnx, fd);
@ -306,6 +311,11 @@ void probing_read_process(struct connection* cnx,
void cnx_write_process(struct loop_info* fd_info, int fd)
{
struct connection* cnx = collection_get_cnx_from_fd(fd_info->collection, fd);
/* connection can get tidied if there is an error on the other file
* descriptor -- then cnx is NULL */
if (!cnx) return;
int res;
int queue = active_queue(cnx, fd);