Opened 18 years ago

Closed 18 years ago

#1589 closed defect (invalid)

Thread safe support for initialization of libcurl

Reported by: unicoletti Owned by: mapserverbugs
Priority: high Milestone:
Component: WMS Client Version: unspecified
Severity: normal Keywords:
Cc: sgillies@…

Description

The initialization of libcurl in mshttp.c is subject to a possible race
condition. The patch attached attempts to solve this problem by putting a lock
around it.
I am adding Sean as a cc because I see he is the mantainer of the thread safe
faq entry on the web site.

Attachments (1)

curl-ts.patch (2.0 KB ) - added by unicoletti 18 years ago.
Patch to safely lock libcurl while initializing

Download all attachments as: .zip

Change History (4)

by unicoletti, 18 years ago

Attachment: curl-ts.patch added

Patch to safely lock libcurl while initializing

comment:1 by unicoletti, 18 years ago

*** Bug 1588 has been marked as a duplicate of this bug. ***

comment:2 by unicoletti, 18 years ago

Checked out latest cvs version of mapserver and I have seen that curl
initialization has already been locked, so applying this patch is not necessary.

On a side note IMHO comparing mapserver code and mine I believe that my code
would be cleaner.
My code would be as follows:

    // Acquiring thread lock to prevent double initialization.
    // unicoletti@prometeo.it, Dec 2005
    int returnCode = MS_SUCCESS;

    msAcquireLock( TLOCK_CURL );
    if (!gbCurlInitialized &&
         curl_global_init(CURL_GLOBAL_ALL) != 0)
    {
         msSetError(MS_HTTPERR, "Libcurl initialization failed.",
                    "msHTTPInit()");
         returnCode = MS_FAILURE;
    } else 
    {
         gbCurlInitialized = MS_TRUE;
    }
    msReleaseLock( TLOCK_CURL );

    return returnCode;


comment:3 by unicoletti, 18 years ago

Resolution: invalid
Status: newclosed
Closing after 3 months.
Note: See TracTickets for help on using tickets.