From: David Scott Date: Wed, 28 Oct 2009 17:02:04 +0000 (+0000) Subject: Drop the runtime lock while calling syslog() in case it blocks for a long time. X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=214703c04ca35bbf1a3120854702656b5574940c;p=xcp%2Fxen-api-libs.git Drop the runtime lock while calling syslog() in case it blocks for a long time. The effect of writing synchronously to /var/log/messages has become much more noticable ever since we moved to a kernel with a fixed fsync(). Signed-off-by: David Scott --- diff --git a/log/syslog_stubs.c b/log/syslog_stubs.c index fa34684..4ecaa7a 100644 --- a/log/syslog_stubs.c +++ b/log/syslog_stubs.c @@ -55,11 +55,15 @@ value stub_openlog(value ident, value option, value facility) value stub_syslog(value facility, value level, value msg) { CAMLparam3(facility, level, msg); - int c_facility; + const char *c_msg = strdup(String_val(msg)); + int c_facility = __syslog_facility_table[Int_val(facility)] + | __syslog_level_table[Int_val(level)]; - c_facility = __syslog_facility_table[Int_val(facility)] - | __syslog_level_table[Int_val(level)]; - syslog(c_facility, "%s", String_val(msg)); + caml_enter_blocking_section(); + syslog(c_facility, "%s", c_msg); + caml_leave_blocking_section(); + + free(c_msg); CAMLreturn(Val_unit); }