changeset 1226:835fe2345db6

Update send logic per Nikos Mavrogiannopoulos comments
author Sebastien Decugis <sdecugis@freediameter.net>
date Thu, 20 Jun 2013 09:42:07 +0800
parents 1804ef0240cc
children 33b94b5b8289
files libfdcore/sctp_dtls.c
diffstat 1 files changed, 7 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/libfdcore/sctp_dtls.c	Thu Jun 20 09:38:52 2013 +0800
+++ b/libfdcore/sctp_dtls.c	Thu Jun 20 09:42:07 2013 +0800
@@ -671,7 +671,9 @@
 
 	TRACE_DEBUG(FULL, "Thread terminated");	
 	return NULL;
-}			
+}	
+
+		
 
 /* Send a new Diameter message over the association */
 int fd_sctp_dtls_send(struct cnxctx * conn, unsigned char * buf, size_t len)
@@ -696,7 +698,10 @@
 	
 	/* Now send the data over this stream. Do it in a loop in case the length is larger than the MTU */
 	do {
-		CHECK_GNUTLS_DO( ret = fd_tls_send_handle_error(conn, conn->cc_tls_para.session, buf + sent, len - sent),  );
+		size_t tosend = len - sent;
+		if (tosend > DTLS_SCTP_MTU)
+			tosend = DTLS_SCTP_MTU;
+		CHECK_GNUTLS_DO( ret = fd_tls_send_handle_error(conn, conn->cc_tls_para.session, buf + sent, tosend),  );
 		if (ret <= 0)
 			return ENOTCONN;
 		
"Welcome to our mercurial repository"