X-Git-Url: http://git.eversberg.eu/gitweb.cgi?p=lcr.git;a=blobdiff_plain;f=trace.c;h=a810d8cb7f1379868498fdd87191c3280894dfa7;hp=73686ff7de0caeb84f31b3e7f741e58153d4efd9;hb=ca68dbb3a581cd9b4b89253aa2a418721f993f72;hpb=e9bfe48fc5254e79e59c6ffc1698912175edf4e3 diff --git a/trace.c b/trace.c index 73686ff..a810d8c 100644 --- a/trace.c +++ b/trace.c @@ -22,6 +22,8 @@ static const char *spaces = " "; */ void _start_trace(const char *__file, int __line, int port, struct interface *interface, const char *caller, const char *dialing, int direction, int category, int serial, const char *name) { + struct timeval current_time; + if (trace.name[0]) PERROR("trace already started (name=%s) in file %s line %d\n", trace.name, __file, __line); memset(&trace, 0, sizeof(struct trace)); @@ -39,8 +41,9 @@ void _start_trace(const char *__file, int __line, int port, struct interface *in SCPY(trace.name, name); if (!trace.name[0]) SCPY(trace.name, ""); - trace.sec = now_tv.tv_sec; - trace.usec = now_tv.tv_usec; + gettimeofday(¤t_time, NULL); + trace.sec = current_time.tv_sec; + trace.usec = current_time.tv_usec; } @@ -261,6 +264,7 @@ void _end_trace(const char *__file, int __line) FILE *fp; struct admin_list *admin; struct admin_queue *response, **responsep; /* response pointer */ + int ret; if (!trace.name[0]) PERROR("trace not started in file %s line %d\n", __file, __line); @@ -270,12 +274,12 @@ void _end_trace(const char *__file, int __line) if (string) { /* process debug */ if (options.deb) - debug(NULL, 0, "trace", string); + debug(NULL, 0, "TRACE", string); /* process log */ if (options.log[0]) { fp = fopen(options.log, "a"); if (fp) { - fwrite(string, strlen(string), 1, fp); + ret = fwrite(string, strlen(string), 1, fp); fclose(fp); } } @@ -307,6 +311,7 @@ void _end_trace(const char *__file, int __line) /* attach to response chain */ *responsep = response; responsep = &response->next; + admin->fd.when |= LCR_FD_WRITE; } } admin = admin->next;