From: Andre Noll Date: Sat, 19 Dec 2009 12:18:49 +0000 (+0100) Subject: Merge remote branch 'fml/master' X-Git-Tag: v0.4.1~5^2~15 X-Git-Url: http://git.tuebingen.mpg.de/?p=paraslash.git;a=commitdiff_plain;h=01dfe58862bc84934fcd88d3110670be1dcee4fa;hp=63c4f3404cfb3aea943949d81b03bca14dbea559 Merge remote branch 'fml/master' --- diff --git a/Makefile.in b/Makefile.in index f1cf1e40..e4a3dd3f 100644 --- a/Makefile.in +++ b/Makefile.in @@ -188,16 +188,13 @@ $(object_dir)/%.o: %.c | $(object_dir) @[ -z "$(Q)" ] || echo 'CC $<' $(Q) $(CC) -c -o $@ $(CPPFLAGS) $(DEBUG_CPPFLAGS) $< -# We depend on the *.cmdline.[ch] files as these must be present for depend.sh -# to work. The first dependency is explititly given as it is used by $<. - -$(object_dir)/%.cmdline.d: %.cmdline.c $(cmdline_generated) | $(object_dir) +$(object_dir)/%.cmdline.d: $(cmdline_dir)/%.cmdline.c | $(object_dir) @[ -z "$(Q)" ] || echo 'DEP $<' - $(Q) ./depend.sh $(object_dir) $(CPPFLAGS) $< > $@ + $(Q) ./depend.sh $(object_dir) $(cmdline_dir) $(CPPFLAGS) $< > $@ -$(object_dir)/%.d: %.c $(cmdline_generated) | $(object_dir) +$(object_dir)/%.d: %.c | $(object_dir) @[ -z "$(Q)" ] || echo 'DEP $<' - $(Q) ./depend.sh $(object_dir) $(CPPFLAGS) $< > $@ + $(Q) ./depend.sh $(object_dir) $(cmdline_dir) $(CPPFLAGS) $< > $@ recv_objs := $(addprefix $(object_dir)/, @recv_objs@) filter_objs := $(addprefix $(object_dir)/, @filter_objs@) @@ -211,7 +208,7 @@ write_objs := $(addprefix $(object_dir)/, @write_objs@) afh_objs := $(addprefix $(object_dir)/, @afh_objs@) all_objs := $(recv_objs) $(filter_objs) $(client_objs) $(gui_objs) \ - $(audiod_objs ) $(audioc_objs) $(fade_objs) $(server_objs) \ + $(audiod_objs) $(audioc_objs) $(fade_objs) $(server_objs) \ $(write_objs) $(afh_objs) -include $(all_objs:.o=.d) diff --git a/NEWS b/NEWS index 25f1e915..4fe1f2bf 100644 --- a/NEWS +++ b/NEWS @@ -8,8 +8,10 @@ NEWS Support for another audio format and bug fixes: All fixes that have been accumulated in the 0.3.6 release appear in this release as well. - - wma support - - new afh option: --human to activate human-readable output + - wma support. + - new afh option: --human to activate human-readable output. + - new server/audiod option: --log-timing to print timing information. + - build system improvments. ------------------------------------- 0.3.6 (2009-12-07) "cubic continuity" diff --git a/audiod.c b/audiod.c index e0a455d2..395a14d3 100644 --- a/audiod.c +++ b/audiod.c @@ -1207,6 +1207,8 @@ int main(int argc, char *argv[]) daemon_set_flag(DF_LOG_TIME); daemon_set_flag(DF_LOG_HOSTNAME); daemon_set_flag(DF_LOG_LL); + if (conf.log_timing_given) + daemon_set_flag(DF_LOG_TIMING); if (conf.logfile_given) { daemon_set_logfile(conf.logfile_arg); daemon_open_log_or_die(); diff --git a/daemon.c b/daemon.c index c855daa1..a669482f 100644 --- a/daemon.c +++ b/daemon.c @@ -10,6 +10,8 @@ #include #include /* getgrnam() */ #include +#include +#include #include "para.h" #include "daemon.h" @@ -141,7 +143,7 @@ void daemon_clear_flag(unsigned flag) me->flags &= ~flag; } -static unsigned daemon_test_flag(unsigned flag) +static bool daemon_test_flag(unsigned flag) { return me->flags & flag; } @@ -332,8 +334,9 @@ __printf_2_3 void para_log(int ll, const char* fmt,...) va_list argp; FILE *fp; struct tm *tm; - time_t t1; char *color; + bool log_time = daemon_test_flag(DF_LOG_TIME), log_timing = + daemon_test_flag(DF_LOG_TIMING); ll = PARA_MIN(ll, NUM_LOGLEVELS - 1); ll = PARA_MAX(ll, LL_DEBUG); @@ -344,12 +347,18 @@ __printf_2_3 void para_log(int ll, const char* fmt,...) color = daemon_test_flag(DF_COLOR_LOG)? me->log_colors[ll] : NULL; if (color) fprintf(fp, "%s", color); - if (daemon_test_flag(DF_LOG_TIME)) { /* print date and time */ - char str[100]; - time(&t1); - tm = localtime(&t1); - strftime(str, sizeof(str), "%b %d %H:%M:%S", tm); - fprintf(fp, "%s ", str); + if (log_time || log_timing) { + struct timeval tv; + gettimeofday(&tv, NULL); + if (daemon_test_flag(DF_LOG_TIME)) { /* print date and time */ + time_t t1 = tv.tv_sec; + char str[100]; + tm = localtime(&t1); + strftime(str, sizeof(str), "%b %d %H:%M:%S", tm); + fprintf(fp, "%s%s", str, log_timing? ":" : " "); + } + if (log_timing) /* print milliseconds */ + fprintf(fp, "%04lu ", (long unsigned)tv.tv_usec / 1000); } if (daemon_test_flag(DF_LOG_HOSTNAME)) { if (!me->hostname) diff --git a/daemon.h b/daemon.h index c8dd997f..3705b9da 100644 --- a/daemon.h +++ b/daemon.h @@ -29,4 +29,6 @@ enum daemon_flags { DF_LOG_LL = 8, /** Use colored output. */ DF_COLOR_LOG = 16, + /** Include milliseconds in log output. */ + DF_LOG_TIMING = 32 }; diff --git a/depend.sh b/depend.sh index db32f6c6..aad45a3c 100755 --- a/depend.sh +++ b/depend.sh @@ -1,4 +1,22 @@ #!/bin/sh -dir="$1" + +# Call gcc to output a rule suitable for make describing the dependencies of +# the given input file and parse the output to add a *.d target with the same +# dependencies. + +# The first two arguments to that script are special: $1 is the object +# directory. This string is prefixed to both the .o and the .d target. $2 is +# the directory that contains the *.cmdline.h files generated by gengetopt. + +# As gcc outputs the dependencies on the *.cmdline.h files either as either +# foo.cmdline.h or as $cmdline_dir/foo,cmdline.h, depending on whether the +# latter file exists, we prefix the former with $2/ + +object_dir="$1" +cmdline_dir="$2" shift -gcc -MM -MG "$@" | sed -e "s@^\(.*\)\.o:@$dir/\1.d $dir/\1.o:@" +shift + +LC_ALL=C gcc -MM -MG "$@" \ + | sed -e "s@^\(.*\)\.o:@$object_dir/\1.d $object_dir/\1.o:@" \ + -e "s@[ ^]\([a-zA-Z0-9_]\+\.cmdline.h\)@ $cmdline_dir/\1@g" diff --git a/ggo/audiod.m4 b/ggo/audiod.m4 index 29bce100..7ff8806c 100644 --- a/ggo/audiod.m4 +++ b/ggo/audiod.m4 @@ -12,6 +12,7 @@ include(loglevel.m4) include(color.m4) include(config_file.m4) include(logfile.m4) +include(log_timing.m4) include(daemon.m4) include(user.m4) include(group.m4) diff --git a/ggo/log_timing.m4 b/ggo/log_timing.m4 new file mode 100644 index 00000000..ac0ea841 --- /dev/null +++ b/ggo/log_timing.m4 @@ -0,0 +1,12 @@ + +option "log-timing" T +#~~~~~~~~~~~~~~~~~~~~ +"show milliseconds in log messages" +flag off +details = " + Selecting this option causes milliseconds to be included in + the log message output. This allows to measure the interval + between log messages in milliseconds which is useful for + identifying timing problems. +" + diff --git a/ggo/makefile b/ggo/makefile index d7bfc4fb..d4f3a8cd 100644 --- a/ggo/makefile +++ b/ggo/makefile @@ -50,7 +50,7 @@ $(ggo_dir)/server.ggo $(ggo_dir)/audiod.ggo: \ $(ggo_dir)/loglevel.m4 $(ggo_dir)/color.m4 \ $(ggo_dir)/config_file.m4 $(ggo_dir)/logfile.m4 \ $(ggo_dir)/daemon.m4 $(ggo_dir)/user.m4 \ - $(ggo_dir)/group.m4 + $(ggo_dir)/group.m4 $(ggo_dir)/log_timing.m4 $(ggo_dir)/afh.ggo: $(ggo_dir)/loglevel.m4 $(ggo_dir)/audioc.ggo: $(ggo_dir)/loglevel.m4 diff --git a/ggo/server.m4 b/ggo/server.m4 index df943575..4be4e2c9 100644 --- a/ggo/server.m4 +++ b/ggo/server.m4 @@ -9,6 +9,7 @@ section "General options" include(loglevel.m4) +include(log_timing.m4) include(color.m4) include(daemon.m4) include(user.m4) diff --git a/http_send.c b/http_send.c index 3959cad4..6ededb27 100644 --- a/http_send.c +++ b/http_send.c @@ -135,7 +135,7 @@ static void http_post_select(fd_set *rfds, __a_unused fd_set *wfds) phsd->status = HTTP_CONNECTED; } -static void http_pre_select(int *max_fileno, fd_set *rfds, __a_unused fd_set *wfds) +static void http_pre_select(int *max_fileno, fd_set *rfds, fd_set *wfds) { struct sender_client *sc, *tmp; @@ -146,6 +146,9 @@ static void http_pre_select(int *max_fileno, fd_set *rfds, __a_unused fd_set *wf struct private_http_sender_data *phsd = sc->private_data; if (phsd->status == HTTP_CONNECTED) /* need to recv get request */ para_fd_set(sc->fd, rfds, max_fileno); + if (phsd->status == HTTP_GOT_GET_REQUEST || + phsd->status == HTTP_INVALID_GET_REQUEST) + para_fd_set(sc->fd, wfds, max_fileno); } } diff --git a/server.c b/server.c index f7aad898..d9cd1fd4 100644 --- a/server.c +++ b/server.c @@ -243,6 +243,8 @@ void parse_config_or_die(int override) daemon_set_flag(DF_LOG_PID); daemon_set_flag(DF_LOG_LL); daemon_set_flag(DF_LOG_TIME); + if (conf.log_timing_given) + daemon_set_flag(DF_LOG_TIMING); ret = 1; out: free(cf);