<div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr">Hi Matt,<div><br></div><div>            Thanks a lot for the response. The alternative method to resume job operation is a good one. <br></div><div>             </div><div>            I need some more clarifications regarding the async job operation. Please help.</div><div>            In ssl/ss_lib.c, ssl_start_async_job() function found. In which ASYNC_start_job function is calling but no mechanism found for polling the fd's. Is it written elsewhere?.  <br></div><div>            <br></div></div></div></div></div><br><div class="gmail_quote"><div dir="ltr">On Fri, Jan 11, 2019 at 3:12 PM Matt Caswell <<a href="mailto:matt@openssl.org" target="_blank">matt@openssl.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><br>
<br>
On 10/01/2019 18:09, Ananthu Unnikrishnan wrote:<br>
> Hi Matt,<br>
> <br>
>         Thanks a lot for the reply.<br>
> <br>
>        After calling ASYNC_pause_job() from the engine, control will transfer to<br>
> the place where we start the ASYNC_start_job right? So how can we write the code<br>
> to put a trigger on fd in the same thread?<br>
<br>
I'm not saying you can't use threads to do this - only that you need to be<br>
careful about using them and must obey the rules.<br>
<br>
<br>
> If I am wrong  please correct me.<br>
> Also if u can suggest where resume operation should be done, it would be helpful.<br>
<br>
Typically the calling application will wait on the fd (e.g. using "select" or<br>
similar) until it is readable. Once it sees the fd as readable then it calls<br>
ASYNC_start_job() again.<br>
<br>
<br>
As an aside you may also be interested in this PR that is currently being reviewed:<br>
<br>
<a href="https://github.com/openssl/openssl/pull/7573" rel="noreferrer" target="_blank">https://github.com/openssl/openssl/pull/7573</a><br>
<br>
This adds an alternative mechanism for signalling other than using fds (i.e. to<br>
use a callback instead) and will be available in OpenSSL 3.0 when it gets released.<br>
<br>
Matt<br>
<br>
<br>
<br>
> <br>
> On Thu, Jan 10, 2019 at 10:11 PM Matt Caswell <<a href="mailto:matt@openssl.org" target="_blank">matt@openssl.org</a><br>
> <mailto:<a href="mailto:matt@openssl.org" target="_blank">matt@openssl.org</a>>> wrote:<br>
> <br>
> <br>
> <br>
>     On 10/01/2019 09:39, Ananthu Unnikrishnan wrote:<br>
>     > Hi all,<br>
>     ><br>
>     >         We are not able to access the waitctx address from the job address<br>
>     using<br>
>     > ASYNC_get_wait_ctx(job) from a thread which starts in the bind section of the<br>
>     > dynamic engine. The job address is the same as that we got<br>
>     > using ASYNC_get_current_job.  Can anyone help on this?<br>
> <br>
>     It's very unclear from the your various emails what you are trying to achieve<br>
>     and the problem that you are experiencing.<br>
> <br>
>     From the above it sounds like you are starting threads from inside your dynamic<br>
>     engine? ASYNC_JOBs are always local to a thread. When a job is started it is<br>
>     associated with the current thread. So ASYNC_get_current_job() returns the job<br>
>     associated with the current thread. Similarly if you pause a job,<br>
>     ASYNC_pause_job() must be called from that same thread. Finally if you restart a<br>
>     paused job it must also be restarted on the same thread.<br>
> <br>
>     If you are starting new threads from within your engine then extreme care must<br>
>     be taken to obey the above rules - otherwise you are likely to get strange<br>
>     results.<br>
> <br>
>     Matt<br>
> <br>
> <br>
>     ><br>
>     >          <br>
>     ><br>
>     > On Tue, Jan 8, 2019 at 11:26 AM Ananthu Unnikrishnan<br>
>     <<a href="mailto:ananthuu741@gmail.com" target="_blank">ananthuu741@gmail.com</a> <mailto:<a href="mailto:ananthuu741@gmail.com" target="_blank">ananthuu741@gmail.com</a>><br>
>     > <mailto:<a href="mailto:ananthuu741@gmail.com" target="_blank">ananthuu741@gmail.com</a> <mailto:<a href="mailto:ananthuu741@gmail.com" target="_blank">ananthuu741@gmail.com</a>>>> wrote:<br>
>     ><br>
>     >     Can anyone please help on this? If u need any additional information<br>
>     please<br>
>     >     let me know.<br>
>     ><br>
>     >     On Mon, Jan 7, 2019 at 6:25 PM Ananthu Unnikrishnan<br>
>     <<a href="mailto:ananthuu741@gmail.com" target="_blank">ananthuu741@gmail.com</a> <mailto:<a href="mailto:ananthuu741@gmail.com" target="_blank">ananthuu741@gmail.com</a>><br>
>     >     <mailto:<a href="mailto:ananthuu741@gmail.com" target="_blank">ananthuu741@gmail.com</a> <mailto:<a href="mailto:ananthuu741@gmail.com" target="_blank">ananthuu741@gmail.com</a>>>> wrote:<br>
>     ><br>
>     >         Hi all,<br>
>     ><br>
>     >         Adding more details to the previous mail. We have edited the OpenSSL<br>
>     >         code for implementing the polling for changed fd's as in OpenSSL speed<br>
>     >         command. Attached the code snippet of the same along with this mail.<br>
>     >         Mentioned below some observations which found doubtful:<br>
>     ><br>
>     >         1) We have got prints in ASYNC_FINISH case, before getting print in<br>
>     >         ASYNC_PAUSE case. Attaching the log also, so you can understand<br>
>     easily. <br>
>     >         2) Shown below the code snippet which we have written to provide a<br>
>     write<br>
>     >         on fd.<br>
>     ><br>
>     >         if ((waitctx = ASYNC_get_wait_ctx((ASYNC_JOB *)job)) == NULL) {<br>
>     >                 printf("In dynamic engine | waitctx == NULL : %d\n",<br>
>     __LINE__);<br>
>     >                 return ret;<br>
>     >             }<br>
>     ><br>
>     >             printf("\n----- In dynamic engine | After pausing | job is %lx | <br>
>     >         waitctx in resume job %lx |-----\n", job, waitctx);<br>
>     ><br>
>     >                 if ((ret = ASYNC_WAIT_CTX_get_fd(waitctx, engine_id, &efd,<br>
>     >                                       &custom)) > 0) {<br>
>     >                 if (write(efd, &buf, sizeof(uint64_t)) == -1) {<br>
>     >                     printf("\nFailed to write\n");<br>
>     >                 }<br>
>     >             }<br>
>     ><br>
>     >         Here waitctx is getting NULL when we tried to fetch waitctx using<br>
>     >         ASYNC_get_wait_ctx(). We have printed data of sizeof(ASYNC_JOB)<br>
>     ie.1176<br>
>     >         bytes contained in the job address from the engine,  we got<br>
>     correct data<br>
>     >         before calling ASYNC_pause() and but got half data zero data when we<br>
>     >         tried to access the same address after ASYNC_pause(). <br>
>     ><br>
>     >         Attaching both job structure contents before and after calling<br>
>     >         ASYNC_pause(). Also, we got the correct data in the same address<br>
>     when we<br>
>     >         have printed from ssl_start_async_job() before polling starts,<br>
>     where we<br>
>     >         have started the async_job<br>
>     >         . <br>
>     >         The prints starting with "In dynamic engine" are prints inside the<br>
>     >         engine, rest prints are from ss/ssl_lib.c. Kindly check this and<br>
>     please<br>
>     >         point out if anything is wrong somewhere. Thanks in advance.<br>
>     ><br>
>     ><br>
>     >         On Sun, Jan 6, 2019 at 10:30 AM Ananthu Unnikrishnan<br>
>     >         <<a href="mailto:ananthuu741@gmail.com" target="_blank">ananthuu741@gmail.com</a> <mailto:<a href="mailto:ananthuu741@gmail.com" target="_blank">ananthuu741@gmail.com</a>><br>
>     <mailto:<a href="mailto:ananthuu741@gmail.com" target="_blank">ananthuu741@gmail.com</a> <mailto:<a href="mailto:ananthuu741@gmail.com" target="_blank">ananthuu741@gmail.com</a>>>> wrote:<br>
>     ><br>
>     >             Hi all,<br>
>     ><br>
>     >                    We have implemented a dynamic engine and tested in the<br>
>     async<br>
>     >             mode using OpenSSL speed command. But in a real network<br>
>     scenario, we<br>
>     >             have seen only starting the async_job(in file ssl/ssl_lib.c,<br>
>     >             function: ssl_start_async_job) in the OpenSSL. We haven't seen<br>
>     >             polling async_fd's for resuming the job as in apps/speed.c(in<br>
>     speed<br>
>     >             command case).<br>
>     >                     So can anyone please suggest any solution for resuming the<br>
>     >             async_jobs in real network scenario? Thanks in advance.<br>
>     ><br>
>     ><br>
>     ><br>
>     ><br>
>     ><br>
>     >         --<br>
>     >         With best Regards, <br>
>     ><br>
>     >                  Ananthu<br>
>     ><br>
>     ><br>
>     ><br>
>     ><br>
>     >     --<br>
>     >     With best Regards, <br>
>     ><br>
>     >              Ananthu<br>
>     ><br>
>     ><br>
>     ><br>
>     ><br>
>     > --<br>
>     > With best Regards, <br>
>     ><br>
>     >          Ananthu<br>
>     ><br>
>     ><br>
>     ><br>
>     -- <br>
>     openssl-users mailing list<br>
>     To unsubscribe: <a href="https://mta.openssl.org/mailman/listinfo/openssl-users" rel="noreferrer" target="_blank">https://mta.openssl.org/mailman/listinfo/openssl-users</a><br>
> <br>
> <br>
> <br>
> -- <br>
> With best Regards, <br>
> <br>
>          Ananthu<br>
> <br>
> <br>
> <br>
-- <br>
openssl-users mailing list<br>
To unsubscribe: <a href="https://mta.openssl.org/mailman/listinfo/openssl-users" rel="noreferrer" target="_blank">https://mta.openssl.org/mailman/listinfo/openssl-users</a><br>
</blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr" class="gmail-m_6568501894848592116gmail_signature"><div dir="ltr"><div>With best Regards, </div><div><br></div>         Ananthu<br><div><br><br></div></div></div>