Changeset 1d24f9eb2f57e2ec2176345ab54522661ae88465
- Timestamp:
- 10/04/11 03:27:09
(2 years ago)
- Author:
- Theo Schlossnagle <jesus@omniti.com>
- git-committer:
- Theo Schlossnagle <jesus@omniti.com> 1317698829 -0400
- git-parent:
[a24b16602b2109f5f6aa6e2349c56510b0c4d427]
- git-author:
- Theo Schlossnagle <jesus@omniti.com> 1317698829 -0400
- Message:
If the SSL connect "completed" (good or bad) without blocking, we
would lua_resume while already in lua. That resume should only
happen when we're called from the scheduler. So, from the original
instigator, we'll just do the SSL connect manually and handle the
"immediate" connection correctly.
-
Files:
-
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
| rf632f7d |
r1d24f9e |
|
| 506 | 506 | struct nl_slcl *cl = vcl; |
|---|
| 507 | 507 | int rv; |
|---|
| 508 | | |
|---|
| | 508 | |
|---|
| 509 | 509 | rv = eventer_SSL_connect(e, &mask); |
|---|
| 510 | 510 | if(rv <= 0 && errno == EAGAIN) return mask | EVENTER_EXCEPTION; |
|---|
| … | … | |
| 513 | 513 | assert(ci); |
|---|
| 514 | 514 | noit_lua_check_deregister_event(ci, e, 0); |
|---|
| 515 | | |
|---|
| | 515 | |
|---|
| 516 | 516 | *(cl->eptr) = eventer_alloc(); |
|---|
| 517 | 517 | memcpy(*cl->eptr, e, sizeof(*e)); |
|---|
| … | … | |
| 530 | 530 | eventer_t e, *eptr; |
|---|
| 531 | 531 | struct timeval now; |
|---|
| | 532 | int tmpmask, rv; |
|---|
| 532 | 533 | |
|---|
| 533 | 534 | ci = get_ci(L); |
|---|
| … | … | |
| 551 | 552 | eventer_ssl_ctx_set_verify(sslctx, eventer_ssl_verify_cert, NULL); |
|---|
| 552 | 553 | EVENTER_ATTACH_SSL(e, sslctx); |
|---|
| 553 | | e->callback = noit_lua_ssl_upgrade; |
|---|
| 554 | | gettimeofday(&now, NULL); |
|---|
| 555 | | e->mask = e->callback(e, EVENTER_READ|EVENTER_WRITE, e->closure, &now); |
|---|
| 556 | | if(e->mask & (EVENTER_READ|EVENTER_WRITE)) { |
|---|
| | 554 | |
|---|
| | 555 | /* We need do the ssl connect and register a completion if |
|---|
| | 556 | * it comes back with an EAGAIN. |
|---|
| | 557 | */ |
|---|
| | 558 | tmpmask = EVENTER_READ|EVENTER_WRITE; |
|---|
| | 559 | rv = eventer_SSL_connect(e, &tmpmask); |
|---|
| | 560 | if(rv <= 0 && errno == EAGAIN) { |
|---|
| 557 | 561 | /* Need completion */ |
|---|
| | 562 | e->mask = tmpmask | EVENTER_EXCEPTION; |
|---|
| | 563 | e->callback = noit_lua_ssl_upgrade; |
|---|
| 558 | 564 | eventer_add(e); |
|---|
| 559 | 565 | return noit_lua_yield(ci, 0); |
|---|
| 560 | 566 | } |
|---|
| 561 | | lua_pushinteger(L, 0); |
|---|
| | 567 | lua_pushinteger(L, (rv > 0) ? 0 : -1); |
|---|
| 562 | 568 | return 1; |
|---|
| 563 | 569 | } |
|---|