]> xenbits.xensource.com Git - xcp/xen-api-libs.git/commitdiff
Drop the runtime lock while calling syslog() in case it blocks for a long time.
authorDavid Scott <dave.scott@eu.citrix.com>
Wed, 28 Oct 2009 17:02:04 +0000 (17:02 +0000)
committerDavid Scott <dave.scott@eu.citrix.com>
Wed, 28 Oct 2009 17:02:04 +0000 (17:02 +0000)
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 <dave.scott@eu.citrix.com>
log/syslog_stubs.c

index fa34684774ae0eef5e0356fe64e437b11caf109a..4ecaa7a057d052fbafbb7882bc26d34b4af0b7a6 100644 (file)
@@ -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);
 }