mirror of
https://github.com/tuxbox-neutrino/neutrino.git
synced 2025-08-29 00:11:14 +02:00
copy Houdini fix from tuxcvs;-fix unsigned len >= 0 is always true
git-svn-id: file:///home/bas/coolstream_public_svn/THIRDPARTY/applications/neutrino-experimental@287 e54a6e83-5905-42d5-8d5c-058d10e6a962
This commit is contained in:
@@ -88,7 +88,7 @@ void CLogging::printf ( const char *fmt, ... )
|
|||||||
pthread_mutex_lock( &Log_mutex );
|
pthread_mutex_lock( &Log_mutex );
|
||||||
::printf(buffer);
|
::printf(buffer);
|
||||||
if(LogToFile)
|
if(LogToFile)
|
||||||
; //FIXME Logging to File
|
usleep(0); //FIXME Logging to File
|
||||||
pthread_mutex_unlock( &Log_mutex );
|
pthread_mutex_unlock( &Log_mutex );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
//=============================================================================
|
//=============================================================================
|
||||||
// YHTTPD
|
// YHTTPD
|
||||||
// Socket Class : Basic Socket Operations
|
// Socket Class : Basic Socket Operations
|
||||||
//=============================================================================
|
//=============================================================================
|
||||||
|
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
@@ -167,7 +167,7 @@ bool CySocket::listen(int port, int max_connections)
|
|||||||
{
|
{
|
||||||
if(sock == INVALID_SOCKET)
|
if(sock == INVALID_SOCKET)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// set sockaddr for listening
|
// set sockaddr for listening
|
||||||
sockaddr_in sai;
|
sockaddr_in sai;
|
||||||
memset(&sai, 0, sizeof(sai));
|
memset(&sai, 0, sizeof(sai));
|
||||||
@@ -200,7 +200,7 @@ CySocket* CySocket::accept()
|
|||||||
new_ySocket->set_option(IPPROTO_TCP, TCP_CORK);
|
new_ySocket->set_option(IPPROTO_TCP, TCP_CORK);
|
||||||
#else
|
#else
|
||||||
set_tcp_nodelay();
|
set_tcp_nodelay();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
new_ySocket->isOpened = true;
|
new_ySocket->isOpened = true;
|
||||||
// handling = true;
|
// handling = true;
|
||||||
@@ -301,7 +301,7 @@ int CySocket::Send(char const *buffer, unsigned int length)
|
|||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
len = ::send(sock, buffer, length, MSG_NOSIGNAL);
|
len = ::send(sock, buffer, length, MSG_NOSIGNAL);
|
||||||
if(len >= 0)
|
if(len > 0)
|
||||||
BytesSend += len;
|
BytesSend += len;
|
||||||
return len;
|
return len;
|
||||||
}
|
}
|
||||||
@@ -346,7 +346,7 @@ int CySocket::SendFile(int filed)
|
|||||||
#else
|
#else
|
||||||
char sbuf[1024];
|
char sbuf[1024];
|
||||||
unsigned int r=0;
|
unsigned int r=0;
|
||||||
while ((r=read(filed, sbuf, 1024)) > 0)
|
while ((r=read(filed, sbuf, 1024)) > 0)
|
||||||
{
|
{
|
||||||
if (Send(sbuf, r) < 0)
|
if (Send(sbuf, r) < 0)
|
||||||
{
|
{
|
||||||
@@ -355,7 +355,7 @@ int CySocket::SendFile(int filed)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif // Y_CONFIG_HAVE_SENDFILE
|
#endif // Y_CONFIG_HAVE_SENDFILE
|
||||||
log_level_printf(9,"<Sock:SendFile>: Bytes:%ld\n", BytesSend);
|
log_level_printf(9,"<Sock:SendFile>: Bytes:%ld\n", BytesSend);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
@@ -403,7 +403,7 @@ unsigned int CySocket::ReceiveFileGivenLength(int filed, unsigned int _length)
|
|||||||
{
|
{
|
||||||
isValid = false;
|
isValid = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
_readbytes += bytes_gotten;
|
_readbytes += bytes_gotten;
|
||||||
if (write(filed, buffer, bytes_gotten) != bytes_gotten)
|
if (write(filed, buffer, bytes_gotten) != bytes_gotten)
|
||||||
{
|
{
|
||||||
@@ -431,7 +431,7 @@ std::string CySocket::ReceiveBlock()
|
|||||||
return "";
|
return "";
|
||||||
// signal(SIGALRM, ytimeout);
|
// signal(SIGALRM, ytimeout);
|
||||||
alarm(1);
|
alarm(1);
|
||||||
|
|
||||||
while(true)
|
while(true)
|
||||||
{
|
{
|
||||||
// check bytes in Socket buffer
|
// check bytes in Socket buffer
|
||||||
@@ -452,7 +452,7 @@ std::string CySocket::ReceiveBlock()
|
|||||||
}
|
}
|
||||||
// Read data
|
// Read data
|
||||||
int bytes_gotten = Read(buffer, readarg);
|
int bytes_gotten = Read(buffer, readarg);
|
||||||
|
|
||||||
if(bytes_gotten == -1 && errno == EINTR)// non-blocking
|
if(bytes_gotten == -1 && errno == EINTR)// non-blocking
|
||||||
continue;
|
continue;
|
||||||
if(bytes_gotten <= 0) // ERROR Code gotten or Conection closed by peer
|
if(bytes_gotten <= 0) // ERROR Code gotten or Conection closed by peer
|
||||||
@@ -464,7 +464,7 @@ std::string CySocket::ReceiveBlock()
|
|||||||
if((u_long)bytes_gotten < readarg) // no more bytes
|
if((u_long)bytes_gotten < readarg) // no more bytes
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
alarm(0);
|
alarm(0);
|
||||||
signal(SIGALRM,SIG_IGN);
|
signal(SIGALRM,SIG_IGN);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@@ -481,7 +481,7 @@ std::string CySocket::ReceiveLine()
|
|||||||
|
|
||||||
while(true)
|
while(true)
|
||||||
{
|
{
|
||||||
// read one char
|
// read one char
|
||||||
if(Read(buffer+bytes_gotten, 1) == 1)
|
if(Read(buffer+bytes_gotten, 1) == 1)
|
||||||
{
|
{
|
||||||
if(buffer[bytes_gotten] == '\n')
|
if(buffer[bytes_gotten] == '\n')
|
||||||
@@ -500,6 +500,6 @@ std::string CySocket::ReceiveLine()
|
|||||||
}
|
}
|
||||||
buffer[++bytes_gotten] = '\0';
|
buffer[++bytes_gotten] = '\0';
|
||||||
result.assign(buffer, bytes_gotten);
|
result.assign(buffer, bytes_gotten);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@@ -76,46 +76,46 @@ typedef struct
|
|||||||
} HttpEnumString;
|
} HttpEnumString;
|
||||||
|
|
||||||
static const HttpEnumString httpResponseNames[] = {
|
static const HttpEnumString httpResponseNames[] = {
|
||||||
{ HTTP_CONTINUE, "Continue" },
|
{ HTTP_CONTINUE, "Continue", "" },
|
||||||
{ HTTP_SWITCHING_PROTOCOLS, "Switching Protocols" },
|
{ HTTP_SWITCHING_PROTOCOLS, "Switching Protocols", "" },
|
||||||
{ HTTP_OK, "OK" },
|
{ HTTP_OK, "OK", "" },
|
||||||
{ HTTP_CREATED, "Created" },
|
{ HTTP_CREATED, "Created", "" },
|
||||||
{ HTTP_ACCEPTED, "Accepted" },
|
{ HTTP_ACCEPTED, "Accepted", "" },
|
||||||
{ HTTP_NON_AUTHORITATIVE_INFO, "No Authorative Info" },
|
{ HTTP_NON_AUTHORITATIVE_INFO, "No Authorative Info", "" },
|
||||||
{ HTTP_NO_CONTENT, "No Content" },
|
{ HTTP_NO_CONTENT, "No Content", "" },
|
||||||
{ HTTP_RESET_CONTENT, "Reset Content" },
|
{ HTTP_RESET_CONTENT, "Reset Content", "" },
|
||||||
{ HTTP_PARTIAL_CONTENT, "Partial Content" },
|
{ HTTP_PARTIAL_CONTENT, "Partial Content", "" },
|
||||||
{ HTTP_MULTIBLE_CHOICES, "Multiple Choices" },
|
{ HTTP_MULTIBLE_CHOICES, "Multiple Choices", "" },
|
||||||
{ HTTP_MOVED_PERMANENTLY, "Moved Permanently" },
|
{ HTTP_MOVED_PERMANENTLY, "Moved Permanently", "" },
|
||||||
{ HTTP_MOVED_TEMPORARILY, "Moved Temporarily" },
|
{ HTTP_MOVED_TEMPORARILY, "Moved Temporarily", "" },
|
||||||
{ HTTP_SEE_OTHER, "See Other" },
|
{ HTTP_SEE_OTHER, "See Other", "" },
|
||||||
{ HTTP_NOT_MODIFIED, "Not Modified" },
|
{ HTTP_NOT_MODIFIED, "Not Modified", "" },
|
||||||
{ HTTP_USE_PROXY, "Use Proxy" },
|
{ HTTP_USE_PROXY, "Use Proxy", "" },
|
||||||
{ HTTP_TEMPORARY_REDIRECT, "Temporary Redirect" },
|
{ HTTP_TEMPORARY_REDIRECT, "Temporary Redirect", "" },
|
||||||
{ HTTP_BAD_REQUEST, "Bad Request", "Unsupported method." },
|
{ HTTP_BAD_REQUEST, "Bad Request", "Unsupported method." },
|
||||||
{ HTTP_UNAUTHORIZED, "Unauthorized", "Access denied." },
|
{ HTTP_UNAUTHORIZED, "Unauthorized", "Access denied."},
|
||||||
{ HTTP_PAYMENT_REQUIRED, "Payment Required" },
|
{ HTTP_PAYMENT_REQUIRED, "Payment Required", "" },
|
||||||
{ HTTP_FORBIDDEN, "Forbidden", "" },
|
{ HTTP_FORBIDDEN, "Forbidden", "" },
|
||||||
{ HTTP_NOT_FOUND, "Not Found", "The requested URL was not found on this server." },
|
{ HTTP_NOT_FOUND, "Not Found", "The requested URL was not found on this server." },
|
||||||
{ HTTP_METHOD_NOT_ALLOWED, "Method Not Allowed" },
|
{ HTTP_METHOD_NOT_ALLOWED, "Method Not Allowed", "" },
|
||||||
{ HTTP_NOT_ACCEPTABLE, "Not Acceptable" },
|
{ HTTP_NOT_ACCEPTABLE, "Not Acceptable", "" },
|
||||||
{ HTTP_PROXY_AUTHENTICATION_REQUIRED,"Proxy Authentication Required" },
|
{ HTTP_PROXY_AUTHENTICATION_REQUIRED, "Proxy Authentication Required", "" },
|
||||||
{ HTTP_REQUEST_TIMEOUT, "Request Time-out" },
|
{ HTTP_REQUEST_TIMEOUT, "Request Time-out", "" },
|
||||||
{ HTTP_CONFLICT, "Conflict" },
|
{ HTTP_CONFLICT, "Conflict", "" },
|
||||||
{ HTTP_GONE, "Gone" },
|
{ HTTP_GONE, "Gone", "" },
|
||||||
{ HTTP_LENGTH_REQUIRED, "Length Required" },
|
{ HTTP_LENGTH_REQUIRED, "Length Required", "" },
|
||||||
{ HTTP_PRECONDITION_FAILED, "Precondition Failed" },
|
{ HTTP_PRECONDITION_FAILED, "Precondition Failed", "" },
|
||||||
{ HTTP_REQUEST_ENTITY_TOO_LARGE,"Request Entity Too Large" },
|
{ HTTP_REQUEST_ENTITY_TOO_LARGE, "Request Entity Too Large", "" },
|
||||||
{ HTTP_REQUEST_URI_TOO_LARGE, "Request-URI Too Large" },
|
{ HTTP_REQUEST_URI_TOO_LARGE, "Request-URI Too Large", "" },
|
||||||
{ HTTP_UNSUPPORTED_MEDIA_TYPE, "Unsupported Media Type" },
|
{ HTTP_UNSUPPORTED_MEDIA_TYPE, "Unsupported Media Type", "" },
|
||||||
{ HTTP_REQUEST_RANGE_NOT_SATISFIABLE,"Requested range not satisfiable" },
|
{ HTTP_REQUEST_RANGE_NOT_SATISFIABLE, "Requested range not satisfiable", "" },
|
||||||
{ HTTP_EXPECTAION_FAILED, "Expectation Failed" },
|
{ HTTP_EXPECTAION_FAILED, "Expectation Failed", "" },
|
||||||
{ HTTP_INTERNAL_SERVER_ERROR, "Internal Server Error", "Internal Server Error" },
|
{ HTTP_INTERNAL_SERVER_ERROR, "Internal Server Error", "Internal Server Error" },
|
||||||
{ HTTP_NOT_IMPLEMENTED, "Not Implemented", "The requested method is not recognized by this server." },
|
{ HTTP_NOT_IMPLEMENTED, "Not Implemented", "The requested method is not recognized by this server." },
|
||||||
{ HTTP_BAD_GATEWAY, "Bad Gateway" },
|
{ HTTP_BAD_GATEWAY, "Bad Gateway", "" },
|
||||||
{ HTTP_SERVICE_UNAVAILABLE, "Service Unavailable" },
|
{ HTTP_SERVICE_UNAVAILABLE, "Service Unavailable", "" },
|
||||||
{ HTTP_GATEWAY_TIMEOUT, "Gateway Time-out" },
|
{ HTTP_GATEWAY_TIMEOUT, "Gateway Time-out", "" },
|
||||||
{ HTTP_HTTP_VERSION_NOT_SUPPORTED,"HTTP Version not supported" },
|
{ HTTP_HTTP_VERSION_NOT_SUPPORTED, "HTTP Version not supported", "" },
|
||||||
};
|
};
|
||||||
|
|
||||||
// HTTP-methods
|
// HTTP-methods
|
||||||
|
Reference in New Issue
Block a user