Async clean ups
authorMatt Caswell <matt@openssl.org>
Thu, 26 Mar 2015 10:15:59 +0000 (10:15 +0000)
committerMatt Caswell <matt@openssl.org>
Fri, 20 Nov 2015 23:32:18 +0000 (23:32 +0000)
Removed the function ASYNC_job_is_waiting() as it was redundant. The only
time user code has a handle on a job is when one is waiting, so all they
need to do is check whether the job is NULL. Also did some cleanups to
make sure the job really is NULL after it has been freed!

Reviewed-by: Rich Salz <rsalz@openssl.org>
crypto/async/async.c
include/openssl/async.h
ssl/ssl_lib.c

index cef5f4f9599e94da8dea83d223892ef7d4f2b9b2..c0f362e2c8b0d469fd5ce8854081257486d84c2a 100644 (file)
@@ -157,6 +157,7 @@ int ASYNC_start_job(ASYNC_JOB **job, int *ret, int (*func)(void *),
                 *ret = ASYNC_get_ctx()->currjob->ret;
                 ASYNC_JOB_free(ASYNC_get_ctx()->currjob);
                 ASYNC_get_ctx()->currjob = NULL;
+                *job = NULL;
                 ASYNC_CTX_free();
                 return ASYNC_FINISH;
             }
@@ -180,6 +181,7 @@ int ASYNC_start_job(ASYNC_JOB **job, int *ret, int (*func)(void *),
             /* Should not happen */
             ASYNC_JOB_free(ASYNC_get_ctx()->currjob);
             ASYNC_get_ctx()->currjob = NULL;
+            *job = NULL;
             ASYNC_CTX_free();
             return ASYNC_ERR;
         }
@@ -213,6 +215,7 @@ int ASYNC_start_job(ASYNC_JOB **job, int *ret, int (*func)(void *),
 err:
     ASYNC_JOB_free(ASYNC_get_ctx()->currjob);
     ASYNC_get_ctx()->currjob = NULL;
+    *job = NULL;
     ASYNC_CTX_free();
     return ASYNC_ERR;
 }
@@ -244,8 +247,3 @@ int ASYNC_in_job(void)
 
     return 0;
 }
-
-int ASYNC_job_is_waiting(ASYNC_JOB *job)
-{
-    return job->status == ASYNC_JOB_PAUSED;
-}
index 434db2254bce3f5994fb7db3fdf2cb1081dccba2..ff5985748df35456182aad8798b4e29298478dad 100644 (file)
@@ -70,7 +70,6 @@ int ASYNC_start_job(ASYNC_JOB **job, int *ret, int (*func)(void *),
                          void *args, size_t size);
 int ASYNC_pause_job(void);
 int ASYNC_in_job(void);
-int ASYNC_job_is_waiting(ASYNC_JOB *job);
 
 # ifdef  __cplusplus
 }
index 63a1a891f265ae81f07189a2dbdbbdb006604962..31adbe473e37afb7103273a1aeb5885956ac5297 100644 (file)
@@ -925,9 +925,9 @@ int SSL_check_private_key(const SSL *ssl)
 
 int SSL_waiting_for_async(SSL *s)
 {
-    if(s->job) {
-        return ASYNC_job_is_waiting(s->job);
-    }
+    if(s->job)
+        return 1;
+
     return 0;
 }