summaryrefslogtreecommitdiffstats
path: root/crypto/async
diff options
context:
space:
mode:
authorAndrea Grandi <andrea.grandi@intel.com>2017-02-10 10:23:21 +0000
committerMatt Caswell <matt@openssl.org>2017-02-13 15:45:12 +0000
commit955286c9f38c11b8be719d632fa9267eb13467f8 (patch)
tree0176ecafde76e272ed1608f006e9482a58d6c95e /crypto/async
parentbb5b56af4c3b9e43a698f01b70732c62d3642583 (diff)
Further improvements to ASYNC_WAIT_CTX_clear_fd
Remove call to cleanup function Use only one loop to find previous element Reviewed-by: Rich Salz <rsalz@openssl.org> Reviewed-by: Matt Caswell <matt@openssl.org> (Merged from https://github.com/openssl/openssl/pull/2581) (cherry picked from commit 219aa86cb04e1bfc9c156fab18da2f767502afb2)
Diffstat (limited to 'crypto/async')
-rw-r--r--crypto/async/async_wait.c23
1 files changed, 7 insertions, 16 deletions
diff --git a/crypto/async/async_wait.c b/crypto/async/async_wait.c
index 50c150e8c5..e115985d22 100644
--- a/crypto/async/async_wait.c
+++ b/crypto/async/async_wait.c
@@ -138,11 +138,12 @@ int ASYNC_WAIT_CTX_get_changed_fds(ASYNC_WAIT_CTX *ctx, OSSL_ASYNC_FD *addfd,
int ASYNC_WAIT_CTX_clear_fd(ASYNC_WAIT_CTX *ctx, const void *key)
{
- struct fd_lookup_st *curr;
+ struct fd_lookup_st *curr, *prev;
curr = ctx->fds;
+ prev = NULL;
while (curr != NULL) {
- if (curr->del) {
+ if (curr->del == 1) {
/* This one has been marked deleted already so do nothing */
curr = curr->next;
continue;
@@ -152,24 +153,13 @@ int ASYNC_WAIT_CTX_clear_fd(ASYNC_WAIT_CTX *ctx, const void *key)
if (curr->add == 1) {
if (ctx->fds == curr) {
ctx->fds = curr->next;
- }
- else {
- struct fd_lookup_st *prev = ctx->fds;
- while (prev->next != curr && prev->next != NULL) {
- prev = prev->next;
- }
- if (prev->next == NULL) {
- return 1;
- }
+ } else {
prev->next = curr->next;
}
- /*
- * The fd has just been added so it can't be used externally
- * and it is safe to call the cleanup function here
+ /* It is responsibility of the caller to cleanup before calling
+ * ASYNC_WAIT_CTX_clear_fd
*/
- if (curr->cleanup != NULL)
- curr->cleanup(ctx, curr->key, curr->fd, curr->custom_data);
OPENSSL_free(curr);
ctx->numadd--;
return 1;
@@ -184,6 +174,7 @@ int ASYNC_WAIT_CTX_clear_fd(ASYNC_WAIT_CTX *ctx, const void *key)
ctx->numdel++;
return 1;
}
+ prev = curr;
curr = curr->next;
}
return 0;