From bd4a686ede3ec35f024c76eec5b07d7f2334ffcd Mon Sep 17 00:00:00 2001 From: Martin Peach Date: Tue, 18 Feb 2014 20:09:23 +0000 Subject: More crash prevention in 64-bit svn path=/trunk/externals/mrpeach/; revision=17267 --- net/tcpclient.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/net/tcpclient.c b/net/tcpclient.c index 98d6bec..f32f910 100644 --- a/net/tcpclient.c +++ b/net/tcpclient.c @@ -70,7 +70,7 @@ static char objName[] = "tcpclient"; typedef struct _tcpclient_sender_params { char x_sendbuf[MAX_TCPCLIENT_SEND_BUF]; /* possibly allocate this dynamically for space over speed */ - int x_buf_len; + size_t x_buf_len; int x_sendresult; pthread_t sendthreadid; int threadisvalid; /* non-zero if sendthreadid is an active thread */ @@ -383,8 +383,11 @@ static void *tcpclient_child_send(void *w) { t_tcpclient_sender_params *tsp = (t_tcpclient_sender_params*) w; - tsp->x_sendresult = send(tsp->x_x->x_fd, tsp->x_sendbuf, tsp->x_buf_len, 0); - clock_delay(tsp->x_x->x_sendclock, 0); // calls tcpclient_sent when it's safe to do so + if (tsp->x_x->x_fd >= 0) + { + tsp->x_sendresult = send(tsp->x_x->x_fd, tsp->x_sendbuf, tsp->x_buf_len, 0); + clock_delay(tsp->x_x->x_sendclock, 0); // calls tcpclient_sent when it's safe to do so + } tsp->threadisvalid = 0; /* this thread is over */ return(tsp); } -- cgit v1.2.1