Changeset 5751 for pjproject/trunk/pjlib/src/pj/ssl_sock_ossl.c
- Timestamp:
- Mar 6, 2018 8:44:18 AM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjlib/src/pj/ssl_sock_ossl.c
r5726 r5751 264 264 pj_bool_t flushing_write_pend; /* flag of flushing is ongoing*/ 265 265 send_buf_t send_buf; 266 write_data_t send_buf_pending; /* send buffer is full but some 267 * data is queuing in wbio. */ 266 268 write_data_t send_pending; /* list of pending write to network */ 267 269 pj_lock_t *write_mutex; /* protect write BIO and send_buf */ … … 1890 1892 wdata = alloc_send_data(ssock, needed_len); 1891 1893 if (wdata == NULL) { 1894 /* Oops, write BIO is ready but the send buffer is full, let's just 1895 * queue it for sending and return PJ_EPENDING. 1896 */ 1897 ssock->send_buf_pending.data_len = needed_len; 1898 ssock->send_buf_pending.app_key = send_key; 1899 ssock->send_buf_pending.flags = flags; 1900 ssock->send_buf_pending.plain_data_len = orig_len; 1892 1901 pj_lock_release(ssock->write_mutex); 1893 return PJ_E NOMEM;1902 return PJ_EPENDING; 1894 1903 } 1895 1904 … … 2193 2202 pj_ssl_sock_t *ssock = (pj_ssl_sock_t*) 2194 2203 pj_activesock_get_user_data(asock); 2195 2196 PJ_UNUSED_ARG(send_key); 2197 PJ_UNUSED_ARG(sent); 2204 write_data_t *wdata = (write_data_t*)send_key->user_data; 2205 pj_ioqueue_op_key_t *app_key = wdata->app_key; 2206 pj_ssize_t sent_len; 2207 2208 sent_len = (sent > 0)? wdata->plain_data_len : sent; 2209 2210 /* Update write buffer state */ 2211 pj_lock_acquire(ssock->write_mutex); 2212 free_send_data(ssock, wdata); 2213 pj_lock_release(ssock->write_mutex); 2214 wdata = NULL; 2198 2215 2199 2216 if (ssock->ssl_state == SSL_STATE_HANDSHAKING) { … … 2208 2225 } else if (send_key != &ssock->handshake_op_key) { 2209 2226 /* Some data has been sent, notify application */ 2210 write_data_t *wdata = (write_data_t*)send_key->user_data;2211 2227 if (ssock->param.cb.on_data_sent) { 2212 2228 pj_bool_t ret; 2213 pj_ssize_t sent_len; 2214 2215 sent_len = (sent > 0)? wdata->plain_data_len : sent; 2216 ret = (*ssock->param.cb.on_data_sent)(ssock, wdata->app_key, 2229 ret = (*ssock->param.cb.on_data_sent)(ssock, app_key, 2217 2230 sent_len); 2218 2231 if (!ret) { … … 2221 2234 } 2222 2235 } 2223 2224 /* Update write buffer state */2225 pj_lock_acquire(ssock->write_mutex);2226 free_send_data(ssock, wdata);2227 pj_lock_release(ssock->write_mutex);2228 2229 2236 } else { 2230 2237 /* SSL re-negotiation is on-progress, just do nothing */ 2238 } 2239 2240 /* Send buffer has been updated, let's try to send any pending data */ 2241 if (ssock->send_buf_pending.data_len) { 2242 pj_status_t status; 2243 status = flush_write_bio(ssock, ssock->send_buf_pending.app_key, 2244 ssock->send_buf_pending.plain_data_len, 2245 ssock->send_buf_pending.flags); 2246 if (status == PJ_SUCCESS || status == PJ_EPENDING) { 2247 ssock->send_buf_pending.data_len = 0; 2248 } 2231 2249 } 2232 2250 … … 2998 3016 */ 2999 3017 pj_lock_acquire(ssock->write_mutex); 3018 /* Don't write to SSL if send buffer is full and some data is in 3019 * write BIO already, just return PJ_ENOMEM. 3020 */ 3021 if (ssock->send_buf_pending.data_len) { 3022 pj_lock_release(ssock->write_mutex); 3023 return PJ_ENOMEM; 3024 } 3000 3025 nwritten = SSL_write(ssock->ossl_ssl, data, (int)size); 3001 3026 pj_lock_release(ssock->write_mutex);
Note: See TracChangeset
for help on using the changeset viewer.