set TCP_NODELAY on the mpd tcp socket

This commit is contained in:
Andrzej Rybczak
2014-08-31 12:24:09 +02:00
parent 40ef9070af
commit 37195d6bea
2 changed files with 7 additions and 1 deletions

View File

@@ -185,7 +185,7 @@ AC_CHECK_LIB(regex, regcomp, LDFLAGS="$LDFLAGS -lregex", )
dnl ================================
dnl = checking for various headers =
dnl ================================
AC_CHECK_HEADERS([dirent.h regex.h], , AC_MSG_ERROR(vital headers missing))
AC_CHECK_HEADERS([netinet/tcp.h netinet/in.h], , AC_MSG_ERROR(vital headers missing))
AC_CHECK_HEADERS([langinfo.h], , AC_MSG_WARN(locale detection disabled))
dnl ==============================

View File

@@ -22,6 +22,8 @@
#include <clocale>
#include <csignal>
#include <cstring>
#include <netinet/tcp.h>
#include <netinet/in.h>
#include <boost/locale.hpp>
#include <iostream>
@@ -177,6 +179,10 @@ int main(int argc, char **argv)
myPlaylist->main().highlight(curr_pos);
}
// Set TCP_NODELAY on the tcp socket as this significantly speeds up operations.
int flag = 1;
setsockopt(Mpd.GetFD(), IPPROTO_TCP, TCP_NODELAY, &flag, sizeof(flag));
// go to startup screen
if (Config.startup_screen_type != myScreen->type())
toScreen(Config.startup_screen_type)->switchTo();