Changeset 807:09f8f0c4f4a4 in freeDiameter for libfdcore/sctps.c
- Timestamp:
- Aug 24, 2012, 7:15:48 AM (12 years ago)
- Branch:
- default
- Phase:
- public
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
libfdcore/sctps.c
r803 r807 105 105 106 106 case FDEVP_CNX_ERROR: 107 fd_cnx_markerror(conn);108 107 goto out; 109 108 … … 121 120 /* Signal termination of the connection to all decipher threads */ 122 121 for (strid = 0; strid < conn->cc_sctp_para.pairs; strid++) { 123 if (conn->cc_sctps_data.array[strid].raw_recv) 122 if (conn->cc_sctps_data.array[strid].raw_recv) { 124 123 CHECK_FCT_DO(fd_event_send(conn->cc_sctps_data.array[strid].raw_recv, FDEVP_CNX_ERROR, 0, NULL), goto fatal ); 125 } 124 } 125 } 126 fd_cnx_markerror(conn); 126 127 TRACE_DEBUG(FULL, "Thread terminated"); 127 128 return NULL; … … 171 172 CHECK_PARAMS_DO( tr && data, { errno = EINVAL; return -1; } ); 172 173 173 CHECK_FCT_DO( fd_sctp_sendstr(ctx->parent, ctx->strid, (uint8_t *)data, len), /* errno is already set */return -1 );174 CHECK_FCT_DO( fd_sctp_sendstr(ctx->parent, ctx->strid, (uint8_t *)data, len), return -1 ); 174 175 175 176 return len; … … 184 185 185 186 TRACE_ENTRY("%p %p %zd", tr, buf, len); 186 CHECK_PARAMS_DO( tr && buf, { errno = EINVAL; return -1; } );187 CHECK_PARAMS_DO( tr && buf, { errno = EINVAL; goto error; } ); 187 188 188 189 /* If we don't have data available now, pull new message from the fifo -- this is blocking (until the queue is destroyed) */ 189 190 if (!ctx->partial.buf) { 190 191 int ev; 191 CHECK_FCT_DO( errno = fd_event_get(ctx->raw_recv, &ev, &ctx->partial.bufsz, (void *)&ctx->partial.buf), return -1 ); 192 if (ev == FDEVP_CNX_ERROR) 193 return 0; /* connection closed */ 192 CHECK_FCT_DO( errno = fd_event_get(ctx->raw_recv, &ev, &ctx->partial.bufsz, (void *)&ctx->partial.buf), goto error ); 193 if (ev == FDEVP_CNX_ERROR) { 194 /* Documentations says to return 0 on connection closed, but it does hang within gnutls_handshake */ 195 return -1; 196 } 194 197 } 195 198 … … 216 219 /* We are done */ 217 220 return pulled; 221 222 error: 223 gnutls_transport_set_errno (ctx->session, errno); 224 return -1; 218 225 } 219 226 … … 463 470 464 471 TRACE_DEBUG(FULL, "Starting TLS resumed handshake on stream %hu", ctx->strid); 465 #ifdef GNUTLS_VERSION_310 466 GNUTLS_TRACE( gnutls_handshake_set_timeout( ctx->session, GNUTLS_DEFAULT_HANDSHAKE_TIMEOUT)); 467 #endif /* GNUTLS_VERSION_310 */ 472 468 473 CHECK_GNUTLS_DO( gnutls_handshake( ctx->session ), return NULL); 469 474 470 475 GNUTLS_TRACE( resumed = gnutls_session_is_resumed(ctx->session) ); 476 #ifndef GNUTLS_VERSION_300 471 477 if (!resumed) { 472 478 /* Check the credentials here also */ 473 479 CHECK_FCT_DO( fd_tls_verify_credentials(ctx->session, ctx->parent, 0), return NULL ); 474 480 } 481 #endif /* GNUTLS_VERSION_300 */ 475 482 if (TRACE_BOOL(FULL)) { 476 483 if (resumed) { 477 484 fd_log_debug("Session was resumed successfully on stream %hu (conn: '%s')\n", ctx->strid, fd_cnx_getid(ctx->parent)); 478 485 } else { 479 fd_log_debug("Session was NOT resumed on stream %hu (full handshake + verif) (conn: '%s')\n", ctx->strid, fd_cnx_getid(ctx->parent));486 fd_log_debug("Session was NOT resumed on stream %hu (full handshake) (conn: '%s')\n", ctx->strid, fd_cnx_getid(ctx->parent)); 480 487 } 481 488 } … … 555 562 CHECK_FCT( fd_tls_prepare(&conn->cc_sctps_data.array[i].session, conn->cc_tls_para.mode, priority, alt_creds) ); 556 563 564 /* additional initialization for gnutls 3.x */ 565 #ifdef GNUTLS_VERSION_300 566 /* the verify function has already been set in the global initialization in config.c */ 567 568 /* fd_tls_verify_credentials_2 uses the connection */ 569 gnutls_session_set_ptr (conn->cc_sctps_data.array[i].session, (void *) conn); 570 571 if ((conn->cc_tls_para.cn != NULL) && (conn->cc_tls_para.mode == GNUTLS_CLIENT)) { 572 /* this might allow virtual hosting on the remote peer */ 573 CHECK_GNUTLS_DO( gnutls_server_name_set (conn->cc_sctps_data.array[i].session, GNUTLS_NAME_DNS, conn->cc_tls_para.cn, strlen(conn->cc_tls_para.cn)), /* ignore failure */); 574 } 575 576 #endif /* GNUTLS_VERSION_300 */ 577 578 #ifdef GNUTLS_VERSION_310 579 GNUTLS_TRACE( gnutls_handshake_set_timeout( conn->cc_sctps_data.array[i].session, GNUTLS_DEFAULT_HANDSHAKE_TIMEOUT)); 580 #endif /* GNUTLS_VERSION_310 */ 581 557 582 /* For the client, copy data from master session; for the server, set session resuming pointers */ 558 583 if (conn->cc_tls_para.mode == GNUTLS_CLIENT) {
Note: See TracChangeset
for help on using the changeset viewer.