1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-03-26 10:42:26 +01:00

* Don't steal the logfile when starting a secondary instance of Tomahawk.

This commit is contained in:
Christian Muehlhaeuser 2011-06-21 05:40:07 +02:00
parent eb70419203
commit 4006452d15
2 changed files with 31 additions and 22 deletions

View File

@ -86,7 +86,8 @@
using namespace std;
ofstream logfile;
void TomahawkLogHandler( QtMsgType type, const char *msg )
void
TomahawkLogHandler( QtMsgType type, const char *msg )
{
static QMutex s_mutex;
@ -120,7 +121,8 @@ void TomahawkLogHandler( QtMsgType type, const char *msg )
logfile.flush();
}
void setupLogfile()
void
setupLogfile()
{
if ( QFileInfo( LOGFILE ).size() > LOGFILE_SIZE )
{
@ -146,6 +148,28 @@ void setupLogfile()
qInstallMsgHandler( TomahawkLogHandler );
}
void
increaseMaxFileDescriptors()
{
#ifdef Q_WS_MAC
/// Following code taken from Clementine project, main.cpp. Thanks!
// Bump the soft limit for the number of file descriptors from the default of 256 to
// the maximum (usually 1024).
struct rlimit limit;
getrlimit( RLIMIT_NOFILE, &limit );
// getrlimit() lies about the hard limit so we have to check sysctl.
int max_fd = 0;
size_t len = sizeof( max_fd );
sysctlbyname( "kern.maxfilesperproc", &max_fd, &len, NULL, 0 );
limit.rlim_cur = max_fd;
int ret = setrlimit( RLIMIT_NOFILE, &limit );
if ( ret == 0 )
qDebug() << "Max fd:" << max_fd;
#endif
}
using namespace Tomahawk;
@ -158,12 +182,13 @@ TomahawkApp::TomahawkApp( int& argc, char *argv[] )
setApplicationName( QLatin1String( TOMAHAWK_APPLICATION_NAME ) );
setApplicationVersion( QLatin1String( TOMAHAWK_VERSION ) );
registerMetaTypes();
setupLogfile();
}
void
TomahawkApp::init()
{
setupLogfile();
qsrand( QTime( 0, 0, 0 ).secsTo( QTime::currentTime() ) );
#ifdef TOMAHAWK_HEADLESS
@ -222,24 +247,7 @@ TomahawkApp::init()
Tomahawk::setShortcutHandler( static_cast<MacShortcutHandler*>( m_shortcutHandler.data() ) );
Tomahawk::setApplicationHandler( this );
/// Following code taken from Clementine project, main.cpp. Thanks!
// Bump the soft limit for the number of file descriptors from the default of 256 to
// the maximum (usually 1024).
struct rlimit limit;
getrlimit(RLIMIT_NOFILE, &limit);
// getrlimit() lies about the hard limit so we have to check sysctl.
int max_fd = 0;
size_t len = sizeof(max_fd);
sysctlbyname("kern.maxfilesperproc", &max_fd, &len, NULL, 0);
limit.rlim_cur = max_fd;
int ret = setrlimit(RLIMIT_NOFILE, &limit);
if (ret == 0) {
qDebug() << "Max fd:" << max_fd;
}
increaseMaxFileDescriptors();
#endif
// Connect up shortcuts

View File

@ -105,9 +105,10 @@ private slots:
void setupSIP();
private:
void registerMetaTypes();
void initLocalCollection();
void loadPlugins();
void registerMetaTypes();
void startServent();
void setupDatabase();
void setupPipeline();