Mercurial > hg > nginx-quic
comparison src/event/ngx_event_openssl.c @ 1013:7dd987e09701
stop rbtree search early if equal hash was found
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Thu, 11 Jan 2007 17:05:18 +0000 |
parents | 1b9a4d92173f |
children | 5ffd76a9ccf3 |
comparison
equal
deleted
inserted
replaced
1012:11ffb8e4753f | 1013:7dd987e09701 |
---|---|
1411 if (hash > node->key) { | 1411 if (hash > node->key) { |
1412 node = node->right; | 1412 node = node->right; |
1413 continue; | 1413 continue; |
1414 } | 1414 } |
1415 | 1415 |
1416 if (hash == node->key && (u_char) len == node->data) { | 1416 /* hash == node->key */ |
1417 sess_id = (ngx_ssl_sess_id_t *) node; | 1417 |
1418 | 1418 do { |
1419 if (ngx_strncmp(id, sess_id->id, len) == 0) { | 1419 if ((u_char) len == node->data) { |
1420 | 1420 sess_id = (ngx_ssl_sess_id_t *) node; |
1421 cached_sess = sess_id->session; | 1421 |
1422 | 1422 if (ngx_strncmp(id, sess_id->id, len) == 0) { |
1423 tp = ngx_timeofday(); | 1423 |
1424 | 1424 cached_sess = sess_id->session; |
1425 if (cached_sess->expire > tp->sec) { | 1425 |
1426 ngx_memcpy(buf, &cached_sess->asn1[0], sess_id->len); | 1426 tp = ngx_timeofday(); |
1427 | 1427 |
1428 ngx_shmtx_unlock(&shpool->mutex); | 1428 if (cached_sess->expire > tp->sec) { |
1429 | 1429 ngx_memcpy(buf, &cached_sess->asn1[0], sess_id->len); |
1430 p = buf; | 1430 |
1431 sess = d2i_SSL_SESSION(NULL, &p, sess_id->len); | 1431 ngx_shmtx_unlock(&shpool->mutex); |
1432 | 1432 |
1433 return sess; | 1433 p = buf; |
1434 sess = d2i_SSL_SESSION(NULL, &p, sess_id->len); | |
1435 | |
1436 return sess; | |
1437 } | |
1438 | |
1439 cached_sess->next->prev = cached_sess->prev; | |
1440 cached_sess->prev->next = cached_sess->next; | |
1441 | |
1442 ngx_rbtree_delete(cache->session_rbtree, node); | |
1443 | |
1444 ngx_slab_free_locked(shpool, cached_sess); | |
1445 ngx_slab_free_locked(shpool, sess_id->id); | |
1446 ngx_slab_free_locked(shpool, sess_id); | |
1447 | |
1448 sess = NULL; | |
1449 | |
1450 goto done; | |
1434 } | 1451 } |
1435 | |
1436 cached_sess->next->prev = cached_sess->prev; | |
1437 cached_sess->prev->next = cached_sess->next; | |
1438 | |
1439 ngx_rbtree_delete(cache->session_rbtree, node); | |
1440 | |
1441 ngx_slab_free_locked(shpool, cached_sess); | |
1442 ngx_slab_free_locked(shpool, sess_id->id); | |
1443 ngx_slab_free_locked(shpool, sess_id); | |
1444 | |
1445 sess = NULL; | |
1446 | |
1447 break; | |
1448 } | 1452 } |
1449 } | 1453 |
1450 | 1454 node = node->right; |
1451 node = node->right; | 1455 |
1452 } | 1456 } while (node != sentinel && hash == node->key); |
1457 | |
1458 break; | |
1459 } | |
1460 | |
1461 done: | |
1453 | 1462 |
1454 ngx_shmtx_unlock(&shpool->mutex); | 1463 ngx_shmtx_unlock(&shpool->mutex); |
1455 | 1464 |
1456 return sess; | 1465 return sess; |
1457 } | 1466 } |
1498 if (hash > node->key) { | 1507 if (hash > node->key) { |
1499 node = node->right; | 1508 node = node->right; |
1500 continue; | 1509 continue; |
1501 } | 1510 } |
1502 | 1511 |
1503 if (hash == node->key && len == node->data) { | 1512 /* hash == node->key */ |
1504 sess_id = (ngx_ssl_sess_id_t *) node; | 1513 |
1505 | 1514 do { |
1506 if (ngx_strncmp(id, sess_id->id, (size_t) len) == 0) { | 1515 if ((u_char) len == node->data) { |
1507 | 1516 sess_id = (ngx_ssl_sess_id_t *) node; |
1508 cached_sess = sess_id->session; | 1517 |
1509 | 1518 if (ngx_strncmp(id, sess_id->id, (size_t) len) == 0) { |
1510 cached_sess->next->prev = cached_sess->prev; | 1519 |
1511 cached_sess->prev->next = cached_sess->next; | 1520 cached_sess = sess_id->session; |
1512 | 1521 |
1513 ngx_rbtree_delete(cache->session_rbtree, node); | 1522 cached_sess->next->prev = cached_sess->prev; |
1514 | 1523 cached_sess->prev->next = cached_sess->next; |
1515 ngx_slab_free_locked(shpool, cached_sess); | 1524 |
1516 ngx_slab_free_locked(shpool, sess_id->id); | 1525 ngx_rbtree_delete(cache->session_rbtree, node); |
1517 ngx_slab_free_locked(shpool, sess_id); | 1526 |
1518 | 1527 ngx_slab_free_locked(shpool, cached_sess); |
1519 break; | 1528 ngx_slab_free_locked(shpool, sess_id->id); |
1520 } | 1529 ngx_slab_free_locked(shpool, sess_id); |
1521 } | 1530 |
1522 | 1531 goto done; |
1523 node = node->right; | 1532 } |
1524 } | 1533 } |
1534 | |
1535 node = node->right; | |
1536 | |
1537 } while (node != sentinel && hash == node->key); | |
1538 | |
1539 break; | |
1540 } | |
1541 | |
1542 done: | |
1525 | 1543 |
1526 ngx_shmtx_unlock(&shpool->mutex); | 1544 ngx_shmtx_unlock(&shpool->mutex); |
1527 } | 1545 } |
1528 | 1546 |
1529 | 1547 |