c260e0
From 9b675516d5fb09a455d1f7b7aa98e253361bedf3 Mon Sep 17 00:00:00 2001
c260e0
From: Daniel Stenberg <daniel@haxx.se>
c260e0
Date: Fri, 8 Feb 2013 13:48:56 +0100
c260e0
Subject: [PATCH 1/2] DONE: consider callback-aborted transfers premature
c260e0
c260e0
This bug report properly identified that when doing SMTP and aborting
c260e0
the transfer with a callback, it must be considered aborted prematurely
c260e0
by the code to avoid QUIT etc to be attempted as that would cause a
c260e0
hang.
c260e0
c260e0
The new test case 1507 verifies this behavior.
c260e0
c260e0
Reported by: Patricia Muscalu
c260e0
Bug: http://curl.haxx.se/bug/view.cgi?id=1184
c260e0
c260e0
[upstream commit 72688317adcedb9508fd2189e6c6d3945e06a004]
c260e0
c260e0
Signed-off-by: Kamil Dudka <kdudka@redhat.com>
c260e0
---
c260e0
 lib/url.c                  |    7 ++
c260e0
 tests/data/Makefile.am     |    3 +-
c260e0
 tests/data/Makefile.in     |    3 +-
c260e0
 tests/data/test1507        |   51 +++++++++++++
c260e0
 tests/libtest/Makefile.in  |   82 +++++++++++++++++++++-
c260e0
 tests/libtest/Makefile.inc |    6 ++-
c260e0
 tests/libtest/lib1507.c    |  167 ++++++++++++++++++++++++++++++++++++++++++++
c260e0
 7 files changed, 313 insertions(+), 6 deletions(-)
c260e0
 create mode 100644 tests/data/test1507
c260e0
 create mode 100644 tests/libtest/lib1507.c
c260e0
c260e0
diff --git a/lib/url.c b/lib/url.c
c260e0
index 52f7e27..a6375a2 100644
c260e0
--- a/lib/url.c
c260e0
+++ b/lib/url.c
c260e0
@@ -5222,6 +5222,13 @@ CURLcode Curl_done(struct connectdata **connp,
c260e0
     conn->dns_entry = NULL;
c260e0
   }
c260e0
 
c260e0
+  if(status == CURLE_ABORTED_BY_CALLBACK)
c260e0
+    /* When we're aborted due to a callback return code it basically have to
c260e0
+       be counted as premature as there is trouble ahead if we don't. We have
c260e0
+       many callbacks and protocols work differently, we could potentially do
c260e0
+       this more fine-grained in the future. */
c260e0
+    premature = TRUE;
c260e0
+
c260e0
   /* this calls the protocol-specific function pointer previously set */
c260e0
   if(conn->handler->done)
c260e0
     result = conn->handler->done(conn, status, premature);
c260e0
diff --git a/tests/data/Makefile.am b/tests/data/Makefile.am
c260e0
index 3f6a047..805955c 100644
c260e0
--- a/tests/data/Makefile.am
c260e0
+++ b/tests/data/Makefile.am
c260e0
@@ -93,7 +93,8 @@ test1379 test1380 test1381 test1382 test1383 test1384 test1385 test1386 \
c260e0
 test1387 test1388 test1389 test1390 test1391 test1392 test1393 \
c260e0
 test1400 test1401 test1402 test1403 test1404 test1405 test1406 test1407 \
c260e0
 test1408 test1409 test1410 test1411 test1412 test1413 \
c260e0
-test1500 test1501 test1502 test1503 test1504 test1505 test1506 test1508 \
c260e0
+test1500 test1501 test1502 test1503 test1504 test1505 test1506 test1507 \
c260e0
+test1508 \
c260e0
 test2000 test2001 test2002 test2003 test2004 test2005 test2006 test2007 \
c260e0
 test2008 test2009 test2010 test2011 test2012 test2013 test2014 test2015 \
c260e0
 test2016 test2017 test2018 test2019 test2020 test2021 test2022 \
c260e0
diff --git a/tests/data/Makefile.in b/tests/data/Makefile.in
c260e0
index 71c9422..1e6d679 100644
c260e0
--- a/tests/data/Makefile.in
c260e0
+++ b/tests/data/Makefile.in
c260e0
@@ -357,7 +357,8 @@ test1379 test1380 test1381 test1382 test1383 test1384 test1385 test1386 \
c260e0
 test1387 test1388 test1389 test1390 test1391 test1392 test1393 \
