diff -ur curl-7.19.3-20081216.orig/lib/multi.c curl-7.19.3-20081216.fix/lib/multi.c
--- curl-7.19.3-20081216.orig/lib/multi.c	2008-12-13 05:00:04.000000000 +0200
+++ curl-7.19.3-20081216.fix/lib/multi.c	2008-12-16 16:19:11.559621600 +0200
@@ -1670,6 +1670,8 @@
   curl_socket_t s;
   int num;
   unsigned int curraction;
+  struct Curl_one_easy *easy_by_hash;
+  bool remove_sock_from_hash;
 
   memset(&socks, 0, sizeof(socks));
   for(i=0; i< MAX_SOCKSPEREASYHANDLE; i++)
@@ -1737,21 +1739,62 @@
       }
     }
     if(s != CURL_SOCKET_BAD) {
+
       /* this socket has been removed. Remove it */
+      remove_sock_from_hash = TRUE;
 
       entry = Curl_hash_pick(multi->sockhash, (char *)&s, sizeof(s));
       if(entry) {
+        /* check if the socket to be removed serves the connection which has
+           other easy-s in pipelines. In this case the socket should not be
+           removed. */
+        easy_by_hash = entry->easy->multi_pos;
+        if(easy_by_hash->easy_conn) {
+           if (easy_by_hash->easy_conn->recv_pipe  &&
+               easy_by_hash->easy_conn->recv_pipe->size > 1) { /* the handle should not be removed from the pipe yet */
+
+             remove_sock_from_hash = FALSE;
+
+             /* Update the sockhash entry */
+             if (entry->easy == easy->easy_handle) {
+               if (isHandleAtHead(easy->easy_handle, easy_by_hash->easy_conn->recv_pipe))
+                 entry->easy = easy_by_hash->easy_conn->recv_pipe->head->next->ptr;
+               else
+                 entry->easy = easy_by_hash->easy_conn->recv_pipe->head->ptr;
+             }
+           }
+           if (easy_by_hash->easy_conn->send_pipe  &&
+               easy_by_hash->easy_conn->send_pipe->size > 1) { /* the handle should not be removed from the pipe yet */
+
+             remove_sock_from_hash = FALSE;
+             
+             if (entry->easy == easy->easy_handle) {
+               if (isHandleAtHead(easy->easy_handle, easy_by_hash->easy_conn->send_pipe))
+                 entry->easy = easy_by_hash->easy_conn->send_pipe->head->next->ptr;
+               else
+                 entry->easy = easy_by_hash->easy_conn->send_pipe->head->ptr;
+             }
+           }
+           /* Don't worry about overwriting recv_pipe head with send_pipe_head,
+              when action will be asked on the socket (see multi_socket()),
+              the head of the correct pipe will be taken according to the action. */
+        }
+      }
+      else
         /* just a precaution, this socket really SHOULD be in the hash already
            but in case it isn't, we don't have to tell the app to remove it
            either since it never got to know about it */
+        remove_sock_from_hash = FALSE;
+
+      if (remove_sock_from_hash == TRUE) {
         multi->socket_cb(easy->easy_handle,
                          s,
                          CURL_POLL_REMOVE,
                          multi->socket_userp,
                          entry ? entry->socketp : NULL);
-
         sh_delentry(multi->sockhash, s);
       }
+
     }
   }
 
@@ -1804,6 +1847,21 @@
         /* bad bad bad bad bad bad bad */
         return CURLM_INTERNAL_ERROR;
 
+      /* If the pipeline is enabled, take the handle which is in the head of
+         the pipeline. If we should write into the socket, take the send_pipe head.
+         If we should read from the socket, take the recv_pipe head. */
+      if(data->set.one_easy->easy_conn) {
+        if ((ev_bitmask & CURL_POLL_OUT) &&
+            data->set.one_easy->easy_conn->send_pipe &&
+            data->set.one_easy->easy_conn->send_pipe->head)
+          data = data->set.one_easy->easy_conn->send_pipe->head->ptr;
+        else
+        if ((ev_bitmask & CURL_POLL_IN) && 
+            data->set.one_easy->easy_conn->recv_pipe &&
+            data->set.one_easy->easy_conn->recv_pipe->head)
+          data = data->set.one_easy->easy_conn->recv_pipe->head->ptr;
+      }
+
       if(data->set.one_easy->easy_conn)  /* set socket event bitmask */
         data->set.one_easy->easy_conn->cselect_bits = ev_bitmask;
 
