Menu

#1184 SMTP: libcurl hangs when returning CURL_READFUNC_ABORT from readfunc callback

closed-fixed
None
5
2013-06-21
2013-01-25
No

The problem appears in 7.24 (I've not tested the earlier versions of libcurl).
The problem can also be reproduces with libcurl 7.28.

Discussion

  • Patricia Muscalu

    As far as I understand the code, smtp_easy_statemach function enters an endless while-loop in this case: Curl_pp_easy_statemach returns 0 (as select() has timedout). Maybe CURLE_OPERATION_TIMEDOUT should be returned here.
    Is it the correct solution?

     
  • Daniel Stenberg

    Daniel Stenberg - 2013-01-25

    If the callback has returned ABORT then it shouldn't call select at all. Or am I misunderstanding something?

     
  • Patricia Muscalu

    You're completely right.
    What I see is that no status information is propagated to the Curl_disconnect function.Should the connection be marked as premature=TRUE if status==ABORT?

     
  • Patricia Muscalu

    The following patch seems to solve the problem. Could you have a look at the patch? Thanks.

    diff --git a/lib/url.c b/lib/url.c
    index 80c8a997e39891d567a71d7d77bc8de62bf7e25b..40b420b0821804c23b9eaaa2798fe58a3692d582 100644
    --- a/lib/url.c
    +++ b/lib/url.c
    @@ -5174,7 +5174,12 @@ CURLcode Curl_done(struct connectdata connp,
    /
    if(data->set.reuse_forbid || conn->bits.close || premature ||
    (-1 == conn->connection_id)) {
    - CURLcode res2 = Curl_disconnect(conn, premature); /
    close connection /
    + CURLcode res2;
    +
    + if(status == CURLE_ABORTED_BY_CALLBACK)
    + premature = TRUE;
    +
    + res2 = Curl_disconnect(conn, premature); /
    close connection */

     /* If we had an error already, make sure we return that one. But
        if we got a new error, return that. */
    
     
  • Patricia Muscalu

    Hello, I wonder if the suggested patch is the correct one. Thank you!

    I used doc/examples/smtp-multi.c to reproduce the problem.

     
  • Daniel Stenberg

    Daniel Stenberg - 2013-02-08

    thanks a lot for your report and work.

    I've pushed a fix to git just now, commit 72688317adcedb9508fd2. It is slightly different than yours but similar. I've also added test case 1507 that I've used to verify the fix.

     
  • Daniel Stenberg

    Daniel Stenberg - 2013-02-08
    • status: open --> closed-fixed
    • assigned_to: Daniel Stenberg
    • milestone: -->
     
  • Patricia Muscalu

    Thank you!