c260e0
 test1400 test1401 test1402 test1403 test1404 test1405 test1406 test1407 \
c260e0
 test1408 test1409 test1410 test1411 test1412 test1413 \
c260e0
-test1500 test1501 test1502 test1503 test1504 test1505 test1506 test1508 \
c260e0
+test1500 test1501 test1502 test1503 test1504 test1505 test1506 test1507 \
c260e0
+test1508 \
c260e0
 test2000 test2001 test2002 test2003 test2004 test2005 test2006 test2007 \
c260e0
 test2008 test2009 test2010 test2011 test2012 test2013 test2014 test2015 \
c260e0
 test2016 test2017 test2018 test2019 test2020 test2021 test2022 \
c260e0
diff --git a/tests/data/test1507 b/tests/data/test1507
c260e0
new file mode 100644
c260e0
index 0000000..b66e71d
c260e0
--- /dev/null
c260e0
+++ b/tests/data/test1507
c260e0
@@ -0,0 +1,51 @@
c260e0
+<testcase>
c260e0
+<info>
c260e0
+<keywords>
c260e0
+SMTP
c260e0
+multi
c260e0
+</keywords>
c260e0
+</info>
c260e0
+
c260e0
+#
c260e0
+# Server-side
c260e0
+<reply>
c260e0
+</reply>
c260e0
+
c260e0
+#
c260e0
+# Client-side
c260e0
+<client>
c260e0
+<server>
c260e0
+smtp
c260e0
+</server>
c260e0
+<tool>
c260e0
+lib1507
c260e0
+</tool>
c260e0
+
c260e0
+# based on bug report #1184
c260e0
+ <name>
c260e0
+SMTP with multi interface and CURLE_ABORTED_BY_CALLBACK
c260e0
+ </name>
c260e0
+<stdin>
c260e0
+From: different
c260e0
+To: another
c260e0
+
c260e0
+body
c260e0
+</stdin>
c260e0
+ <command>
c260e0
+smtp://%HOSTIP:%SMTPPORT/user
c260e0
+</command>
c260e0
+</client>
c260e0
+
c260e0
+#
c260e0
+# Verify data after the test has been "shot"
c260e0
+<verify>
c260e0
+<protocol>
c260e0
+EHLO user
c260e0
+MAIL FROM:<1507-realuser@example.com>
c260e0
+RCPT TO:<1507-recipient@example.com>
c260e0
+DATA
c260e0
+</protocol>
c260e0
+<upload>
c260e0
+</upload>
c260e0
+</verify>
c260e0
+</testcase>
c260e0
diff --git a/tests/libtest/Makefile.in b/tests/libtest/Makefile.in
c260e0
index 7683c09..e6826c0 100644
c260e0
--- a/tests/libtest/Makefile.in
c260e0
+++ b/tests/libtest/Makefile.in
c260e0
@@ -85,7 +85,8 @@ noinst_PROGRAMS = chkhostname$(EXEEXT) libauthretry$(EXEEXT) \
c260e0
 	lib591$(EXEEXT) lib597$(EXEEXT) lib598$(EXEEXT) \
c260e0
 	lib599$(EXEEXT) lib1500$(EXEEXT) lib1501$(EXEEXT) \
c260e0
 	lib1502$(EXEEXT) lib1503$(EXEEXT) lib1504$(EXEEXT) \
c260e0
-	lib1505$(EXEEXT) lib1506$(EXEEXT) lib1508$(EXEEXT)
c260e0
+	lib1505$(EXEEXT) lib1506$(EXEEXT) lib1507$(EXEEXT) \
c260e0
+	lib1508$(EXEEXT)
c260e0
 subdir = tests/libtest
c260e0
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
c260e0
 am__aclocal_m4_deps = $(top_srcdir)/m4/curl-compilers.m4 \
c260e0
@@ -173,6 +174,13 @@ am_lib1506_OBJECTS = lib1506-lib1506.$(OBJEXT) $(am__objects_18) \
c260e0
 	$(am__objects_19) $(am__objects_20)
c260e0
 lib1506_OBJECTS = $(am_lib1506_OBJECTS)
c260e0
 lib1506_DEPENDENCIES = $(am__DEPENDENCIES_1)
