Mercurial > hg > waaad
changeset 107:c956cc2dbaed
Added cancelation cleanup handlers
author | Sebastien Decugis <sdecugis@nict.go.jp> |
---|---|
date | Mon, 28 Jul 2008 18:11:58 +0900 |
parents | e243c9a234cd |
children | 219c6d78480f |
files | extensions/sec_nosec/sns_recv_unprotect.c |
diffstat | 1 files changed, 6 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/extensions/sec_nosec/sns_recv_unprotect.c Mon Jul 28 13:59:54 2008 +0900 +++ b/extensions/sec_nosec/sns_recv_unprotect.c Mon Jul 28 18:11:58 2008 +0900 @@ -39,8 +39,9 @@ #include "sec_nosec.h" -/* We just receive the buffer "as is" on the connection object, and rebuild a message (boundaries are lost with TCP) */ - +/* We just receive the buffer "as is" on the connection object, and rebuild a message (boundaries are lost with TCP) + * Note that we may be cancelled in any of the recv call. + */ int sns_recv_unprotect (sec_session_t * session, void ** ext_session, void ** data, size_t *length) { unsigned char header[4]; @@ -92,7 +93,10 @@ memcpy(newmsg, header, sizeof(header)); while (received < *length) { + pthread_cleanup_push(free, newmsg); /* In case we are canceled, clean the partialy built buffer */ ret = (*session->recv_data) (session->conn, newmsg + received, (*length) - received); + pthread_cleanup_pop(0); + if (ret == 0) { /* Shutdown in progress */ TRACE_DEBUG(INFO, "The recv_data function returned 0");