--- curl-7.10.6-share1/lib/share.c	Tue Aug  5 19:35:35 2003
+++ curl-7.10.6-share2/lib/share.c	Sun Aug 10 14:29:31 2003
@@ -39,8 +39,10 @@
 {
   struct Curl_share *share =
     (struct Curl_share *)malloc(sizeof(struct Curl_share));
-  if (share)
+  if (share) {
     memset (share, 0, sizeof(struct Curl_share));
+    share->specifier |= (1<<CURL_LOCK_DATA_SHARE);
+  }
 
   return share;
 }
@@ -145,11 +147,20 @@
   return CURLSHE_OK;
 }
 
-CURLSHcode curl_share_cleanup(CURLSH *sh)
+CURLSHcode
+curl_share_cleanup(CURLSH *sh)
 {
   struct Curl_share *share = (struct Curl_share *)sh;
-  if (share->dirty)
+  
+  if (share == NULL)
+    return CURLSHE_INVALID;
+  
+  share->lockfunc (NULL, CURL_LOCK_DATA_SHARE, CURL_LOCK_ACCESS_SINGLE, share->clientdata);
+  
+  if (share->dirty) {
+    share->unlockfunc (NULL, CURL_LOCK_DATA_SHARE, share->clientdata);
     return CURLSHE_IN_USE;
+  }
 
   if (share->hostcache) {
     Curl_hash_destroy(share->hostcache);
@@ -159,6 +170,7 @@
     Curl_cookie_cleanup(share->cookies);
   }
 
+  share->unlockfunc (NULL, CURL_LOCK_DATA_SHARE, share->clientdata);
   free (share);
   
   return CURLSHE_OK;

