From 184d009ca6adb260afa38b5c4b0738dfba41b4a3 Mon Sep 17 00:00:00 2001 From: satbaby Date: Sat, 6 Feb 2010 20:55:55 +0000 Subject: [PATCH] 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 --- src/nhttpd/yhttpd_core/ylogging.cpp | 2 +- src/nhttpd/yhttpd_core/ysocket.cpp | 24 ++++---- src/nhttpd/yhttpd_core/ytypes_globals.h | 80 ++++++++++++------------- 3 files changed, 53 insertions(+), 53 deletions(-) diff --git a/src/nhttpd/yhttpd_core/ylogging.cpp b/src/nhttpd/yhttpd_core/ylogging.cpp index 2663665ba..d88d98311 100644 --- a/src/nhttpd/yhttpd_core/ylogging.cpp +++ b/src/nhttpd/yhttpd_core/ylogging.cpp @@ -88,7 +88,7 @@ void CLogging::printf ( const char *fmt, ... ) pthread_mutex_lock( &Log_mutex ); ::printf(buffer); if(LogToFile) - ; //FIXME Logging to File + usleep(0); //FIXME Logging to File pthread_mutex_unlock( &Log_mutex ); } diff --git a/src/nhttpd/yhttpd_core/ysocket.cpp b/src/nhttpd/yhttpd_core/ysocket.cpp index 51a5cefb3..ad9d74f5d 100644 --- a/src/nhttpd/yhttpd_core/ysocket.cpp +++ b/src/nhttpd/yhttpd_core/ysocket.cpp @@ -1,6 +1,6 @@ //============================================================================= // YHTTPD -// Socket Class : Basic Socket Operations +// Socket Class : Basic Socket Operations //============================================================================= #include @@ -167,7 +167,7 @@ bool CySocket::listen(int port, int max_connections) { if(sock == INVALID_SOCKET) return false; - + // set sockaddr for listening sockaddr_in sai; memset(&sai, 0, sizeof(sai)); @@ -200,7 +200,7 @@ CySocket* CySocket::accept() new_ySocket->set_option(IPPROTO_TCP, TCP_CORK); #else set_tcp_nodelay(); -#endif +#endif } new_ySocket->isOpened = true; // handling = true; @@ -301,7 +301,7 @@ int CySocket::Send(char const *buffer, unsigned int length) else #endif len = ::send(sock, buffer, length, MSG_NOSIGNAL); - if(len >= 0) + if(len > 0) BytesSend += len; return len; } @@ -346,7 +346,7 @@ int CySocket::SendFile(int filed) #else char sbuf[1024]; unsigned int r=0; - while ((r=read(filed, sbuf, 1024)) > 0) + while ((r=read(filed, sbuf, 1024)) > 0) { if (Send(sbuf, r) < 0) { @@ -355,7 +355,7 @@ int CySocket::SendFile(int filed) } } #endif // Y_CONFIG_HAVE_SENDFILE - log_level_printf(9,": Bytes:%ld\n", BytesSend); + log_level_printf(9,": Bytes:%ld\n", BytesSend); return true; } //----------------------------------------------------------------------------- @@ -403,7 +403,7 @@ unsigned int CySocket::ReceiveFileGivenLength(int filed, unsigned int _length) { isValid = false; break; - } + } _readbytes += bytes_gotten; if (write(filed, buffer, bytes_gotten) != bytes_gotten) { @@ -431,7 +431,7 @@ std::string CySocket::ReceiveBlock() return ""; // signal(SIGALRM, ytimeout); alarm(1); - + while(true) { // check bytes in Socket buffer @@ -452,7 +452,7 @@ std::string CySocket::ReceiveBlock() } // Read data int bytes_gotten = Read(buffer, readarg); - + if(bytes_gotten == -1 && errno == EINTR)// non-blocking continue; 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 break; } - alarm(0); + alarm(0); signal(SIGALRM,SIG_IGN); return result; } @@ -481,7 +481,7 @@ std::string CySocket::ReceiveLine() while(true) { - // read one char + // read one char if(Read(buffer+bytes_gotten, 1) == 1) { if(buffer[bytes_gotten] == '\n') @@ -500,6 +500,6 @@ std::string CySocket::ReceiveLine() } buffer[++bytes_gotten] = '\0'; result.assign(buffer, bytes_gotten); - + return result; } diff --git a/src/nhttpd/yhttpd_core/ytypes_globals.h b/src/nhttpd/yhttpd_core/ytypes_globals.h index 43bdb43e3..a69110ce9 100644 --- a/src/nhttpd/yhttpd_core/ytypes_globals.h +++ b/src/nhttpd/yhttpd_core/ytypes_globals.h @@ -76,46 +76,46 @@ typedef struct } HttpEnumString; static const HttpEnumString httpResponseNames[] = { - { HTTP_CONTINUE, "Continue" }, - { HTTP_SWITCHING_PROTOCOLS, "Switching Protocols" }, - { HTTP_OK, "OK" }, - { HTTP_CREATED, "Created" }, - { HTTP_ACCEPTED, "Accepted" }, - { HTTP_NON_AUTHORITATIVE_INFO, "No Authorative Info" }, - { HTTP_NO_CONTENT, "No Content" }, - { HTTP_RESET_CONTENT, "Reset Content" }, - { HTTP_PARTIAL_CONTENT, "Partial Content" }, - { HTTP_MULTIBLE_CHOICES, "Multiple Choices" }, - { HTTP_MOVED_PERMANENTLY, "Moved Permanently" }, - { HTTP_MOVED_TEMPORARILY, "Moved Temporarily" }, - { HTTP_SEE_OTHER, "See Other" }, - { HTTP_NOT_MODIFIED, "Not Modified" }, - { HTTP_USE_PROXY, "Use Proxy" }, - { HTTP_TEMPORARY_REDIRECT, "Temporary Redirect" }, - { HTTP_BAD_REQUEST, "Bad Request", "Unsupported method." }, - { HTTP_UNAUTHORIZED, "Unauthorized", "Access denied." }, - { HTTP_PAYMENT_REQUIRED, "Payment Required" }, - { HTTP_FORBIDDEN, "Forbidden", "" }, - { HTTP_NOT_FOUND, "Not Found", "The requested URL was not found on this server." }, - { HTTP_METHOD_NOT_ALLOWED, "Method Not Allowed" }, - { HTTP_NOT_ACCEPTABLE, "Not Acceptable" }, - { HTTP_PROXY_AUTHENTICATION_REQUIRED,"Proxy Authentication Required" }, - { HTTP_REQUEST_TIMEOUT, "Request Time-out" }, - { HTTP_CONFLICT, "Conflict" }, - { HTTP_GONE, "Gone" }, - { HTTP_LENGTH_REQUIRED, "Length Required" }, - { HTTP_PRECONDITION_FAILED, "Precondition Failed" }, - { HTTP_REQUEST_ENTITY_TOO_LARGE,"Request Entity Too Large" }, - { HTTP_REQUEST_URI_TOO_LARGE, "Request-URI Too Large" }, - { HTTP_UNSUPPORTED_MEDIA_TYPE, "Unsupported Media Type" }, - { HTTP_REQUEST_RANGE_NOT_SATISFIABLE,"Requested range not satisfiable" }, - { HTTP_EXPECTAION_FAILED, "Expectation Failed" }, - { 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_BAD_GATEWAY, "Bad Gateway" }, - { HTTP_SERVICE_UNAVAILABLE, "Service Unavailable" }, - { HTTP_GATEWAY_TIMEOUT, "Gateway Time-out" }, - { HTTP_HTTP_VERSION_NOT_SUPPORTED,"HTTP Version not supported" }, + { HTTP_CONTINUE, "Continue", "" }, + { HTTP_SWITCHING_PROTOCOLS, "Switching Protocols", "" }, + { HTTP_OK, "OK", "" }, + { HTTP_CREATED, "Created", "" }, + { HTTP_ACCEPTED, "Accepted", "" }, + { HTTP_NON_AUTHORITATIVE_INFO, "No Authorative Info", "" }, + { HTTP_NO_CONTENT, "No Content", "" }, + { HTTP_RESET_CONTENT, "Reset Content", "" }, + { HTTP_PARTIAL_CONTENT, "Partial Content", "" }, + { HTTP_MULTIBLE_CHOICES, "Multiple Choices", "" }, + { HTTP_MOVED_PERMANENTLY, "Moved Permanently", "" }, + { HTTP_MOVED_TEMPORARILY, "Moved Temporarily", "" }, + { HTTP_SEE_OTHER, "See Other", "" }, + { HTTP_NOT_MODIFIED, "Not Modified", "" }, + { HTTP_USE_PROXY, "Use Proxy", "" }, + { HTTP_TEMPORARY_REDIRECT, "Temporary Redirect", "" }, + { HTTP_BAD_REQUEST, "Bad Request", "Unsupported method." }, + { HTTP_UNAUTHORIZED, "Unauthorized", "Access denied."}, + { HTTP_PAYMENT_REQUIRED, "Payment Required", "" }, + { HTTP_FORBIDDEN, "Forbidden", "" }, + { HTTP_NOT_FOUND, "Not Found", "The requested URL was not found on this server." }, + { HTTP_METHOD_NOT_ALLOWED, "Method Not Allowed", "" }, + { HTTP_NOT_ACCEPTABLE, "Not Acceptable", "" }, + { HTTP_PROXY_AUTHENTICATION_REQUIRED, "Proxy Authentication Required", "" }, + { HTTP_REQUEST_TIMEOUT, "Request Time-out", "" }, + { HTTP_CONFLICT, "Conflict", "" }, + { HTTP_GONE, "Gone", "" }, + { HTTP_LENGTH_REQUIRED, "Length Required", "" }, + { HTTP_PRECONDITION_FAILED, "Precondition Failed", "" }, + { HTTP_REQUEST_ENTITY_TOO_LARGE, "Request Entity Too Large", "" }, + { HTTP_REQUEST_URI_TOO_LARGE, "Request-URI Too Large", "" }, + { HTTP_UNSUPPORTED_MEDIA_TYPE, "Unsupported Media Type", "" }, + { HTTP_REQUEST_RANGE_NOT_SATISFIABLE, "Requested range not satisfiable", "" }, + { HTTP_EXPECTAION_FAILED, "Expectation Failed", "" }, + { 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_BAD_GATEWAY, "Bad Gateway", "" }, + { HTTP_SERVICE_UNAVAILABLE, "Service Unavailable", "" }, + { HTTP_GATEWAY_TIMEOUT, "Gateway Time-out", "" }, + { HTTP_HTTP_VERSION_NOT_SUPPORTED, "HTTP Version not supported", "" }, }; // HTTP-methods