Changeset 1d24f9eb2f57e2ec2176345ab54522661ae88465

Show
Ignore:
Timestamp:
10/04/11 03:27:09 (3 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
  • src/modules/lua_noit.c

    rf632f7d r1d24f9e  
    506506  struct nl_slcl *cl = vcl; 
    507507  int rv; 
    508    
     508 
    509509  rv = eventer_SSL_connect(e, &mask); 
    510510  if(rv <= 0 && errno == EAGAIN) return mask | EVENTER_EXCEPTION; 
     
    513513  assert(ci); 
    514514  noit_lua_check_deregister_event(ci, e, 0); 
    515    
     515 
    516516  *(cl->eptr) = eventer_alloc(); 
    517517  memcpy(*cl->eptr, e, sizeof(*e)); 
     
    530530  eventer_t e, *eptr; 
    531531  struct timeval now; 
     532  int tmpmask, rv; 
    532533 
    533534  ci = get_ci(L); 
     
    551552  eventer_ssl_ctx_set_verify(sslctx, eventer_ssl_verify_cert, NULL); 
    552553  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) { 
    557561    /* Need completion */ 
     562    e->mask = tmpmask | EVENTER_EXCEPTION; 
     563    e->callback = noit_lua_ssl_upgrade; 
    558564    eventer_add(e); 
    559565    return noit_lua_yield(ci, 0); 
    560566  } 
    561   lua_pushinteger(L, 0); 
     567  lua_pushinteger(L, (rv > 0) ? 0 : -1); 
    562568  return 1; 
    563569}