Changeset 1838
- Timestamp:
- 08/15/08 00:27:24 (3 months ago)
- Files:
-
- cherokee/trunk/ChangeLog (modified) (1 diff)
- cherokee/trunk/cherokee/connection.c (modified) (1 diff)
- cherokee/trunk/cherokee/socket.c (modified) (7 diffs)
- cherokee/trunk/cherokee/socket.h (modified) (1 diff)
- cherokee/trunk/cherokee/thread.c (modified) (5 diffs)
- cherokee/trunk/cherokee/thread.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
cherokee/trunk/ChangeLog
r1837 r1838 1 1 2008-08-14 Alvaro Lopez Ortega <alvaro@alobbs.com> 2 3 * cherokee/socket.c, cherokee/socket.h, cherokee/thread.c, 4 cherokee/thread.h, cherokee/connection.c: Fixes the TLS/SSL 5 support. It adds support for a new concept within the server: a 6 cherokee_buffer_t can have pending information to be read, so in 7 addition to the file descriptor this property must be checked 8 whenever it real status need to be known. 2 9 3 10 * qa/run-tests.py, qa/base.py: Fixes two minor issues. cherokee/trunk/cherokee/connection.c
r1814 r1838 717 717 case ret_eof: 718 718 case ret_error: 719 return ret; 720 719 721 case ret_eagain: 720 return ret; 722 if (cherokee_socket_pending_read (&conn->socket)) { 723 CONN_THREAD(conn)->pending_read_num += 1; 724 } 725 return ret_eagain; 721 726 722 727 default: cherokee/trunk/cherokee/socket.c
r1790 r1838 1141 1141 1142 1142 if (likely (len > 0)) { 1143 *pcnt_read = len; 1143 *pcnt_read = len; 1144 if (gnutls_record_check_pending (socket->session) > 0) 1145 return ret_eagain; 1144 1146 return ret_ok; 1145 1147 } … … 1171 1173 #elif defined (HAVE_OPENSSL) 1172 1174 len = SSL_read (socket->session, buf, buf_size); 1173 1174 1175 if (likely (len > 0)) { 1175 1176 *pcnt_read = len; 1177 if (SSL_pending (socket->session)) 1178 return ret_eagain; 1176 1179 return ret_ok; 1177 1180 } … … 1184 1187 { /* len < 0 */ 1185 1188 int re; 1189 int error = errno; 1186 1190 1187 1191 re = SSL_get_error (socket->session, len); … … 1195 1199 case SSL_ERROR_SSL: 1196 1200 return ret_error; 1201 case SSL_ERROR_SYSCALL: 1202 switch (error) { 1203 case EPIPE: 1204 case ECONNRESET: 1205 socket->status = socket_closed; 1206 return ret_eof; 1207 default: 1208 PRINT_ERRNO (error, "SSL_read: unknown errno: ${errno}\n"); 1209 } 1210 return ret_error; 1197 1211 } 1198 1212 … … 1207 1221 #endif /* HAVE_TLS */ 1208 1222 1223 } 1224 1225 1226 int 1227 cherokee_socket_pending_read (cherokee_socket_t *socket) 1228 { 1229 if (socket->is_tls != TLS) 1230 return 0; 1231 1232 if (unlikely ((socket->status != socket_reading) && 1233 (socket->status != socket_writing))) 1234 return 0; 1235 1236 #ifdef HAVE_TLS 1237 # ifdef HAVE_GNUTLS 1238 return (gnutls_record_check_pending (socket->session) > 0); 1239 # elif defined (HAVE_OPENSSL) 1240 return (SSL_pending (socket->session) > 0); 1241 # endif 1242 #endif 1209 1243 } 1210 1244 … … 1375 1409 */ 1376 1410 ret_t 1377 cherokee_socket_bufread (cherokee_socket_t *socket, cherokee_buffer_t *buf, size_t count, size_t *pcnt_read) 1411 cherokee_socket_bufread (cherokee_socket_t *socket, 1412 cherokee_buffer_t *buf, 1413 size_t count, 1414 size_t *pcnt_read) 1378 1415 { 1379 1416 ret_t ret; … … 1387 1424 1388 1425 starting = buf->buf + buf->len; 1389 1426 1390 1427 ret = cherokee_socket_read (socket, starting, count, pcnt_read); 1391 if ( ret == ret_ok) {1428 if (*pcnt_read > 0) { 1392 1429 buf->len += *pcnt_read; 1393 1430 buf->buf[buf->len] = '\0'; cherokee/trunk/cherokee/socket.h
r1790 r1838 191 191 ret_t cherokee_socket_shutdown (cherokee_socket_t *socket, int how); 192 192 ret_t cherokee_socket_accept (cherokee_socket_t *socket, int server_socket); 193 int cherokee_socket_pending_read (cherokee_socket_t *socket); 193 194 194 195 ret_t cherokee_socket_set_client (cherokee_socket_t *socket, unsigned short int type); cherokee/trunk/cherokee/thread.c
r1814 r1838 155 155 n->polling_list_num = 0; 156 156 n->reuse_list_num = 0; 157 157 158 n->pending_conns_num = 0; 159 n->pending_read_num = 0; 158 160 159 161 n->fastcgi_servers = NULL; … … 581 583 */ 582 584 if ((conn->traffic_next < thd->bogo_now) && 583 ( conn->rx != 0) &&584 (conn->tx != 0)){585 ((conn->rx != 0) || (conn->tx != 0))) 586 { 585 587 cherokee_connection_update_vhost_traffic (conn); 586 588 } … … 603 605 continue; 604 606 case 0: 605 continue; 607 if (! cherokee_socket_pending_read (&conn->socket)) 608 continue; 606 609 } 607 610 } … … 1509 1512 } 1510 1513 1514 if (thd->pending_read_num > 0) { 1515 fdwatch_msecs = 0; 1516 thd->pending_read_num = 0; 1517 } 1518 1511 1519 re = cherokee_fdpoll_watch (thd->fdpoll, fdwatch_msecs); 1512 1520 if (re <= 0) … … 1852 1860 fdwatch_msecs = 0; 1853 1861 thd->pending_conns_num = 0; 1862 } 1863 1864 if (thd->pending_read_num > 0) { 1865 fdwatch_msecs = 0; 1866 thd->pending_read_num = 0; 1854 1867 } 1855 1868 cherokee/trunk/cherokee/thread.h
r1763 r1838 86 86 87 87 int pending_conns_num; /* Waiting pipelining connections */ 88 88 int pending_read_num; /* Conns with SSL deping read */ 89 89 90 struct { 90 91 uint32_t continuous;