Skip to content

Commit

Permalink
Added usecs to logging timestamp
Browse files Browse the repository at this point in the history
Cleaned up unnecessary warnings after writing to internal shutdown sockets
  • Loading branch information
ravelox committed May 14, 2020
1 parent 26fb7e2 commit 3298906
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 23 deletions.
8 changes: 7 additions & 1 deletion raveloxmidi/src/logging.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include <errno.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/time.h>
#include <pthread.h>

#include "config.h"
Expand Down Expand Up @@ -150,7 +151,12 @@ void logging_printf(int level, const char *format, ...)

if( ! prefix_disabled )
{
fprintf( logging_fp , "[%lu]\t[tid=%lu]\t%s: ", time( NULL ) , pthread_self(), logging_value_to_name( loglevel_map, level ) );
struct timeval tv;
struct timezone tz;

gettimeofday( &tv, &tz);

fprintf( logging_fp , "[%lu.%lu]\t[tid=%lu]\t%s: ", tv.tv_sec, tv.tv_usec, pthread_self(), logging_value_to_name( loglevel_map, level ) );
}

va_start(ap, format);
Expand Down
29 changes: 7 additions & 22 deletions raveloxmidi/src/net_socket.c
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,6 @@ int net_socket_read( int fd )
*/
} else if( ( fd == local_fd ) && ( midi_state_compare( found_socket->state, "QUIT", 4) == 0 ) )
{
int ret = 0;
const char *buffer="QT";
size_t bytes_written = 0;

Expand All @@ -493,16 +492,8 @@ int net_socket_read( int fd )

net_socket_set_shutdown_lock(1);

ret = write( shutdown_fd[0] , "X", 1 );
if( ret != 0 )
{
logging_printf( LOGGING_WARN, "net_socket_read: Unable to write to internal shutdown socket 0\n");
}
ret = write( shutdown_fd[1] , "X", 1 );
if( ret != 0 )
{
logging_printf( LOGGING_WARN, "net_socket_read: Unable to write to internal shutdown socket 1\n");
}
write( shutdown_fd[0] , "X", 1 );
write( shutdown_fd[1] , "X", 1 );

midi_state_advance( found_socket->state, 4);
/*
Expand Down Expand Up @@ -712,19 +703,13 @@ int net_socket_fd_loop()

void net_socket_loop_shutdown(int signal)
{
int ret = 0;
logging_printf(LOGGING_INFO, "net_socket_loop_shutdown: shutdown signal received(%u)\n", signal);

net_socket_set_shutdown_lock( 1 );
ret = write( shutdown_fd[0] , "X", 1 );
if( ret != 0 )
{
logging_printf( LOGGING_WARN, "net_socket_loop_shutdown: Unable to write to internal shutdown socket 0\n");
}
ret = write( shutdown_fd[1] , "X", 1 );
if( ret != 0 )
{
logging_printf( LOGGING_WARN, "net_socket_loop_shutdown: Unable to write to internal shutdown socket 1\n");
}

write( shutdown_fd[0] , "X", 1 );
write( shutdown_fd[1] , "X", 1 );

close( shutdown_fd[0] );
close( shutdown_fd[1] );
}
Expand Down

0 comments on commit 3298906

Please sign in to comment.