c260e0
+am__objects_154 = lib1507-first.$(OBJEXT)
c260e0
+am__objects_155 = lib1507-testutil.$(OBJEXT)
c260e0
+am__objects_156 = lib1507-warnless.$(OBJEXT)
c260e0
+am_lib1507_OBJECTS = lib1507-lib1507.$(OBJEXT) $(am__objects_154) \
c260e0
+	$(am__objects_155) $(am__objects_156)
c260e0
+lib1507_OBJECTS = $(am_lib1507_OBJECTS)
c260e0
+lib1507_DEPENDENCIES = $(am__DEPENDENCIES_1)
c260e0
 am__objects_151 = lib1508-first.$(OBJEXT)
c260e0
 am__objects_152 = lib1508-testutil.$(OBJEXT)
c260e0
 am__objects_153 = lib1508-warnless.$(OBJEXT)
c260e0
@@ -639,7 +647,8 @@ LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
c260e0
 SOURCES = $(libhostname_la_SOURCES) $(chkhostname_SOURCES) \
c260e0
 	$(lib1500_SOURCES) $(lib1501_SOURCES) $(lib1502_SOURCES) \
c260e0
 	$(lib1503_SOURCES) $(lib1504_SOURCES) $(lib1505_SOURCES) \
c260e0
-	$(lib1506_SOURCES) $(lib1508_SOURCES) $(lib500_SOURCES) $(lib501_SOURCES) \
c260e0
+	$(lib1506_SOURCES) $(lib1507_SOURCES) $(lib1508_SOURCES) \
c260e0
+	$(lib500_SOURCES) $(lib501_SOURCES) \
c260e0
 	$(lib502_SOURCES) $(lib503_SOURCES) $(lib504_SOURCES) \
c260e0
 	$(lib505_SOURCES) $(lib506_SOURCES) $(lib507_SOURCES) \
c260e0
 	$(lib508_SOURCES) $(lib510_SOURCES) $(lib511_SOURCES) \
c260e0
@@ -669,7 +678,8 @@ SOURCES = $(libhostname_la_SOURCES) $(chkhostname_SOURCES) \
c260e0
 DIST_SOURCES = $(libhostname_la_SOURCES) $(chkhostname_SOURCES) \
c260e0
 	$(lib1500_SOURCES) $(lib1501_SOURCES) $(lib1502_SOURCES) \
c260e0
 	$(lib1503_SOURCES) $(lib1504_SOURCES) $(lib1505_SOURCES) \
c260e0
-	$(lib1506_SOURCES) $(lib1508_SOURCES) $(lib500_SOURCES) $(lib501_SOURCES)  \
c260e0
+	$(lib1506_SOURCES) $(lib1507_SOURCES) $(lib1508_SOURCES) \
c260e0
+	$(lib500_SOURCES) $(lib501_SOURCES)  \
c260e0
 	$(lib502_SOURCES) $(lib503_SOURCES) $(lib504_SOURCES) \
c260e0
 	$(lib505_SOURCES) $(lib506_SOURCES) $(lib507_SOURCES) \
c260e0
 	$(lib508_SOURCES) $(lib510_SOURCES) $(lib511_SOURCES) \
c260e0
@@ -1162,6 +1172,9 @@ lib1505_CPPFLAGS = $(AM_CPPFLAGS) -DLIB1505
c260e0
 lib1506_SOURCES = lib1506.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS)
c260e0
 lib1506_LDADD = $(TESTUTIL_LIBS)
c260e0
 lib1506_CPPFLAGS = $(AM_CPPFLAGS) -DLIB1506
c260e0
+lib1507_SOURCES = lib1507.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS)
c260e0
+lib1507_LDADD = $(TESTUTIL_LIBS)
c260e0
+lib1507_CPPFLAGS = $(AM_CPPFLAGS) -DLIB1507
c260e0
 lib1508_SOURCES = lib1508.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS)
c260e0
 lib1508_LDADD = $(TESTUTIL_LIBS)
c260e0
 lib1508_CPPFLAGS = $(AM_CPPFLAGS) -DLIB1508
