Renamed log_trace() to log()

This commit is contained in:
2016-08-10 20:21:54 +03:00
parent 65b923cba8
commit dcd7a46d0a
10 changed files with 100 additions and 97 deletions

View File

@@ -1,5 +1,5 @@
#include "thread_pool.h"
#include "log_trace.h"
#include "log.h"
#include "protocol.h"
#include <pthread.h>
#include <unistd.h>
@@ -24,18 +24,18 @@ static void show_certs(SSL *ssl)
cert = SSL_get_peer_certificate(ssl); /* Get certificates (if available) */
if (SSL_get_verify_result(ssl)==X509_V_OK)
log_trace(VERBOSE, "get_verify_result == ok");
log(VERBOSE, "get_verify_result == ok");
if (cert != NULL) {
log_trace(VERBOSE, "Server certificates:");
log(VERBOSE, "Server certificates:");
line = X509_NAME_oneline(X509_get_subject_name(cert), 0, 0);
log_trace(VERBOSE, "Subject: %s", line);
log(VERBOSE, "Subject: %s", line);
free(line);
line = X509_NAME_oneline(X509_get_issuer_name(cert), 0, 0);
log_trace(VERBOSE, "Issuer: %s", line);
log(VERBOSE, "Issuer: %s", line);
free(line);
X509_free(cert);
} else
log_trace(VERBOSE, "No certificates from peer");
log(VERBOSE, "No certificates from peer");
}
static void* servlet(void *args) /* Serve the connection -- threadable */
@@ -49,7 +49,7 @@ static void* servlet(void *args) /* Serve the connection -- threadable */
ret = SSL_accept(agent->ssl);
/* We check for unclean (ret < 0) and clean (ret == 0) failures */
if (ret <= 0) {
log_trace(WARNING, "SSL_accept() failed. Reason below:");
log(WARNING, "SSL_accept() failed. Reason below:");
log_ssl();
} else {
show_certs(agent->ssl);
@@ -60,26 +60,26 @@ static void* servlet(void *args) /* Serve the connection -- threadable */
bytes = SSL_read(agent->ssl, &buf, sizeof(buf));
if (bytes > 0) {
if (bytes != sizeof(struct msg)) {
log_trace( WARNING,
log( WARNING,
"Agent [%s] sent non-standard data!",
agent->ip );
continue;
}
log_trace(VERBOSE, "Client msg: \"%s\"", buf.chunk.data);
log(VERBOSE, "Client msg: \"%s\"", buf.chunk.data);
/* TODO: Insert msg handler here */
continue;
}
if (SSL_get_shutdown(agent->ssl) == SSL_RECEIVED_SHUTDOWN)
log_trace(VERBOSE, "SSL_RECEIVED_SHUTDOWN from agent [%s]", agent->ip);
log(VERBOSE, "SSL_RECEIVED_SHUTDOWN from agent [%s]", agent->ip);
else {
log_trace(VERBOSE, "Client didn't send data! SSL error below:");
log(VERBOSE, "Client didn't send data! SSL error below:");
//log_ssl(); /* We actually don't have anything to log from SSL */
sprintf((char*)buf.chunk.data, "%s", "Where's the data, m8?");
SSL_write(agent->ssl, &buf, sizeof(struct msg));
}
log_trace(INFO, "Agent [%s] disconnected.", agent->ip);
log(INFO, "Agent [%s] disconnected.", agent->ip);
} while (bytes);
}
SSL_free(agent->ssl); /* release SSL state */
@@ -116,7 +116,7 @@ void ssl_pt_mutex(int srv, SSL_CTX *ctx, int poolsize)
socklen_t len = sizeof(addr);
SSL *ssl;
int agent = accept(srv, (struct sockaddr*)&addr, &len);
log_trace( INFO,
log( INFO,
"Connection: %s:%d",
inet_ntop(AF_INET, &addr.sin_addr, address, sizeof(address)),
ntohs(addr.sin_port)
@@ -139,7 +139,7 @@ void ssl_pt_mutex(int srv, SSL_CTX *ctx, int poolsize)
}
}
if (i == poolsize) {
log_trace( WARNING,
log( WARNING,
"Agent [%s] dropped. Poolsize limit reached.",
inet_ntop(AF_INET, &addr.sin_addr, address, sizeof(address))
);