Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
home:pchenthill
evolution-data-server
bgo-eds-336086-settz.diff
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File bgo-eds-336086-settz.diff of Package evolution-data-server
--- /home/palkris/icaltime.c 2006-12-21 15:49:09.000000000 +0530 +++ calendar/libical/src/libical/icaltime.c 2006-12-21 17:25:14.000000000 +0530 @@ -56,9 +56,6 @@ static pthread_mutex_t tzid_mutex = PTHREAD_MUTEX_INITIALIZER; #endif -static void release_saved_tz (); -static char * access_saved_tz (); - /* * Function to convert a struct tm time specification * to an ANSI time_t using the specified time zone. @@ -292,7 +289,8 @@ time_t icaltime_as_timet(const struct ic static char* saved_tz = NULL; /* If you use set_tz(), you must call unset_tz() some time later to restore the - original TZ. Pass unset_tz() the string that set_tz() returns. */ + original TZ. Pass unset_tz() the string that set_tz() returns. Call both the functions + locking the tzid mutex as in icaltime_as_timet_with_zone */ char* set_tz(const char* tzid) { char *old_tz, *old_tz_copy = NULL, *new_tz; @@ -327,14 +325,11 @@ char* set_tz(const char* tzid) /* Free any previous TZ environment string we have used in a synchronized manner. */ - if (access_saved_tz ()) - free (saved_tz); + free (saved_tz); /* Save a pointer to the TZ string we just set, so we can free it later. */ saved_tz = new_tz; - release_saved_tz (); - return old_tz_copy; /* This will be zero if the TZ env var was not set */ } @@ -358,15 +353,11 @@ void unset_tz(char *tzstr) } /* Free any previous TZ environment string we have used in a synchronized manner */ - - if (access_saved_tz ()) - free (saved_tz); + free (saved_tz); /* Save a pointer to the TZ string we just set, so we can free it later. (This can possibly be NULL if there was no TZ to restore.) */ saved_tz = tzstr; - - release_saved_tz (); } /** Return the time as seconds past the UNIX epoch, using the @@ -411,7 +402,13 @@ time_t icaltime_as_timet_with_zone(const stm.tm_mon = local_tt.month-1; stm.tm_year = local_tt.year-1900; stm.tm_isdst = -1; +/* The functions putenv and mktime are not thread safe, inserting a lock +to prevent any crashes */ +#ifdef HAVE_PTHREAD + pthread_mutex_lock (&tzid_mutex); +#endif + /* Set TZ to UTC and use mktime to convert to a time_t. */ old_tz = set_tz ("UTC"); #ifdef WIN32 @@ -423,6 +420,9 @@ time_t icaltime_as_timet_with_zone(const tzset (); #endif +#ifdef HAVE_PTHREAD + pthread_mutex_unlock (&tzid_mutex); +#endif return t; } @@ -1172,32 +1172,3 @@ int icaltime_span_contains(icaltime_span return 0; } -/* @brief gives access the static variable saved_tz synchronously - * @return The pointer to the saved_tz - * - */ - -static char * access_saved_tz () -{ - - #ifdef HAVE_PTHREAD - pthread_mutex_lock (&tzid_mutex); - #endif - return saved_tz; - -} - - -/* @brief releases the access to the static variable saved_tz synchronously - * - */ - -static void release_saved_tz () -{ - - #ifdef HAVE_PTHREAD - pthread_mutex_unlock (&tzid_mutex); - #endif - return; - -}
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor