Branch: Tag:

2014-05-02

2014-05-02 15:03:03 by Henrik Grubbström (Grubba) <grubba@grubba.org>

Compat: 7.8::SSL: Some more robustness fixes in destroy().

Apply the "SSL: Some more robustness fixes in destroy()." fix from
Pike 7.8 in the Pike 7.8 compat SSL module:

set_nonblocking_keep_callbacks() calls update_internal_state(),
which is likely to install callbacks and thus may trigger the
tests in CHECK_CB_MODE() (cf [bug 6958] #6).

Yet another potential fix for [bug 6958].

806:    // We don't know which thread this will be called in if the refcount    // garb or the gc got here. That's not a race problem since it won't    // be registered in a backend in that case. -  if (stream && stream->query_backend()) { +  if (stream) {    // Make sure not to fail in ENTER below due to bad backend thread.    // [bug 6958]. -  stream->set_backend(Pike.DefaultBackend); +  stream->set_callbacks(0, 0, 0);    }    ENTER (0, 0) {    if (stream) {
817:    // Don't bother with closing nicely if there's an error from    // an earlier operation. close() will throw an error for it.    !cb_errno) { -  set_nonblocking_keep_callbacks(); +  // We can't use our set_nonblocking() et al here, since we +  // might be associated with a backend in a different thread, +  // and update_internal_state() will install callbacks, which +  // in turn might trigger the tests in CHECK_CB_MODE(). +  stream->set_nonblocking(); // Make sure not to to block. +  nonblocking_mode = 0; // Make sure not to install any callbacks.    close (0, 0, 1);    }    else