]> git.sesse.net Git - cubemap/blobdiff - server.cpp
Fix a small memory leak in HTTPInput.
[cubemap] / server.cpp
index 46bda5b21935ff36d0aca3be838885c5e4b7b7ba..24aa84e357a129db9fcea63b43cec986b114407a 100644 (file)
@@ -14,6 +14,7 @@
 #include <utility>
 #include <vector>
 
+#include "accesslog.h"
 #include "log.h"
 #include "markpool.h"
 #include "mutexlock.h"
@@ -24,6 +25,8 @@
 
 using namespace std;
 
+extern AccessLogThread *access_log;
+
 Server::Server()
 {
        pthread_mutex_init(&mutex, NULL);
@@ -268,7 +271,7 @@ read_request_again:
        
                switch (status) {
                case RP_OUT_OF_SPACE:
-                       log(WARNING, "fd %d sent overlong request!", client->sock);
+                       log(WARNING, "[%s] Client sent overlong request!", client->remote_addr.c_str());
                        close_client(client);
                        return;
                case RP_NOT_FINISHED_YET:
@@ -276,7 +279,7 @@ read_request_again:
                        // See if there's more data for us.
                        goto read_request_again;
                case RP_EXTRA_DATA:
-                       log(WARNING, "fd %d had junk data after request!", client->sock);
+                       log(WARNING, "[%s] Junk data after request!", client->remote_addr.c_str());
                        close_client(client);
                        return;
                case RP_FINISHED:
@@ -357,8 +360,8 @@ sending_data_again:
                        return;
                }
                if (bytes_to_send > stream->backlog_size) {
-                       log(WARNING, "fd %d lost %lld bytes, maybe too slow connection",
-                               client->sock,
+                       log(WARNING, "[%s] Client lost %lld bytes, maybe too slow connection",
+                               client->remote_addr.c_str(),
                                (long long int)(bytes_to_send - stream->backlog_size));
                        client->stream_pos = stream->bytes_received - stream->backlog_size;
                        client->bytes_lost += bytes_to_send - stream->backlog_size;
@@ -504,6 +507,9 @@ void Server::close_client(Client *client)
                }
        }
 
+       // Log to access_log.
+       access_log->write(client->get_stats());
+
        // Bye-bye!
        int ret;
        do {