X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=lib%2Fvlog.c;h=2587cdeda01e0356a79bc49c9d4d16b1c33b2fa7;hb=7106bb5e7be0db6ca67c61a5fcb66fac2735c42c;hp=31ba96e8102f79236c2523618f754118f3a6c421;hpb=989fd548031d532be32a10129e0c97d45fd98b9a;p=sliver-openvswitch.git diff --git a/lib/vlog.c b/lib/vlog.c index 31ba96e81..2587cdeda 100644 --- a/lib/vlog.c +++ b/lib/vlog.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012 Nicira, Inc. + * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013 Nicira, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -28,6 +28,7 @@ #include #include #include +#include "coverage.h" #include "dirs.h" #include "dynamic-string.h" #include "ofpbuf.h" @@ -40,6 +41,8 @@ VLOG_DEFINE_THIS_MODULE(vlog); +COVERAGE_DEFINE(vlog_recursive); + /* Name for each logging level. */ static const char *level_names[VLL_N_LEVELS] = { #define VLOG_LEVEL(NAME, SYSLOG_LEVEL) #NAME, @@ -952,13 +955,26 @@ static void vlog_write_file(struct ds *s) { if (worker_is_running()) { - worker_request(s->string, s->length, - &log_fd, vlog_async_inited ? 0 : 1, - vlog_async_write_request_cb, NULL, NULL); - vlog_async_inited = true; - } else { - ignore(write(log_fd, s->string, s->length)); + static bool in_worker_request = false; + if (!in_worker_request) { + in_worker_request = true; + + worker_request(s->string, s->length, + &log_fd, vlog_async_inited ? 0 : 1, + vlog_async_write_request_cb, NULL, NULL); + vlog_async_inited = true; + + in_worker_request = false; + return; + } else { + /* We've been entered recursively. This can happen if + * worker_request(), or a function that it calls, tries to log + * something. We can't call worker_request() recursively, so fall + * back to writing the log file directly. */ + COVERAGE_INC(vlog_recursive); + } } + ignore(write(log_fd, s->string, s->length)); } static void