Changeset 5338 for pjproject/trunk/pjlib/src/pj/ssl_sock_ossl.c
- Timestamp:
- Jun 8, 2016 2:55:24 AM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjlib/src/pj/ssl_sock_ossl.c
r5285 r5338 38 38 #define THIS_FILE "ssl_sock_ossl.c" 39 39 40 /* Workaround for ticket #985 */ 41 #define DELAYED_CLOSE_TIMEOUT 200 40 /* Workaround for ticket #985 and #1930 */ 41 #ifndef PJ_SSL_SOCK_DELAYED_CLOSE_TIMEOUT 42 # define PJ_SSL_SOCK_DELAYED_CLOSE_TIMEOUT 500 43 #endif 42 44 43 45 /* … … 808 810 809 811 810 /* Reset SSL socket state */ 811 static void reset_ssl_sock_state(pj_ssl_sock_t *ssock) 812 { 813 ssock->ssl_state = SSL_STATE_NULL; 814 815 destroy_ssl(ssock); 816 812 /* Close sockets */ 813 static void close_sockets(pj_ssl_sock_t *ssock) 814 { 817 815 if (ssock->asock) { 818 816 pj_activesock_close(ssock->asock); … … 824 822 ssock->sock = PJ_INVALID_SOCKET; 825 823 } 824 } 825 826 827 /* Reset SSL socket state */ 828 static void reset_ssl_sock_state(pj_ssl_sock_t *ssock) 829 { 830 ssock->ssl_state = SSL_STATE_NULL; 831 832 destroy_ssl(ssock); 833 834 close_sockets(ssock); 826 835 827 836 /* Upon error, OpenSSL may leave any error description in the thread … … 1193 1202 errmsg)); 1194 1203 1195 /* Workaround for ticket #985 */ 1196 #if (defined(PJ_WIN32) && PJ_WIN32!=0) || (defined(PJ_WIN64) && PJ_WIN64!=0) 1204 /* Originally, this is a workaround for ticket #985. However, 1205 * a race condition may occur in multiple worker threads 1206 * environment when we are destroying SSL objects while other 1207 * threads are still accessing them. 1208 * Please see ticket #1930 for more info. 1209 */ 1210 #if 1 //(defined(PJ_WIN32) && PJ_WIN32!=0)||(defined(PJ_WIN64) && PJ_WIN64!=0) 1197 1211 if (ssock->param.timer_heap) { 1198 pj_time_val interval = {0, DELAYED_CLOSE_TIMEOUT}; 1199 1200 reset_ssl_sock_state(ssock); 1201 1212 pj_time_val interval = {0, PJ_SSL_SOCK_DELAYED_CLOSE_TIMEOUT}; 1213 1214 ssock->ssl_state = SSL_STATE_NULL; 1215 close_sockets(ssock); 1216 1217 if (ssock->timer.id != TIMER_NONE) { 1218 pj_timer_heap_cancel(ssock->param.timer_heap, 1219 &ssock->timer); 1220 } 1202 1221 ssock->timer.id = TIMER_CLOSE; 1203 1222 pj_time_val_normalize(&interval); … … 1205 1224 &ssock->timer, &interval) != 0) 1206 1225 { 1226 PJ_LOG(3,(ssock->pool->obj_name, "Failed to schedule " 1227 "a delayed close. Race condition may occur.")); 1207 1228 ssock->timer.id = TIMER_NONE; 1208 1229 pj_ssl_sock_close(ssock); 1209 1230 } 1210 } else1211 #e ndif /* PJ_WIN32 */1231 } 1232 #else 1212 1233 { 1213 1234 pj_ssl_sock_close(ssock); 1214 1235 } 1236 #endif 1237 1215 1238 return PJ_FALSE; 1216 1239 } … … 2216 2239 pj_ssl_sock_param_copy(pool, &ssock->param, param); 2217 2240 ssock->param.read_buffer_size = ((ssock->param.read_buffer_size+7)>>3)<<3; 2241 if (!ssock->param.timer_heap) { 2242 PJ_LOG(3,(ssock->pool->obj_name, "Warning: timer heap is not " 2243 "available. It is recommended to supply one to avoid " 2244 "a race condition if more than one worker threads " 2245 "are used.")); 2246 } 2218 2247 2219 2248 /* Finally */
Note: See TracChangeset
for help on using the changeset viewer.