Navigation


Changeset 729:5d8ac5da7092 in freeDiameter


Ignore:
Timestamp:
Feb 24, 2011, 5:19:14 PM (13 years ago)
Author:
Sebastien Decugis <sdecugis@nict.go.jp>
Branch:
default
Phase:
public
Message:

Fixed timeout handling + minor fixes

Location:
tests
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • tests/testcnx.c

    r688 r729  
    466466                                "-----END RSA PRIVATE KEY-----\n";
    467467
    468 
    469 struct fd_list eps = FD_LIST_INITIALIZER(eps);
    470 
     468/* Diffie-Hellman parameters, generated with GNUTLS certtool:
     469certtool --generate-dh-params
     470                                Generator: 06
     471
     472                                Prime: ea:c3:75:0b:32:cf:d9:17:98:5c:da:d1
     473                                        e0:1d:b9:7c:be:29:60:b0:6f:68:a9:f6
     474                                        8d:75:05:59:69:04:ae:39:7c:2b:74:04
     475                                        3c:e2:da:28:8a:9b:93:aa:67:05:a7:3e
     476                                        06:3e:0d:31:63:88:55:ad:5a:bd:41:22
     477                                        b7:58:a7:45:b3:d5:03:ad:de:3c:8d:69
     478                                        42:bf:84:3d:c1:90:e7:39:6a:4b:87:01
     479                                        19:e5:f3:a4:e5:8e:e2:45:d5:0c:6b:17
     480                                        22:2b:2e:50:83:91:0c:5b:82:fc:72:27
     481                                        49:3b:9f:29:11:53:c7:90:b8:8d:87:73
     482                                        1a:7b:05:ab:cb:30:59:16:71:30:60:1b
     483                                        4c:80:15:3a:a2:d3:47:b7:4a:61:de:64
     484                                        7e:79:de:88:53:b7:7a:c6:a2:9a:bb:55
     485                                        40:2d:7a:71:c7:41:b5:29:df:d7:5c:fb
     486                                        42:e4:d8:5e:0b:99:d3:3c:93:0f:33:51
     487                                        8b:f4:60:e4:c5:b5:58:21:c0:51:c4:43
     488                                        25:7c:37:fe:5c:d3:62:6c:2a:af:a7:2a
     489                                        82:d5:d3:e2:bb:5d:ad:84:15:f6:78:d9
     490                                        d5:a8:f7:f0:48:5c:8d:e0:3d:04:ac:cf
     491                                        aa:34:3f:5d:f2:0d:3d:ee:ec:b8:d8:e8
     492                                        ad:dc:d3:40:59:a0:fd:45:62:47:63:c0
     493                                        bd:f5:df:8b
     494*/
     495static char dh_params_data[] =  "-----BEGIN DH PARAMETERS-----\n"
     496                                "MIIBCAKCAQEA6sN1CzLP2ReYXNrR4B25fL4pYLBvaKn2jXUFWWkErjl8K3QEPOLa\n"
     497                                "KIqbk6pnBac+Bj4NMWOIVa1avUEit1inRbPVA63ePI1pQr+EPcGQ5zlqS4cBGeXz\n"
     498                                "pOWO4kXVDGsXIisuUIORDFuC/HInSTufKRFTx5C4jYdzGnsFq8swWRZxMGAbTIAV\n"
     499                                "OqLTR7dKYd5kfnneiFO3esaimrtVQC16ccdBtSnf11z7QuTYXguZ0zyTDzNRi/Rg\n"
     500                                "5MW1WCHAUcRDJXw3/lzTYmwqr6cqgtXT4rtdrYQV9njZ1aj38EhcjeA9BKzPqjQ/\n"
     501                                "XfINPe7suNjordzTQFmg/UViR2PAvfXfiwIBBg==\n"
     502                                "-----END DH PARAMETERS-----\n";
     503
     504
     505/* List server endpoints */
     506static struct fd_list eps = FD_LIST_INITIALIZER(eps);
     507
     508/* Pass parameters to the connect thread */
    471509struct connect_flags {
    472510        int     proto;
     
    474512};
    475513
    476 void * connect_thr(void * arg)
     514/* Client's side of the connection established from a separate thread */
     515static void * connect_thr(void * arg)
    477516{
    478517        struct connect_flags * cf = arg;
     
    506545}
    507546
     547/* Parameters to the handshake thread */
    508548struct handshake_flags {
    509549        struct cnxctx * cnx;
     
    512552};
    513553
    514 void * handshake_thr(void * arg)
     554/* Handshake the client's side */
     555static void * handshake_thr(void * arg)
    515556{
    516557        struct handshake_flags * hf = arg;
     
    519560        return NULL;
    520561}
    521        
    522 void * destroy_thr(void * arg)
     562
     563/* Terminate the client's connection side */
     564static void * destroy_thr(void * arg)
    523565{
    524566        struct cnxctx * cnx = arg;
     
    541583        gnutls_datum_t notrust_cert     = { (uint8_t *)notrust_cert_data,       sizeof(notrust_cert_data) };
    542584        gnutls_datum_t notrust_priv     = { (uint8_t *)notrust_priv_data,       sizeof(notrust_priv_data) };
    543        
     585        gnutls_datum_t dh_params        = { (uint8_t *)dh_params_data,          sizeof(dh_params_data)    };
     586       
     587        /* Listening socket, server side */
    544588        struct cnxctx * listener;
    545589#ifndef DISABLE_SCTP
    546590        struct cnxctx * listener_sctp;
    547591#endif /* DISABLE_SCTP */
     592       
     593        /* Server & client connected sockets */
    548594        struct cnxctx * server_side;
    549595        struct cnxctx * client_side;
     596       
    550597        pthread_t thr;
    551598        int ret, i;
     
    579626       
    580627        /* Set default DH params */
    581         CHECK_GNUTLS_DO( ret = gnutls_dh_params_generate2( fd_g_config->cnf_sec_data.dh_cache, GNUTLS_DEFAULT_DHBITS), );
     628        CHECK_GNUTLS_DO( ret = gnutls_dh_params_import_pkcs3( fd_g_config->cnf_sec_data.dh_cache, &dh_params, GNUTLS_X509_FMT_PEM), );
    582629        CHECK( GNUTLS_E_SUCCESS, ret );
    583630       
    584         /* Initialize the server addresses */
     631       
     632        /* Initialize the server address (this should give a safe loopback address + port, even on non-standard configs) */
    585633        {
    586634                struct addrinfo hints, *ai, *aip;
     
    595643                };
    596644                freeaddrinfo(ai);
     645               
     646                CHECK( 0, FD_IS_LIST_EMPTY(&eps) ? 1 : 0 );
    597647        }
    598648       
     
    647697                fd_msg_dump_walk(0, cer);
    648698                #endif
    649                        
     699               
    650700                CHECK( 0, fd_msg_bufferize( cer, &cer_buf, &cer_sz ) );
    651701                CHECK( 0, fd_msg_free(cer) );
     
    660710               
    661711                /* Start the client thread */
    662                 CHECK( 0, pthread_create(&thr, 0, connect_thr, &cf) );
     712                CHECK( 0, pthread_create(&thr, NULL, connect_thr, &cf) );
    663713
    664714                /* Accept the connection of the client */
     
    686736                free(rcv_buf);
    687737               
    688                 /* Now close the connection */
     738                /* Now close the connections */
    689739                fd_cnx_destroy(client_side);
    690740                fd_cnx_destroy(server_side);
     
    700750               
    701751                /* Start the client thread */
    702                 CHECK( 0, pthread_create(&thr, 0, connect_thr, &cf) );
     752                CHECK( 0, pthread_create(&thr, NULL, connect_thr, &cf) );
    703753
    704754                /* Accept the connection of the client */
     
    762812               
    763813                /* Start the client thread */
    764                 CHECK( 0, pthread_create(&thr, 0, connect_thr, &cf) );
     814                CHECK( 0, pthread_create(&thr, NULL, connect_thr, &cf) );
    765815
    766816                /* Accept the connection of the client */
     
    793843               
    794844                /* At this point in legacy Diameter we start the handshake */
    795                 CHECK( 0, pthread_create(&thr, 0, handshake_thr, &hf) );
     845                CHECK( 0, pthread_create(&thr, NULL, handshake_thr, &hf) );
    796846                CHECK( 0, fd_cnx_handshake(server_side, GNUTLS_SERVER, NULL, NULL) );
    797847                CHECK( 0, pthread_join(thr, NULL) );
     
    815865               
    816866                /* Now close the connection */
    817                 CHECK( 0, pthread_create(&thr, 0, destroy_thr, client_side) );
     867                CHECK( 0, pthread_create(&thr, NULL, destroy_thr, client_side) );
    818868                fd_cnx_destroy(server_side);
    819869                CHECK( 0, pthread_join(thr, NULL) );
     
    847897               
    848898                /* Start the client thread */
    849                 CHECK( 0, pthread_create(&thr, 0, connect_thr, &cf) );
     899                CHECK( 0, pthread_create(&thr, NULL, connect_thr, &cf) );
    850900
    851901                /* Accept the connection of the client */
     
    878928               
    879929                /* At this point in legacy Diameter we start the handshake */
    880                 CHECK( 0, pthread_create(&thr, 0, handshake_thr, &hf) );
     930                CHECK( 0, pthread_create(&thr, NULL, handshake_thr, &hf) );
    881931                CHECK( 0, fd_cnx_handshake(server_side, GNUTLS_SERVER, NULL, NULL) );
    882932                CHECK( 0, pthread_join(thr, NULL) );
     
    900950               
    901951                /* Now close the connection */
    902                 CHECK( 0, pthread_create(&thr, 0, destroy_thr, client_side) );
     952                CHECK( 0, pthread_create(&thr, NULL, destroy_thr, client_side) );
    903953                fd_cnx_destroy(server_side);
    904954                CHECK( 0, pthread_join(thr, NULL) );
     
    932982               
    933983                /* Start the client thread */
    934                 CHECK( 0, pthread_create(&thr, 0, connect_thr, &cf) );
     984                CHECK( 0, pthread_create(&thr, NULL, connect_thr, &cf) );
    935985
    936986                /* Accept the connection of the client */
     
    944994               
    945995                /* Start the handshake directly */
    946                 CHECK( 0, pthread_create(&thr, 0, handshake_thr, &hf) );
     996                CHECK( 0, pthread_create(&thr, NULL, handshake_thr, &hf) );
    947997                CHECK( 0, fd_cnx_handshake(server_side, GNUTLS_SERVER, NULL, NULL) );
    948998                CHECK( 0, pthread_join(thr, NULL) );
     
    9651015               
    9661016                /* Now close the connection */
    967                 CHECK( 0, pthread_create(&thr, 0, destroy_thr, client_side) );
     1017                CHECK( 0, pthread_create(&thr, NULL, destroy_thr, client_side) );
    9681018                fd_cnx_destroy(server_side);
    9691019                CHECK( 0, pthread_join(thr, NULL) );
     
    9971047               
    9981048                /* Start the client thread */
    999                 CHECK( 0, pthread_create(&thr, 0, connect_thr, &cf) );
     1049                CHECK( 0, pthread_create(&thr, NULL, connect_thr, &cf) );
    10001050
    10011051                /* Accept the connection of the client */
     
    10091059               
    10101060                /* Start the handshake directly */
    1011                 CHECK( 0, pthread_create(&thr, 0, handshake_thr, &hf) );
     1061                CHECK( 0, pthread_create(&thr, NULL, handshake_thr, &hf) );
     1062                CHECK( 0, fd_cnx_handshake(server_side, GNUTLS_SERVER, NULL, NULL) );
     1063                CHECK( 0, pthread_join(thr, NULL) );
     1064                CHECK( 0, hf.ret );
     1065               
     1066                /* Send a few TLS protected messages, and replies */
     1067                for (i = 0; i < 2 * NB_STREAMS; i++) {
     1068                        CHECK( 0, fd_cnx_send(server_side, cer_buf, cer_sz, 0));
     1069                        CHECK( 0, fd_cnx_receive(client_side, NULL, &rcv_buf, &rcv_sz));
     1070                        CHECK( cer_sz, rcv_sz );
     1071                        CHECK( 0, memcmp( rcv_buf, cer_buf, cer_sz ) );
     1072                        free(rcv_buf);
     1073
     1074                        CHECK( 0, fd_cnx_send(client_side, cer_buf, cer_sz, 0));
     1075                        CHECK( 0, fd_cnx_receive(server_side, NULL, &rcv_buf, &rcv_sz));
     1076                        CHECK( cer_sz, rcv_sz );
     1077                        CHECK( 0, memcmp( rcv_buf, cer_buf, cer_sz ) );
     1078                        free(rcv_buf);
     1079                }
     1080               
     1081               
     1082                /* Now close the connection */
     1083                CHECK( 0, pthread_create(&thr, NULL, destroy_thr, client_side) );
     1084                fd_cnx_destroy(server_side);
     1085                CHECK( 0, pthread_join(thr, NULL) );
     1086               
     1087                /* Free the credentials */
     1088                gnutls_certificate_free_keys(hf.creds);
     1089                gnutls_certificate_free_cas(hf.creds);
     1090                gnutls_certificate_free_credentials(hf.creds);
     1091        }
     1092#endif /* DISABLE_SCTP */
     1093       
     1094        /* Test with different number of streams between server and client */
     1095#ifndef DISABLE_SCTP
     1096        {
     1097                struct connect_flags cf;
     1098                struct handshake_flags hf;
     1099               
     1100                memset(&cf, 0, sizeof(cf));
     1101                cf.proto = IPPROTO_SCTP;
     1102               
     1103                memset(&hf, 0, sizeof(hf));
     1104               
     1105                /* Initialize remote certificate */
     1106                CHECK_GNUTLS_DO( ret = gnutls_certificate_allocate_credentials (&hf.creds), );
     1107                CHECK( GNUTLS_E_SUCCESS, ret );
     1108                /* Set the CA */
     1109                CHECK_GNUTLS_DO( ret = gnutls_certificate_set_x509_trust_mem( hf.creds, &ca, GNUTLS_X509_FMT_PEM), );
     1110                CHECK( 1, ret );
     1111                /* Set the key */
     1112                CHECK_GNUTLS_DO( ret = gnutls_certificate_set_x509_key_mem( hf.creds, &client_cert, &client_priv, GNUTLS_X509_FMT_PEM), );
     1113                CHECK( GNUTLS_E_SUCCESS, ret );
     1114               
     1115                /* Start the client thread with more streams than the server */
     1116                fd_g_config->cnf_sctp_str = 2 * NB_STREAMS;
     1117                CHECK( 0, pthread_create(&thr, NULL, connect_thr, &cf) );
     1118
     1119                /* Accept the connection of the client */
     1120                server_side = fd_cnx_serv_accept(listener_sctp);
     1121                CHECK( 1, server_side ? 1 : 0 );
     1122               
     1123                /* Retrieve the client connection object */
     1124                CHECK( 0, pthread_join( thr, (void *)&client_side ) );
     1125                CHECK( 1, client_side ? 1 : 0 );
     1126                hf.cnx = client_side;
     1127               
     1128                /* Start the handshake directly */
     1129                CHECK( 0, pthread_create(&thr, NULL, handshake_thr, &hf) );
     1130                CHECK( 0, fd_cnx_handshake(server_side, GNUTLS_SERVER, NULL, NULL) );
     1131                CHECK( 0, pthread_join(thr, NULL) );
     1132                CHECK( 0, hf.ret );
     1133               
     1134                /* Send a few TLS protected message, and replies */
     1135                for (i = 0; i < 4 * NB_STREAMS; i++) {
     1136                        CHECK( 0, fd_cnx_send(server_side, cer_buf, cer_sz, 0));
     1137                        CHECK( 0, fd_cnx_receive(client_side, NULL, &rcv_buf, &rcv_sz));
     1138                        CHECK( cer_sz, rcv_sz );
     1139                        CHECK( 0, memcmp( rcv_buf, cer_buf, cer_sz ) );
     1140                        free(rcv_buf);
     1141
     1142                        CHECK( 0, fd_cnx_send(client_side, cer_buf, cer_sz, 0));
     1143                        CHECK( 0, fd_cnx_receive(server_side, NULL, &rcv_buf, &rcv_sz));
     1144                        CHECK( cer_sz, rcv_sz );
     1145                        CHECK( 0, memcmp( rcv_buf, cer_buf, cer_sz ) );
     1146                        free(rcv_buf);
     1147                }
     1148               
     1149                /* Now close the connection */
     1150                CHECK( 0, pthread_create(&thr, NULL, destroy_thr, client_side) );
     1151                fd_cnx_destroy(server_side);
     1152                CHECK( 0, pthread_join(thr, NULL) );
     1153               
     1154                /* Do the same test but with more streams on the server this time */
     1155                fd_g_config->cnf_sctp_str = NB_STREAMS / 2;
     1156                CHECK( 0, pthread_create(&thr, NULL, connect_thr, &cf) );
     1157
     1158                /* Accept the connection of the client */
     1159                server_side = fd_cnx_serv_accept(listener_sctp);
     1160                CHECK( 1, server_side ? 1 : 0 );
     1161               
     1162                /* Retrieve the client connection object */
     1163                CHECK( 0, pthread_join( thr, (void *)&client_side ) );
     1164                CHECK( 1, client_side ? 1 : 0 );
     1165                hf.cnx = client_side;
     1166               
     1167                /* Start the handshake directly */
     1168                CHECK( 0, pthread_create(&thr, NULL, handshake_thr, &hf) );
    10121169                CHECK( 0, fd_cnx_handshake(server_side, GNUTLS_SERVER, NULL, NULL) );
    10131170                CHECK( 0, pthread_join(thr, NULL) );
     
    10291186                }
    10301187               
    1031                
    10321188                /* Now close the connection */
    1033                 CHECK( 0, pthread_create(&thr, 0, destroy_thr, client_side) );
    1034                 fd_cnx_destroy(server_side);
    1035                 CHECK( 0, pthread_join(thr, NULL) );
    1036                
    1037                 /* Free the credentials */
    1038                 gnutls_certificate_free_keys(hf.creds);
    1039                 gnutls_certificate_free_cas(hf.creds);
    1040                 gnutls_certificate_free_credentials(hf.creds);
    1041         }
    1042 #endif /* DISABLE_SCTP */
    1043        
    1044         /* Test with different number of streams between server and client */
    1045 #ifndef DISABLE_SCTP
    1046         {
    1047                 struct connect_flags cf;
    1048                 struct handshake_flags hf;
    1049                
    1050                 memset(&cf, 0, sizeof(cf));
    1051                 cf.proto = IPPROTO_SCTP;
    1052                
    1053                 memset(&hf, 0, sizeof(hf));
    1054                
    1055                 /* Initialize remote certificate */
    1056                 CHECK_GNUTLS_DO( ret = gnutls_certificate_allocate_credentials (&hf.creds), );
    1057                 CHECK( GNUTLS_E_SUCCESS, ret );
    1058                 /* Set the CA */
    1059                 CHECK_GNUTLS_DO( ret = gnutls_certificate_set_x509_trust_mem( hf.creds, &ca, GNUTLS_X509_FMT_PEM), );
    1060                 CHECK( 1, ret );
    1061                 /* Set the key */
    1062                 CHECK_GNUTLS_DO( ret = gnutls_certificate_set_x509_key_mem( hf.creds, &client_cert, &client_priv, GNUTLS_X509_FMT_PEM), );
    1063                 CHECK( GNUTLS_E_SUCCESS, ret );
    1064                
    1065                 /* Start the client thread with more streams than the server */
    1066                 fd_g_config->cnf_sctp_str = 2 * NB_STREAMS;
    1067                 CHECK( 0, pthread_create(&thr, 0, connect_thr, &cf) );
    1068 
    1069                 /* Accept the connection of the client */
    1070                 server_side = fd_cnx_serv_accept(listener_sctp);
    1071                 CHECK( 1, server_side ? 1 : 0 );
    1072                
    1073                 /* Retrieve the client connection object */
    1074                 CHECK( 0, pthread_join( thr, (void *)&client_side ) );
    1075                 CHECK( 1, client_side ? 1 : 0 );
    1076                 hf.cnx = client_side;
    1077                
    1078                 /* Start the handshake directly */
    1079                 CHECK( 0, pthread_create(&thr, 0, handshake_thr, &hf) );
    1080                 CHECK( 0, fd_cnx_handshake(server_side, GNUTLS_SERVER, NULL, NULL) );
    1081                 CHECK( 0, pthread_join(thr, NULL) );
    1082                 CHECK( 0, hf.ret );
    1083                
    1084                 /* Send a few TLS protected message, and replies */
    1085                 for (i = 0; i < 4 * NB_STREAMS; i++) {
    1086                         CHECK( 0, fd_cnx_send(server_side, cer_buf, cer_sz, 0));
    1087                         CHECK( 0, fd_cnx_receive(client_side, NULL, &rcv_buf, &rcv_sz));
    1088                         CHECK( cer_sz, rcv_sz );
    1089                         CHECK( 0, memcmp( rcv_buf, cer_buf, cer_sz ) );
    1090                         free(rcv_buf);
    1091 
    1092                         CHECK( 0, fd_cnx_send(client_side, cer_buf, cer_sz, 0));
    1093                         CHECK( 0, fd_cnx_receive(server_side, NULL, &rcv_buf, &rcv_sz));
    1094                         CHECK( cer_sz, rcv_sz );
    1095                         CHECK( 0, memcmp( rcv_buf, cer_buf, cer_sz ) );
    1096                         free(rcv_buf);
    1097                 }
    1098                
    1099                 /* Now close the connection */
    1100                 CHECK( 0, pthread_create(&thr, 0, destroy_thr, client_side) );
    1101                 fd_cnx_destroy(server_side);
    1102                 CHECK( 0, pthread_join(thr, NULL) );
    1103                
    1104                 /* Do the same test but with more streams on the server this time */
    1105                 fd_g_config->cnf_sctp_str = NB_STREAMS / 2;
    1106                 CHECK( 0, pthread_create(&thr, 0, connect_thr, &cf) );
    1107 
    1108                 /* Accept the connection of the client */
    1109                 server_side = fd_cnx_serv_accept(listener_sctp);
    1110                 CHECK( 1, server_side ? 1 : 0 );
    1111                
    1112                 /* Retrieve the client connection object */
    1113                 CHECK( 0, pthread_join( thr, (void *)&client_side ) );
    1114                 CHECK( 1, client_side ? 1 : 0 );
    1115                 hf.cnx = client_side;
    1116                
    1117                 /* Start the handshake directly */
    1118                 CHECK( 0, pthread_create(&thr, 0, handshake_thr, &hf) );
    1119                 CHECK( 0, fd_cnx_handshake(server_side, GNUTLS_SERVER, NULL, NULL) );
    1120                 CHECK( 0, pthread_join(thr, NULL) );
    1121                 CHECK( 0, hf.ret );
    1122                
    1123                 /* Send a few TLS protected message, and replies */
    1124                 for (i = 0; i < 2 * NB_STREAMS; i++) {
    1125                         CHECK( 0, fd_cnx_send(server_side, cer_buf, cer_sz, 0));
    1126                         CHECK( 0, fd_cnx_receive(client_side, NULL, &rcv_buf, &rcv_sz));
    1127                         CHECK( cer_sz, rcv_sz );
    1128                         CHECK( 0, memcmp( rcv_buf, cer_buf, cer_sz ) );
    1129                         free(rcv_buf);
    1130 
    1131                         CHECK( 0, fd_cnx_send(client_side, cer_buf, cer_sz, 0));
    1132                         CHECK( 0, fd_cnx_receive(server_side, NULL, &rcv_buf, &rcv_sz));
    1133                         CHECK( cer_sz, rcv_sz );
    1134                         CHECK( 0, memcmp( rcv_buf, cer_buf, cer_sz ) );
    1135                         free(rcv_buf);
    1136                 }
    1137                
    1138                 /* Now close the connection */
    1139                 CHECK( 0, pthread_create(&thr, 0, destroy_thr, client_side) );
     1189                CHECK( 0, pthread_create(&thr, NULL, destroy_thr, client_side) );
    11401190                fd_cnx_destroy(server_side);
    11411191                CHECK( 0, pthread_join(thr, NULL) );
     
    11741224               
    11751225                /* Start the client thread */
    1176                 CHECK( 0, pthread_create(&thr, 0, connect_thr, &cf) );
     1226                CHECK( 0, pthread_create(&thr, NULL, connect_thr, &cf) );
    11771227
    11781228                /* Accept the connection of the client */
     
    11861236               
    11871237                /* Start the handshake directly */
    1188                 CHECK( 0, pthread_create(&thr, 0, handshake_thr, &hf) );
     1238                CHECK( 0, pthread_create(&thr, NULL, handshake_thr, &hf) );
    11891239                CHECK( EINVAL, fd_cnx_handshake(server_side, GNUTLS_SERVER, NULL, NULL) );
    11901240                CHECK( 0, pthread_join(thr, NULL) );
    11911241               
    11921242                /* Now close the connection */
    1193                 CHECK( 0, pthread_create(&thr, 0, destroy_thr, client_side) );
     1243                CHECK( 0, pthread_create(&thr, NULL, destroy_thr, client_side) );
    11941244                fd_cnx_destroy(server_side);
    11951245                CHECK( 0, pthread_join(thr, NULL) );
     
    12241274               
    12251275                /* Start the client thread */
    1226                 CHECK( 0, pthread_create(&thr, 0, connect_thr, &cf) );
     1276                CHECK( 0, pthread_create(&thr, NULL, connect_thr, &cf) );
    12271277
    12281278                /* Accept the connection of the client */
     
    12361286               
    12371287                /* Start the handshake directly */
    1238                 CHECK( 0, pthread_create(&thr, 0, handshake_thr, &hf) );
     1288                CHECK( 0, pthread_create(&thr, NULL, handshake_thr, &hf) );
    12391289                CHECK( EINVAL, fd_cnx_handshake(server_side, GNUTLS_SERVER, NULL, NULL) );
    12401290                CHECK( 0, pthread_join(thr, NULL) );
    12411291               
    12421292                /* Now close the connection */
    1243                 CHECK( 0, pthread_create(&thr, 0, destroy_thr, client_side) );
     1293                CHECK( 0, pthread_create(&thr, NULL, destroy_thr, client_side) );
    12441294                fd_cnx_destroy(server_side);
    12451295                CHECK( 0, pthread_join(thr, NULL) );
     
    12731323               
    12741324                /* Start the client thread */
    1275                 CHECK( 0, pthread_create(&thr, 0, connect_thr, &cf) );
     1325                CHECK( 0, pthread_create(&thr, NULL, connect_thr, &cf) );
    12761326
    12771327                /* Accept the connection of the client */
     
    12851335               
    12861336                /* Start the handshake directly */
    1287                 CHECK( 0, pthread_create(&thr, 0, handshake_thr, &hf) );
     1337                CHECK( 0, pthread_create(&thr, NULL, handshake_thr, &hf) );
    12881338                CHECK( EINVAL, fd_cnx_handshake(server_side, GNUTLS_SERVER, NULL, NULL) );
    12891339                CHECK( 0, pthread_join(thr, NULL) );
    12901340               
    12911341                /* Now close the connection */
    1292                 CHECK( 0, pthread_create(&thr, 0, destroy_thr, client_side) );
     1342                CHECK( 0, pthread_create(&thr, NULL, destroy_thr, client_side) );
    12931343                fd_cnx_destroy(server_side);
    12941344                CHECK( 0, pthread_join(thr, NULL) );
     
    13221372               
    13231373                /* Start the client thread */
    1324                 CHECK( 0, pthread_create(&thr, 0, connect_thr, &cf) );
     1374                CHECK( 0, pthread_create(&thr, NULL, connect_thr, &cf) );
    13251375
    13261376                /* Accept the connection of the client */
     
    13371387               
    13381388                /* Start the handshake, check it is successful */
    1339                 CHECK( 0, pthread_create(&thr, 0, handshake_thr, &hf) );
     1389                CHECK( 0, pthread_create(&thr, NULL, handshake_thr, &hf) );
    13401390                CHECK( 0, fd_cnx_handshake(server_side, GNUTLS_SERVER, NULL, NULL) );
    13411391                CHECK( 0, pthread_join(thr, NULL) );
     
    13431393               
    13441394                /* Now close the connection */
    1345                 CHECK( 0, pthread_create(&thr, 0, destroy_thr, client_side) );
     1395                CHECK( 0, pthread_create(&thr, NULL, destroy_thr, client_side) );
    13461396                fd_cnx_destroy(server_side);
    13471397                CHECK( 0, pthread_join(thr, NULL) );
    13481398               
    13491399                /* Do it again with an invalid hostname */
    1350                 CHECK( 0, pthread_create(&thr, 0, connect_thr, &cf) );
     1400                CHECK( 0, pthread_create(&thr, NULL, connect_thr, &cf) );
    13511401
    13521402                /* Accept the connection of the client */
     
    13631413               
    13641414                /* Start the handshake, check it is successful */
    1365                 CHECK( 0, pthread_create(&thr, 0, handshake_thr, &hf) );
     1415                CHECK( 0, pthread_create(&thr, NULL, handshake_thr, &hf) );
    13661416                CHECK( EINVAL, fd_cnx_handshake(server_side, GNUTLS_SERVER, NULL, NULL) );
    13671417                CHECK( 0, pthread_join(thr, NULL) );
    13681418               
    13691419                /* Now close the connection */
    1370                 CHECK( 0, pthread_create(&thr, 0, destroy_thr, client_side) );
     1420                CHECK( 0, pthread_create(&thr, NULL, destroy_thr, client_side) );
    13711421                fd_cnx_destroy(server_side);
    13721422                CHECK( 0, pthread_join(thr, NULL) );
     
    14051455               
    14061456                /* Start the client thread */
    1407                 CHECK( 0, pthread_create(&thr, 0, connect_thr, &cf) );
     1457                CHECK( 0, pthread_create(&thr, NULL, connect_thr, &cf) );
    14081458
    14091459                /* Accept the connection of the client */
     
    14171467               
    14181468                /* Start the handshake */
    1419                 CHECK( 0, pthread_create(&thr, 0, handshake_thr, &hf) );
     1469                CHECK( 0, pthread_create(&thr, NULL, handshake_thr, &hf) );
    14201470                CHECK( 0, fd_cnx_handshake(server_side, GNUTLS_SERVER, NULL, NULL) );
    14211471                CHECK( 0, pthread_join(thr, NULL) );
     
    14591509               
    14601510                /* Now close the connection */
    1461                 CHECK( 0, pthread_create(&thr, 0, destroy_thr, client_side) );
     1511                CHECK( 0, pthread_create(&thr, NULL, destroy_thr, client_side) );
    14621512                fd_cnx_destroy(server_side);
    14631513                CHECK( 0, pthread_join(thr, NULL) );
     
    14971547               
    14981548                /* Start the client thread */
    1499                 CHECK( 0, pthread_create(&thr, 0, connect_thr, &cf) );
     1549                CHECK( 0, pthread_create(&thr, NULL, connect_thr, &cf) );
    15001550
    15011551                /* Accept the connection of the client */
     
    15091559               
    15101560                /* Start the handshake */
    1511                 CHECK( 0, pthread_create(&thr, 0, handshake_thr, &hf) );
     1561                CHECK( 0, pthread_create(&thr, NULL, handshake_thr, &hf) );
    15121562                CHECK( 0, fd_cnx_handshake(server_side, GNUTLS_SERVER, NULL, NULL) );
    15131563                CHECK( 0, pthread_join(thr, NULL) );
     
    15501600               
    15511601                /* Now close the connection */
    1552                 CHECK( 0, pthread_create(&thr, 0, destroy_thr, client_side) );
     1602                CHECK( 0, pthread_create(&thr, NULL, destroy_thr, client_side) );
    15531603                fd_cnx_destroy(server_side);
    15541604                CHECK( 0, pthread_join(thr, NULL) );
     
    15811631               
    15821632                /* Start the client thread, that should fail */
    1583                 CHECK( 0, pthread_create(&thr, 0, connect_thr, &cf) );
     1633                CHECK( 0, pthread_create(&thr, NULL, connect_thr, &cf) );
    15841634                CHECK( 0, pthread_join( thr, (void *)&client_side ) );
    15851635                CHECK( 0, client_side ? 1 : 0 );
     
    15951645               
    15961646                /* Start the client thread, that should fail */
    1597                 CHECK( 0, pthread_create(&thr, 0, connect_thr, &cf) );
     1647                CHECK( 0, pthread_create(&thr, NULL, connect_thr, &cf) );
    15981648                CHECK( 0, pthread_join( thr, (void *)&client_side ) );
    15991649                CHECK( 0, client_side ? 1 : 0 );
  • tests/tests.h

    r695 r729  
    7777        (void)fd_core_shutdown();                       \
    7878        (void)fd_core_wait_shutdown_complete();         \
    79         (void)fd_thr_term(&timeout_thr);                \
     79        (void)fd_thr_term(&signal_thr);                 \
    8080        exit(PASS);                                     \
    8181}
     
    105105}
    106106
    107 static pthread_t timeout_thr;
    108 static void * timeout_catch(void * arg)
     107static pthread_t signal_thr;
     108static void * signal_catch(void * arg)
    109109{
    110110        int sig;
    111111        sigset_t ss;
    112         fd_log_threadname ( "Test alarm catcher" );
     112        fd_log_threadname ( "Signal catcher" );
    113113       
    114114        sigemptyset(&ss);
     115       
     116        /* We use SIGALRM */
    115117        sigaddset(&ss, SIGALRM);
    116118       
     119        /* Unblock any other signal for this thread, so that default handler is enabled */
     120        CHECK_SYS_DO( pthread_sigmask( SIG_SETMASK, &ss, NULL ), );
     121       
     122        /* Now wait for sigwait or cancelation */
    117123        CHECK_POSIX_DO( sigwait(&ss, &sig),  );
    118        
    119124        FAILTEST("The timeout (" _stringize(TEST_TIMEOUT) " sec) was reached. Use -n or change TEST_TIMEOUT if the test needs more time to execute.");
    120125       
     
    165170        if (!no_timeout) {
    166171                alarm(TEST_TIMEOUT);
    167                 CHECK( 0, pthread_create(&timeout_thr, NULL, timeout_catch, NULL) );
    168172        }
     173        CHECK( 0, pthread_create(&signal_thr, NULL, signal_catch, NULL) );
    169174}
    170175 
    171176static inline void test_init(int argc, char * argv[], char *fname)
    172177{
     178        sigset_t sig_all;
     179        sigfillset(&sig_all);
     180       
     181        CHECK( 0, pthread_sigmask(SIG_BLOCK, &sig_all, NULL));
     182       
    173183        memset(fd_g_config, 0, sizeof(struct fd_config));
    174184       
     
    176186       
    177187        fd_log_threadname(basename(fname));
     188       
     189        /* Parse the command line */
     190        parse_cmdline(argc, argv);
    178191       
    179192        /* Initialize gcrypt and gnutls */
     
    194207        CHECK( 0, fd_sess_start()  );
    195208       
    196         /* Parse the command line */
    197         parse_cmdline(argc, argv);
    198        
    199209        return;
    200210}
  • tests/testsctp.c

    r706 r729  
    7878                };
    7979                freeaddrinfo(ai);
     80               
     81                CHECK( 0, FD_IS_LIST_EMPTY(&eps) ? 1 : 0 );
    8082        }
    8183       
Note: See TracChangeset for help on using the changeset viewer.