... | ... |
@@ -64,6 +64,7 @@ static struct fifo_command *cmd_list=0; |
64 | 64 |
|
65 | 65 |
/* up time */ |
66 | 66 |
static time_t up_since; |
67 |
+static char up_since_ctime[MAX_CTIME_LEN]; |
|
67 | 68 |
|
68 | 69 |
static struct fifo_command *lookup_fifo_cmd( char *name ) |
69 | 70 |
{ |
... | ... |
@@ -405,6 +406,8 @@ consume: |
405 | 406 |
|
406 | 407 |
int open_fifo_server() |
407 | 408 |
{ |
409 |
+ char *t; |
|
410 |
+ |
|
408 | 411 |
if (fifo==NULL) { |
409 | 412 |
DBG("TM: open_uac_fifo: no fifo will be opened\n"); |
410 | 413 |
/* everything is ok, we just do not want to start */ |
... | ... |
@@ -423,6 +426,13 @@ int open_fifo_server() |
423 | 426 |
} |
424 | 427 |
DBG("DEBUG: fifo %s opened, mode=%d\n", fifo, fifo_mode ); |
425 | 428 |
time(&up_since); |
429 |
+ t=ctime(&up_since); |
|
430 |
+ if (strlen(t)+1>=MAX_CTIME_LEN) { |
|
431 |
+ LOG(L_ERR, "ERROR: open_fifo_server: " |
|
432 |
+ "too long date %s\n", strlen(t)); |
|
433 |
+ return -1; |
|
434 |
+ } |
|
435 |
+ memcpy(up_since_ctime,t,strlen(t)+1); |
|
426 | 436 |
process_no++; |
427 | 437 |
fifo_pid=fork(); |
428 | 438 |
if (fifo_pid<0) { |
... | ... |
@@ -517,43 +527,8 @@ static int uptime_fifo_cmd( FILE *stream, char *response_file ) |
517 | 527 |
|
518 | 528 |
time(&now); |
519 | 529 |
fifo_reply( response_file, "Now: %sUp Since: %sUp time: %.0f [sec]\n", |
520 |
- ctime(&now), ctime(&up_since), difftime(now, up_since) ); |
|
521 |
- |
|
522 |
-#ifdef _OBSOLETED |
|
523 |
- |
|
524 |
- file=open_reply_pipe(response_file); |
|
525 |
- if (file==NULL) { |
|
526 |
- LOG(L_ERR, "ERROR: uptime_fifo_cmd: file %s bad: %s\n", |
|
527 |
- response_file, strerror(errno) ); |
|
528 |
- return -1; |
|
529 |
- } |
|
530 |
- |
|
531 |
- time(&now); |
|
530 |
+ ctime(&now), up_since_ctime, difftime(now, up_since) ); |
|
532 | 531 |
|
533 |
- r=fprintf(file, "Now: %s", ctime(&now) ); |
|
534 |
- r=1; |
|
535 |
- if (r<=0) { |
|
536 |
- printf("XXX: r: %d : %s\n", r, strerror(errno)); |
|
537 |
- goto done; |
|
538 |
- } |
|
539 |
- |
|
540 |
- r=fprintf(file, "Up since: %s", ctime(&up_since) ); |
|
541 |
- r=1; |
|
542 |
- if (r<=0) { |
|
543 |
- printf("XXX: r: %d : %s\n", r, strerror(errno)); |
|
544 |
- goto done; |
|
545 |
- } |
|
546 |
- r=fprintf(file, "Up time: %.0f [sec]\n", difftime(now, up_since)); |
|
547 |
- r=1; |
|
548 |
- if (r<=0) { |
|
549 |
- printf("XXX: r: %d : %s\n", r, strerror(errno)); |
|
550 |
- goto done; |
|
551 |
- } |
|
552 |
- |
|
553 |
-done: |
|
554 |
- |
|
555 |
- fclose(file); |
|
556 |
-#endif |
|
557 | 532 |
return 1; |
558 | 533 |
} |
559 | 534 |
|