Skip to content
This repository has been archived by the owner on Jan 16, 2021. It is now read-only.

Commit

Permalink
tell the okssl::con_t that the jig is up
Browse files Browse the repository at this point in the history
  • Loading branch information
egwynn committed Oct 14, 2014
1 parent 27352b1 commit 80a0e1b
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
4 changes: 2 additions & 2 deletions client/okwcmain4.T
Expand Up @@ -156,11 +156,11 @@ main2 (int argc, char **argv)
for (s = 0; s < rav.size (); s++) {
ra = rav[s];
if (!cli || !pra || *(pra->host ()) != *(ra->host ()) ) {
cli = New refcounted<okwc4::agent_get_t> (ra->host (), factory);
cli = New refcounted<okwc4::agent_get_t> (ra->host ());
}
cli->set_keepalive (ka);
statusv[s] = HTTP_TIMEOUT;
cli->get (ra, mkevent (rv, statusv[s], respv[s]));
cli->get (ra, connector::timeout (mkevent (rv, statusv[s], respv[s]), timeout));
pra = ra;

if (!parallel) {
Expand Down
2 changes: 2 additions & 0 deletions libokssl/oksslcon.h
Expand Up @@ -38,6 +38,7 @@ namespace okssl {
abuf_src_t *alloc_abuf_src ();
bool ateof () const { return _eof; }
ptr<tame::rcfd_t> _fd;
void cancel() { _cancelled = true; }
protected:
void ssl_connect (evb_t ev, CLOSURE);
void ssl_connect_2 (evb_t ev, CLOSURE);
Expand All @@ -49,6 +50,7 @@ namespace okssl {
bool _connected;
ptr<tame::iofd_t> _rfd, _wfd;
bool _eof;
bool _cancelled;
};

//-----------------------------------------------------------------------
Expand Down
10 changes: 6 additions & 4 deletions libokssl/sslcon.T
Expand Up @@ -30,7 +30,8 @@ namespace okssl {
_connected (false),
_rfd (tame::iofd_t::alloc (_fd, selread)),
_wfd (tame::iofd_t::alloc (_fd, selwrite)),
_eof (false)
_eof (false),
_cancelled (false)
{
unsigned long sl = 1;
if (BIO_socket_ioctl (fd, FIONBIO, &sl) < 0) {
Expand Down Expand Up @@ -271,7 +272,7 @@ namespace okssl {
// only bother to enter this loop if there is data to read and room
// in the buffer. I'm not sure why we'd be called with a len=0, but
// guard against it here.
while (go && len > 0) {
while (go && len > 0 && !_cancelled) {

go = false;

Expand Down Expand Up @@ -301,7 +302,7 @@ namespace okssl {
// Again, protect all forward progress by worrying about
// cancelation by our caller. If we were canceled, then
// don't do anything further.
if (oc == OUTCOME_SUCC) {
if (oc == OUTCOME_SUCC && !_cancelled) {

// This is the actual read.
ret = SSL_read (_ssl, out, len);
Expand Down Expand Up @@ -481,7 +482,8 @@ namespace okssl {

asrc_t::~asrc_t ()
{
*_destroyed = true;
_con->cancel();
*_destroyed = true;
}

//-----------------------------------------------------------------------
Expand Down

0 comments on commit 80a0e1b

Please sign in to comment.