int HttpListener::setSockAttr( int fd, GSockAddr &addr ) { setfd( fd ); ::fcntl( fd, F_SETFD, FD_CLOEXEC ); ::fcntl( fd, F_SETFL, HttpGlobals::getMultiplexer()->getFLTag()); int nodelay = 1; //::setsockopt( fd, IPPROTO_TCP, TCP_NODELAY, &nodelay, sizeof( int ) ); #ifdef TCP_DEFER_ACCEPT ::setsockopt( fd, IPPROTO_TCP, TCP_DEFER_ACCEPT, &nodelay, sizeof( int ) ); #endif //int tos = IPTOS_THROUGHPUT; //setsockopt( fd, IPPROTO_IP, IP_TOS, &tos, sizeof( tos )); m_pMapVHost->setPort( addr.getPort() ); #ifdef SO_ACCEPTFILTER /* * FreeBSD accf_http filter */ struct accept_filter_arg arg; memset( &arg, 0, sizeof(arg) ); strcpy( arg.af_name, "httpready" ); if ( setsockopt(fd, SOL_SOCKET, SO_ACCEPTFILTER, &arg, sizeof(arg)) < 0) { if (errno != ENOENT) { LOG_NOTICE(( "Failed to set accept-filter 'httpready': %s", strerror(errno) )); } } #endif return HttpGlobals::getMultiplexer()->add( this, POLLIN|POLLHUP|POLLERR ); }