c260e0
@@ -1263,6 +1276,9 @@ lib1505$(EXEEXT): $(lib1505_OBJECTS) $(lib1505_DEPENDENCIES) $(EXTRA_lib1505_DEP
c260e0
 lib1506$(EXEEXT): $(lib1506_OBJECTS) $(lib1506_DEPENDENCIES) $(EXTRA_lib1506_DEPENDENCIES) 
c260e0
 	@rm -f lib1506$(EXEEXT)
c260e0
 	$(LINK) $(lib1506_OBJECTS) $(lib1506_LDADD) $(LIBS)
c260e0
+lib1507$(EXEEXT): $(lib1507_OBJECTS) $(lib1507_DEPENDENCIES) $(EXTRA_lib1507_DEPENDENCIES) 
c260e0
+	@rm -f lib1507$(EXEEXT)
c260e0
+	$(LINK) $(lib1507_OBJECTS) $(lib1507_LDADD) $(LIBS)
c260e0
 lib1508$(EXEEXT): $(lib1508_OBJECTS) $(lib1508_DEPENDENCIES) $(EXTRA_lib1508_DEPENDENCIES) 
c260e0
 	@rm -f lib1508$(EXEEXT)
c260e0
 	$(LINK) $(lib1508_OBJECTS) $(lib1508_LDADD) $(LIBS)
c260e0
@@ -1533,6 +1549,10 @@ distclean-compile:
c260e0
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lib1506-lib1506.Po@am__quote@
c260e0
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lib1506-testutil.Po@am__quote@
c260e0
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lib1506-warnless.Po@am__quote@
c260e0
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lib1507-first.Po@am__quote@
c260e0
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lib1507-lib1507.Po@am__quote@
c260e0
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lib1507-testutil.Po@am__quote@
c260e0
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lib1507-warnless.Po@am__quote@
c260e0
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lib1508-first.Po@am__quote@
c260e0
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lib1508-lib1508.Po@am__quote@
c260e0
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lib1508-testutil.Po@am__quote@
c260e0
@@ -2180,6 +2200,62 @@ lib1506-warnless.obj: ../../lib/warnless.c
c260e0
 @AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
c260e0
 @am__fastdepCC_FALSE@	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(lib1506_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o lib1506-warnless.obj `if test -f '../../lib/warnless.c'; then $(CYGPATH_W) '../../lib/warnless.c'; else $(CYGPATH_W) '$(srcdir)/../../lib/warnless.c'; fi`
c260e0
 
c260e0
+lib1507-lib1507.o: lib1507.c
c260e0
+@am__fastdepCC_TRUE@	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(lib1507_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT lib1507-lib1507.o -MD -MP -MF $(DEPDIR)/lib1507-lib1507.Tpo -c -o lib1507-lib1507.o `test -f 'lib1507.c' || echo '$(srcdir)/'`lib1507.c
c260e0
+@am__fastdepCC_TRUE@	$(am__mv) $(DEPDIR)/lib1507-lib1507.Tpo $(DEPDIR)/lib1507-lib1507.Po
c260e0
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='lib1507.c' object='lib1507-lib1507.o' libtool=no @AMDEPBACKSLASH@
c260e0
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
c260e0
+@am__fastdepCC_FALSE@	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(lib1507_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o lib1507-lib1507.o `test -f 'lib1507.c' || echo '$(srcdir)/'`lib1507.c
c260e0
+
c260e0
+lib1507-lib1507.obj: lib1507.c
c260e0
+@am__fastdepCC_TRUE@	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(lib1507_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT lib1507-lib1507.obj -MD -MP -MF $(DEPDIR)/lib1507-lib1507.Tpo -c -o lib1507-lib1507.obj `if test -f 'lib1507.c'; then $(CYGPATH_W) 'lib1507.c'; else $(CYGPATH_W) '$(srcdir)/lib1507.c'; fi`
c260e0
+@am__fastdepCC_TRUE@	$(am__mv) $(DEPDIR)/lib1507-lib1507.Tpo $(DEPDIR)/lib1507-lib1507.Po
c260e0
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='lib1507.c' object='lib1507-lib1507.obj' libtool=no @AMDEPBACKSLASH@
c260e0
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
c260e0
+@am__fastdepCC_FALSE@	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(lib1507_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o lib1507-lib1507.obj `if test -f 'lib1507.c'; then $(CYGPATH_W) 'lib1507.c'; else $(CYGPATH_W) '$(srcdir)/lib1507.c'; fi`
c260e0
+
c260e0
+lib1507-first.o: first.c
c260e0
+@am__fastdepCC_TRUE@	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(lib1507_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT lib1507-first.o -MD -MP -MF $(DEPDIR)/lib1507-first.Tpo -c -o lib1507-first.o `test -f 'first.c' || echo '$(srcdir)/'`first.c
c260e0
+@am__fastdepCC_TRUE@	$(am__mv) $(DEPDIR)/lib1507-first.Tpo $(DEPDIR)/lib1507-first.Po
c260e0
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='first.c' object='lib1507-first.o' libtool=no @AMDEPBACKSLASH@
c260e0
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
c260e0
+@am__fastdepCC_FALSE@	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(lib1507_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o lib1507-first.o `test -f 'first.c' || echo '$(srcdir)/'`first.c
c260e0
+
c260e0
+lib1507-first.obj: first.c
c260e0
+@am__fastdepCC_TRUE@	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(lib1507_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT lib1507-first.obj -MD -MP -MF $(DEPDIR)/lib1507-first.Tpo -c -o lib1507-first.obj `if test -f 'first.c'; then $(CYGPATH_W) 'first.c'; else $(CYGPATH_W) '$(srcdir)/first.c'; fi`
c260e0
+@am__fastdepCC_TRUE@	$(am__mv) $(DEPDIR)/lib1507-first.Tpo $(DEPDIR)/lib1507-first.Po
c260e0
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='first.c' object='lib1507-first.obj' libtool=no @AMDEPBACKSLASH@
c260e0
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
c260e0
+@am__fastdepCC_FALSE@	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(lib1507_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o lib1507-first.obj `if test -f 'first.c'; then $(CYGPATH_W) 'first.c'; else $(CYGPATH_W) '$(srcdir)/first.c'; fi`
c260e0
+
c260e0
+lib1507-testutil.o: testutil.c
c260e0
+@am__fastdepCC_TRUE@	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(lib1507_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT lib1507-testutil.o -MD -MP -MF $(DEPDIR)/lib1507-testutil.Tpo -c -o lib1507-testutil.o `test -f 'testutil.c' || echo '$(srcdir)/'`testutil.c
c260e0
+@am__fastdepCC_TRUE@	$(am__mv) $(DEPDIR)/lib1507-testutil.Tpo $(DEPDIR)/lib1507-testutil.Po
c260e0
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='testutil.c' object='lib1507-testutil.o' libtool=no @AMDEPBACKSLASH@
c260e0
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
c260e0
+@am__fastdepCC_FALSE@	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(lib1507_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o lib1507-testutil.o `test -f 'testutil.c' || echo '$(srcdir)/'`testutil.c
c260e0
+
c260e0
+lib1507-testutil.obj: testutil.c
c260e0
+@am__fastdepCC_TRUE@	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(lib1507_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT lib1507-testutil.obj -MD -MP -MF $(DEPDIR)/lib1507-testutil.Tpo -c -o lib1507-testutil.obj `if test -f 'testutil.c'; then $(CYGPATH_W) 'testutil.c'; else $(CYGPATH_W) '$(srcdir)/testutil.c'; fi`
c260e0
+@am__fastdepCC_TRUE@	$(am__mv) $(DEPDIR)/lib1507-testutil.Tpo $(DEPDIR)/lib1507-testutil.Po
c260e0
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='testutil.c' object='lib1507-testutil.obj' libtool=no @AMDEPBACKSLASH@
c260e0
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
c260e0
+@am__fastdepCC_FALSE@	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(lib1507_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o lib1507-testutil.obj `if test -f 'testutil.c'; then $(CYGPATH_W) 'testutil.c'; else $(CYGPATH_W) '$(srcdir)/testutil.c'; fi`
c260e0
+
c260e0
+lib1507-warnless.o: ../../lib/warnless.c
c260e0
+@am__fastdepCC_TRUE@	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(lib1507_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT lib1507-warnless.o -MD -MP -MF $(DEPDIR)/lib1507-warnless.Tpo -c -o lib1507-warnless.o `test -f '../../lib/warnless.c' || echo '$(srcdir)/'`../../lib/warnless.c
c260e0
+@am__fastdepCC_TRUE@	$(am__mv) $(DEPDIR)/lib1507-warnless.Tpo $(DEPDIR)/lib1507-warnless.Po
c260e0
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='../../lib/warnless.c' object='lib1507-warnless.o' libtool=no @AMDEPBACKSLASH@
c260e0
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
c260e0
+@am__fastdepCC_FALSE@	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(lib1507_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o lib1507-warnless.o `test -f '../../lib/warnless.c' || echo '$(srcdir)/'`../../lib/warnless.c
c260e0
+
c260e0
+lib1507-warnless.obj: ../../lib/warnless.c
c260e0
+@am__fastdepCC_TRUE@	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(lib1507_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT lib1507-warnless.obj -MD -MP -MF $(DEPDIR)/lib1507-warnless.Tpo -c -o lib1507-warnless.obj `if test -f '../../lib/warnless.c'; then $(CYGPATH_W) '../../lib/warnless.c'; else $(CYGPATH_W) '$(srcdir)/../../lib/warnless.c'; fi`
c260e0
+@am__fastdepCC_TRUE@	$(am__mv) $(DEPDIR)/lib1507-warnless.Tpo $(DEPDIR)/lib1507-warnless.Po
c260e0
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='../../lib/warnless.c' object='lib1507-warnless.obj' libtool=no @AMDEPBACKSLASH@
c260e0
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
c260e0
+@am__fastdepCC_FALSE@	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(lib1507_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o lib1507-warnless.obj `if test -f '../../lib/warnless.c'; then $(CYGPATH_W) '../../lib/warnless.c'; else $(CYGPATH_W) '$(srcdir)/../../lib/warnless.c'; fi`
c260e0
+
c260e0
 lib1508-lib1508.o: lib1508.c
c260e0
 @am__fastdepCC_TRUE@	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(lib1508_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT lib1508-lib1508.o -MD -MP -MF $(DEPDIR)/lib1508-lib1508.Tpo -c -o lib1508-lib1508.o `test -f 'lib1508.c' || echo '$(srcdir)/'`lib1508.c
c260e0
 @am__fastdepCC_TRUE@	$(am__mv) $(DEPDIR)/lib1508-lib1508.Tpo $(DEPDIR)/lib1508-lib1508.Po
c260e0
diff --git a/tests/libtest/Makefile.inc b/tests/libtest/Makefile.inc
c260e0
index 8bf2be4..5e377d3 100644
c260e0
--- a/tests/libtest/Makefile.inc
c260e0
+++ b/tests/libtest/Makefile.inc
c260e0
@@ -23,7 +23,7 @@ noinst_PROGRAMS = chkhostname libauthretry libntlmconnect \
c260e0
                 lib582 lib583        lib585 lib586 lib587               \
c260e0
   lib590 lib591                                    lib597 lib598 lib599 \
c260e0
   \
c260e0
-  lib1500 lib1501 lib1502 lib1503 lib1504 lib1505 lib1506 lib1508
c260e0
+  lib1500 lib1501 lib1502 lib1503 lib1504 lib1505 lib1506 lib1507 lib1508
c260e0
 
c260e0
 chkhostname_SOURCES = chkhostname.c ../../lib/curl_gethostname.c
c260e0
 chkhostname_LDADD = @CURL_NETWORK_LIBS@
c260e0
@@ -313,6 +313,10 @@ lib1506_SOURCES = lib1506.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS)
c260e0
 lib1506_LDADD = $(TESTUTIL_LIBS)
c260e0
 lib1506_CPPFLAGS = $(AM_CPPFLAGS) -DLIB1506
c260e0
 
c260e0
+lib1507_SOURCES = lib1507.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS)
c260e0
+lib1507_LDADD = $(TESTUTIL_LIBS)
c260e0
+lib1507_CPPFLAGS = $(AM_CPPFLAGS) -DLIB1507
c260e0
+
c260e0
 lib1508_SOURCES = lib1508.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS)
c260e0
 lib1508_LDADD = $(TESTUTIL_LIBS)
c260e0
 lib1508_CPPFLAGS = $(AM_CPPFLAGS) -DLIB1508
c260e0
diff --git a/tests/libtest/lib1507.c b/tests/libtest/lib1507.c
c260e0
new file mode 100644
c260e0
index 0000000..7c4e6ed
c260e0
--- /dev/null
c260e0
+++ b/tests/libtest/lib1507.c
c260e0
@@ -0,0 +1,167 @@
c260e0
+/***************************************************************************
c260e0
+ *                                  _   _ ____  _
c260e0
+ *  Project                     ___| | | |  _ \| |
c260e0
+ *                             / __| | | | |_) | |
c260e0
+ *                            | (__| |_| |  _ <| |___
c260e0
+ *                             \___|\___/|_| \_\_____|
c260e0
+ *
c260e0
+ * Copyright (C) 1998 - 2013, Daniel Stenberg, <daniel@haxx.se>, et al.
c260e0
+ *
c260e0
+ * This software is licensed as described in the file COPYING, which
c260e0
+ * you should have received as part of this distribution. The terms
c260e0
+ * are also available at http://curl.haxx.se/docs/copyright.html.
c260e0
+ *
c260e0
+ * You may opt to use, copy, modify, merge, publish, distribute and/or sell
c260e0
+ * copies of the Software, and permit persons to whom the Software is
c260e0
+ * furnished to do so, under the terms of the COPYING file.
c260e0
+ *
c260e0
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
c260e0
+ * KIND, either express or implied.
c260e0
+ *
c260e0
+ ***************************************************************************/
c260e0
+#include "test.h"
c260e0
+
c260e0
+#include "testutil.h"
c260e0
+#include "warnless.h"
c260e0
+#include "memdebug.h"
c260e0
+
c260e0
+/*
c260e0
+ * This is the list of basic details you need to tweak to get things right.
c260e0
+ */
c260e0
+#define USERNAME "user@example.com"
c260e0
+#define PASSWORD "123qwerty"
c260e0
+#define RECIPIENT "<1507-recipient@example.com>"
c260e0
+#define MAILFROM "<1507-realuser@example.com>"
c260e0
+
c260e0
+#define MULTI_PERFORM_HANG_TIMEOUT 60 * 1000
c260e0
+
c260e0
+static size_t read_callback(void *ptr, size_t size, size_t nmemb, void *userp)
c260e0
+{
c260e0
+  (void)ptr;
c260e0
+  (void)size;
c260e0
+  (void)nmemb;
c260e0
+  (void)userp;
c260e0
+  return CURL_READFUNC_ABORT;
c260e0
+}
c260e0
+
c260e0
+static struct timeval tvnow(void)
c260e0
+{
c260e0
+  /*
c260e0
+  ** time() returns the value of time in seconds since the Epoch.
c260e0
+  */
c260e0
+  struct timeval now;
c260e0
+  now.tv_sec = (long)time(NULL);
c260e0
+  now.tv_usec = 0;
c260e0
+  return now;
c260e0
+}
c260e0
+
c260e0
+static long tvdiff(struct timeval newer, struct timeval older)
c260e0
+{
c260e0
+  return (newer.tv_sec-older.tv_sec)*1000+
c260e0
+    (newer.tv_usec-older.tv_usec)/1000;
c260e0
+}
c260e0
+
c260e0
+int test(char *URL)
c260e0
+{
c260e0
+   CURL *curl;
c260e0
+   CURLM *mcurl;
c260e0
+   int still_running = 1;
c260e0
+   struct timeval mp_start;
c260e0
+   struct curl_slist* rcpt_list = NULL;
c260e0
+
c260e0
+   curl_global_init(CURL_GLOBAL_DEFAULT);
c260e0
+
c260e0
+   curl = curl_easy_init();
c260e0
+   if(!curl)
c260e0
+     return 1;
c260e0
+
c260e0
+   mcurl = curl_multi_init();
c260e0
+   if(!mcurl)
c260e0
+     return 2;
c260e0
+
c260e0
+   rcpt_list = curl_slist_append(rcpt_list, RECIPIENT);
c260e0
+   /* more addresses can be added here
c260e0
+      rcpt_list = curl_slist_append(rcpt_list, "<others@example.com>");
c260e0
+   */
c260e0
+
c260e0
+   curl_easy_setopt(curl, CURLOPT_URL, URL);
c260e0
+#if 0
c260e0
+   curl_easy_setopt(curl, CURLOPT_USERNAME, USERNAME);
c260e0
+   curl_easy_setopt(curl, CURLOPT_PASSWORD, PASSWORD);
c260e0
+#endif
c260e0
+   curl_easy_setopt(curl, CURLOPT_READFUNCTION, read_callback);
c260e0
+   curl_easy_setopt(curl, CURLOPT_MAIL_FROM, MAILFROM);
c260e0
+   curl_easy_setopt(curl, CURLOPT_MAIL_RCPT, rcpt_list);
c260e0
+   curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
c260e0
+   curl_multi_add_handle(mcurl, curl);
c260e0
+
c260e0
+   mp_start = tvnow();
c260e0
+
c260e0
+  /* we start some action by calling perform right away */
c260e0
+  curl_multi_perform(mcurl, &still_running);
c260e0
+
c260e0
+  while(still_running) {
c260e0
+    struct timeval timeout;
c260e0
+    int rc; /* select() return code */
c260e0
+
c260e0
+    fd_set fdread;
c260e0
+    fd_set fdwrite;
c260e0
+    fd_set fdexcep;
c260e0
+    int maxfd = -1;
c260e0
+
c260e0
+    long curl_timeo = -1;
c260e0
+
c260e0
+    FD_ZERO(&fdread);
c260e0
+    FD_ZERO(&fdwrite);
c260e0
+    FD_ZERO(&fdexcep);
c260e0
+
c260e0
+    /* set a suitable timeout to play around with */
c260e0
+    timeout.tv_sec = 1;
c260e0
+    timeout.tv_usec = 0;
c260e0
+
c260e0
+    curl_multi_timeout(mcurl, &curl_timeo);
c260e0
+    if(curl_timeo >= 0) {
c260e0
+      timeout.tv_sec = curl_timeo / 1000;
c260e0
+      if(timeout.tv_sec > 1)
c260e0
+        timeout.tv_sec = 1;
c260e0
+      else
c260e0
+        timeout.tv_usec = (curl_timeo % 1000) * 1000;
c260e0
+    }
c260e0
+
c260e0
+    /* get file descriptors from the transfers */
c260e0
+    curl_multi_fdset(mcurl, &fdread, &fdwrite, &fdexcep, &maxfd);
c260e0
+
c260e0
+    /* In a real-world program you OF COURSE check the return code of the
c260e0
+       function calls.  On success, the value of maxfd is guaranteed to be
c260e0
+       greater or equal than -1.  We call select(maxfd + 1, ...), specially in
c260e0
+       case of (maxfd == -1), we call select(0, ...), which is basically equal
c260e0
+       to sleep. */
c260e0
+
c260e0
+    rc = select(maxfd+1, &fdread, &fdwrite, &fdexcep, &timeout);
c260e0
+
c260e0
+    if (tvdiff(tvnow(), mp_start) > MULTI_PERFORM_HANG_TIMEOUT) {
c260e0
+      fprintf(stderr, "ABORTING TEST, since it seems "
c260e0
+              "that it would have run forever.\n");
c260e0
+      break;
c260e0
+    }
c260e0
+
c260e0
+    switch(rc) {
c260e0
+    case -1:
c260e0
+      /* select error */
c260e0
+      break;
c260e0
+    case 0: /* timeout */
c260e0
+    default: /* action */
c260e0
+      curl_multi_perform(mcurl, &still_running);
c260e0
+      break;
c260e0
+    }
c260e0
+  }
c260e0
+
c260e0
+  curl_slist_free_all(rcpt_list);
c260e0
+  curl_multi_remove_handle(mcurl, curl);
c260e0
+  curl_multi_cleanup(mcurl);
c260e0
+  curl_easy_cleanup(curl);
c260e0
+  curl_global_cleanup();
c260e0
+  return 0;
c260e0
+}
c260e0
+
c260e0
+
c260e0
-- 
c260e0
1.7.1
c260e0
c260e0
c260e0
From 55004df420d1e520d84fded41a4d16f36acee119 Mon Sep 17 00:00:00 2001
c260e0
From: Kamil Dudka <kdudka@redhat.com>
c260e0
Date: Mon, 9 Sep 2013 13:10:53 +0200
c260e0
Subject: [PATCH 2/2] url: handle abortion by read/write callbacks, too
c260e0
c260e0
Otherwise, the FTP protocol would unnecessarily hang 60 seconds if
c260e0
aborted in the CURLOPT_HEADERFUNCTION callback.
c260e0
c260e0
Reported by: Tomas Mlcoch
c260e0
Bug: https://bugzilla.redhat.com/1005686
c260e0
c260e0
[upstream commit c639d725a37c91fb49bb3a689cb2596fad3a0645]
c260e0
---
c260e0
 lib/url.c |    8 +++++++-
c260e0
 1 files changed, 7 insertions(+), 1 deletions(-)
c260e0
c260e0
diff --git a/lib/url.c b/lib/url.c
c260e0
index a6375a2..bddbd91 100644
c260e0
--- a/lib/url.c
c260e0
+++ b/lib/url.c
c260e0
@@ -5222,12 +5222,18 @@ CURLcode Curl_done(struct connectdata **connp,
c260e0
     conn->dns_entry = NULL;
c260e0
   }
c260e0
 
c260e0
-  if(status == CURLE_ABORTED_BY_CALLBACK)
c260e0
+  switch(status) {
c260e0
+  case CURLE_ABORTED_BY_CALLBACK:
c260e0
+  case CURLE_READ_ERROR:
c260e0
+  case CURLE_WRITE_ERROR:
c260e0
     /* When we're aborted due to a callback return code it basically have to
c260e0
        be counted as premature as there is trouble ahead if we don't. We have
c260e0
        many callbacks and protocols work differently, we could potentially do
c260e0
        this more fine-grained in the future. */
c260e0
     premature = TRUE;
c260e0
+  default:
c260e0
+    break;
c260e0
+  }
c260e0
 
c260e0
   /* this calls the protocol-specific function pointer previously set */
c260e0
   if(conn->handler->done)
c260e0
-- 
c260e0
1.7.1
c260e0