cURL / Mailing Lists / curl-library / Single Mail

curl-library

[PATCH] CURLM_ADDED_ALREADY: new error code

From: Daniel Stenberg <daniel_at_haxx.se>
Date: Tue, 20 Aug 2013 12:31:24 +0200 (CEST)

Hi all,

I'm about to introduce a new error code for the multi interface so I'm all
ears for any feedback you might have on this!

Doing curl_multi_add_handle() on an easy handle that is already added to
a multi handle now returns this error code. It previously returned
CURLM_BAD_EASY_HANDLE for this condition.

---
  docs/libcurl/libcurl-errors.3    | 5 ++++-
  docs/libcurl/symbols-in-versions | 1 +
  include/curl/multi.h             | 4 +++-
  lib/multi.c                      | 3 +--
  lib/strerror.c                   | 5 ++++-
  5 files changed, 13 insertions(+), 5 deletions(-)
diff --git a/docs/libcurl/libcurl-errors.3 b/docs/libcurl/libcurl-errors.3
index 7b68237..af87117 100644
--- a/docs/libcurl/libcurl-errors.3
+++ b/docs/libcurl/libcurl-errors.3
@@ -5,7 +5,7 @@
  .\" *                            | (__| |_| |  _ <| |___
  .\" *                             \___|\___/|_| \_\_____|
  .\" *
-.\" * Copyright (C) 1998 - 2012, Daniel Stenberg, <daniel_at_haxx.se>, et al.
+.\" * Copyright (C) 1998 - 2013, Daniel Stenberg, <daniel_at_haxx.se>, et al.
  .\" *
  .\" * This software is licensed as described in the file COPYING, which
  .\" * you should have received as part of this distribution. The terms
@@ -273,6 +273,9 @@ The passed-in socket is not a valid one that libcurl already knows about.
  .IP "CURLM_UNKNOWN_OPTION (6)"
  curl_multi_setopt() with unsupported option
  (Added in 7.15.4)
+.IP "CURLM_ADDED_ALREADY (7)"
+An easy handle already added to a multi handle was attmpted to get added a
+second time. (Added in 7.32.1)
  .SH "CURLSHcode"
  The "share" interface will return a CURLSHcode to indicate when an error has
  occurred.  Also consider \fIcurl_share_strerror(3)\fP.
diff --git a/docs/libcurl/symbols-in-versions b/docs/libcurl/symbols-in-versions
index e61cbbe..04caf71 100644
--- a/docs/libcurl/symbols-in-versions
+++ b/docs/libcurl/symbols-in-versions
@@ -283,6 +283,7 @@ CURLMOPT_TIMERDATA              7.16.0
  CURLMOPT_TIMERFUNCTION          7.16.0
  CURLMSG_DONE                    7.9.6
  CURLMSG_NONE                    7.9.6
+CURLM_ADDED_ALREADY             7.32.1
  CURLM_BAD_EASY_HANDLE           7.9.6
  CURLM_BAD_HANDLE                7.9.6
  CURLM_BAD_SOCKET                7.15.4
diff --git a/include/curl/multi.h b/include/curl/multi.h
index a5eb3c6..69a7307 100644
--- a/include/curl/multi.h
+++ b/include/curl/multi.h
@@ -7,7 +7,7 @@
   *                            | (__| |_| |  _ <| |___
   *                             \___|\___/|_| \_\_____|
   *
- * Copyright (C) 1998 - 2012, Daniel Stenberg, <daniel_at_haxx.se>, et al.
+ * Copyright (C) 1998 - 2013, Daniel Stenberg, <daniel_at_haxx.se>, et al.
   *
   * This software is licensed as described in the file COPYING, which
   * you should have received as part of this distribution. The terms
@@ -64,6 +64,8 @@ typedef enum {
    CURLM_INTERNAL_ERROR,  /* this is a libcurl bug */
    CURLM_BAD_SOCKET,      /* the passed in socket argument did not match */
    CURLM_UNKNOWN_OPTION,  /* curl_multi_setopt() with unsupported option */
+  CURLM_ADDED_ALREADY,   /* an easy handle already added to a multi handle was
+                            attmpted to get added - again */
    CURLM_LAST
  } CURLMcode;
diff --git a/lib/multi.c b/lib/multi.c
index 306b769..0160540 100644
--- a/lib/multi.c
+++ b/lib/multi.c
@@ -358,8 +358,7 @@ CURLMcode curl_multi_add_handle(CURLM *multi_handle,
    /* Prevent users from adding same easy handle more than once and prevent
       adding to more than one multi stack */
    if(data->multi)
-    /* possibly we should create a new unique error code for this condition */
-    return CURLM_BAD_EASY_HANDLE;
+    return CURLM_ADDED_ALREADY;
    /* Allocate and initialize timeout list for easy handle */
    timeoutlist = Curl_llist_alloc(multi_freetimeout);
diff --git a/lib/strerror.c b/lib/strerror.c
index a385f55..9e8c83f 100644
--- a/lib/strerror.c
+++ b/lib/strerror.c
@@ -5,7 +5,7 @@
   *                            | (__| |_| |  _ <| |___
   *                             \___|\___/|_| \_\_____|
   *
- * Copyright (C) 2004 - 2012, Daniel Stenberg, <daniel_at_haxx.se>, et al.
+ * Copyright (C) 2004 - 2013, Daniel Stenberg, <daniel_at_haxx.se>, et al.
   *
   * This software is licensed as described in the file COPYING, which
   * you should have received as part of this distribution. The terms
@@ -361,6 +361,9 @@ curl_multi_strerror(CURLMcode error)
    case CURLM_UNKNOWN_OPTION:
      return "Unknown option";
+  case CURLM_ADDED_ALREADY:
+    return "The easy handle is already added to a multi handle";
+
    case CURLM_LAST:
      break;
    }
-- 
1.8.4.rc3
-- 
  / daniel.haxx.se


-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html

Received on 2013-08-20