Changeset 5343 for pjproject/trunk/pjlib/src/pj/ssl_sock_ossl.c
- Timestamp:
- Jun 14, 2016 10:28:19 AM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjlib/src/pj/ssl_sock_ossl.c
r5338 r5343 813 813 static void close_sockets(pj_ssl_sock_t *ssock) 814 814 { 815 if (ssock->asock) { 816 pj_activesock_close(ssock->asock); 817 ssock->asock = NULL; 818 ssock->sock = PJ_INVALID_SOCKET; 819 } 820 if (ssock->sock != PJ_INVALID_SOCKET) { 821 pj_sock_close(ssock->sock); 822 ssock->sock = PJ_INVALID_SOCKET; 823 } 815 pj_activesock_t *asock; 816 pj_sock_t sock; 817 818 /* This can happen when pj_ssl_sock_create() fails. */ 819 if (!ssock->write_mutex) 820 return; 821 822 pj_lock_acquire(ssock->write_mutex); 823 asock = ssock->asock; 824 if (asock) { 825 ssock->asock = NULL; 826 ssock->sock = PJ_INVALID_SOCKET; 827 } 828 sock = ssock->sock; 829 if (sock != PJ_INVALID_SOCKET) 830 ssock->sock = PJ_INVALID_SOCKET; 831 pj_lock_release(ssock->write_mutex); 832 833 if (asock) 834 pj_activesock_close(asock); 835 836 if (sock != PJ_INVALID_SOCKET) 837 pj_sock_close(sock); 824 838 } 825 839 … … 1946 1960 &ssock->timer, 1947 1961 &ssock->param.timeout); 1948 if (status != PJ_SUCCESS) 1962 if (status != PJ_SUCCESS) { 1949 1963 ssock->timer.id = TIMER_NONE; 1964 status = PJ_SUCCESS; 1965 } 1950 1966 } 1951 1967 … … 1953 1969 ssock->ssl_state = SSL_STATE_HANDSHAKING; 1954 1970 SSL_set_accept_state(ssock->ossl_ssl); 1955 status = do_handshake(ssock); 1971 //To avoid race condition, we don't need to do it here and 1972 //let the handshake happen in ssock->asock's callback instead. 1973 //status = do_handshake(ssock); 1956 1974 1957 1975 on_return: 1958 if (ssock && status != PJ_EPENDING) 1959 on_handshake_complete(ssock, status); 1976 if (ssock && status != PJ_SUCCESS) { 1977 //on_handshake_complete(ssock, status); 1978 close_sockets(ssock); 1979 } 1960 1980 1961 1981 /* Must return PJ_TRUE whatever happened, as active socket must … … 2864 2884 &ssock->timer, 2865 2885 &ssock->param.timeout); 2866 if (status != PJ_SUCCESS) 2886 if (status != PJ_SUCCESS) { 2867 2887 ssock->timer.id = TIMER_NONE; 2888 status = PJ_SUCCESS; 2889 } 2868 2890 } 2869 2891
Note: See TracChangeset
for help on using the changeset viewer.