From: Paolo Bonzini <pbonzini@redhat.com>
To: Wenchao Xia <xiawenc@linux.vnet.ibm.com>
Cc: stefanha@gmail.com, aliguori@us.ibm.com, qemu-devel@nongnu.org,
quintela@redhat.com
Subject: Re: [Qemu-devel] [PATCH 1/2] oslib-win32: add lock for gmtime_r()
Date: Wed, 09 Jan 2013 10:47:26 +0100 [thread overview]
Message-ID: <50ED3CAE.8010006@redhat.com> (raw)
In-Reply-To: <1357712290-16496-1-git-send-email-xiawenc@linux.vnet.ibm.com>
Il 09/01/2013 07:18, Wenchao Xia ha scritto:
> Also changed the caller of gmtime() to gmtime_r().
Should be a separate patch.
Also, what is the reason to add this lock? They are already protected
by the BQL.
Paolo
> Signed-off-by: Wenchao Xia <xiawenc@linux.vnet.ibm.com>
> ---
> oslib-win32.c | 6 +++++-
> vl.c | 4 ++--
> 2 files changed, 7 insertions(+), 3 deletions(-)
>
> diff --git a/oslib-win32.c b/oslib-win32.c
> index e7e283e..74e0c52 100644
> --- a/oslib-win32.c
> +++ b/oslib-win32.c
> @@ -32,6 +32,8 @@
> #include "trace.h"
> #include "qemu/sockets.h"
>
> +static GStaticMutex time_lock = G_STATIC_MUTEX_INIT;
> +
> void *qemu_oom_check(void *ptr)
> {
> if (ptr == NULL) {
> @@ -74,15 +76,17 @@ void qemu_vfree(void *ptr)
> VirtualFree(ptr, 0, MEM_RELEASE);
> }
>
> -/* FIXME: add proper locking */
> +/* FIXME: add proper locking in MinGW */
> struct tm *gmtime_r(const time_t *timep, struct tm *result)
> {
> + g_static_mutex_lock(&time_lock);
> struct tm *p = gmtime(timep);
> memset(result, 0, sizeof(*result));
> if (p) {
> *result = *p;
> p = result;
> }
> + g_static_mutex_unlock(&time_lock);
> return p;
> }
>
> diff --git a/vl.c b/vl.c
> index 79e5122..8d7864c 100644
> --- a/vl.c
> +++ b/vl.c
> @@ -454,12 +454,12 @@ void qemu_get_timedate(struct tm *tm, int offset)
> ti += offset;
> if (rtc_date_offset == -1) {
> if (rtc_utc)
> - ret = gmtime(&ti);
> + ret = gmtime_r(&ti, tm);
> else
> ret = localtime(&ti);
> } else {
> ti -= rtc_date_offset;
> - ret = gmtime(&ti);
> + ret = gmtime_r(&ti, tm);
> }
>
> memcpy(tm, ret, sizeof(struct tm));
>
next prev parent reply other threads:[~2013-01-09 9:47 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-01-09 6:18 [Qemu-devel] [PATCH 1/2] oslib-win32: add lock for gmtime_r() Wenchao Xia
2013-01-09 6:18 ` [Qemu-devel] [PATCH 2/2] oslib-win32: add lock for localtime_r() Wenchao Xia
2013-01-09 9:47 ` Paolo Bonzini [this message]
2013-01-09 17:06 ` [Qemu-devel] [PATCH 1/2] oslib-win32: add lock for gmtime_r() Stefan Weil
2013-01-10 3:03 ` Wenchao Xia
2013-01-10 6:22 ` Stefan Weil
2013-01-10 3:01 ` Wenchao Xia
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=50ED3CAE.8010006@redhat.com \
--to=pbonzini@redhat.com \
--cc=aliguori@us.ibm.com \
--cc=qemu-devel@nongnu.org \
--cc=quintela@redhat.com \
--cc=stefanha@gmail.com \
--cc=xiawenc@linux.vnet.ibm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).