From 26c1ddafb3c6ed308e91d8f6a0c75d5398ce43a2 Mon Sep 17 00:00:00 2001
From: Philippe PITTOLI
Date: Mon, 5 Nov 2018 19:01:09 +0100
Subject: [PATCH] add a #define to quiet pongd
---
core/client.c | 1 -
core/communication.c | 2 +-
core/ipc.h | 1 +
pong/app/pongd.c | 11 +++++++++--
4 files changed, 11 insertions(+), 4 deletions(-)
diff --git a/core/client.c b/core/client.c
index 03be6cc..46cefc4 100644
--- a/core/client.c
+++ b/core/client.c
@@ -59,7 +59,6 @@ int32_t ipc_clients_del (struct ipc_clients *clients, struct ipc_client *p)
int32_t i;
for (i = 0; i < clients->size; i++) {
if (clients->clients[i] == p) {
-
clients->clients[i] = clients->clients[clients->size-1];
clients->size--;
if (clients->size == 0) {
diff --git a/core/communication.c b/core/communication.c
index 2fd57b1..f56447a 100644
--- a/core/communication.c
+++ b/core/communication.c
@@ -289,7 +289,7 @@ int32_t handle_new_connection (struct ipc_service *srv
handle_error("server_accept < 0");
return 1;
} else {
- printf("new connection\n");
+ // printf("new connection\n");
}
if (ipc_clients_add (clients, *new_client) < 0) {
diff --git a/core/ipc.h b/core/ipc.h
index bf737f2..c073a85 100644
--- a/core/ipc.h
+++ b/core/ipc.h
@@ -13,6 +13,7 @@
#define PATH_MAX 4096
#define IPC_HEADER_SIZE 5
#define IPC_MAX_MESSAGE_SIZE 8000000-IPC_HEADER_SIZE
+// #define IPC_MAX_MESSAGE_SIZE 100-IPC_HEADER_SIZE
// #include "queue.h"
#define IPC_VERSION 1
diff --git a/pong/app/pongd.c b/pong/app/pongd.c
index 4128b9e..8d83e45 100644
--- a/pong/app/pongd.c
+++ b/pong/app/pongd.c
@@ -7,6 +7,7 @@
#include
#define PONGD_SERVICE_NAME "pongd"
+#define PONGD_PRINT_MESSAGES
int cpt = 0;
@@ -42,14 +43,18 @@ void main_loop ()
case IPC_EVENT_TYPE_CONNECTION:
{
cpt++;
- printf ("connection: %d clients connected\n", cpt);
- printf ("new client has the fd %d\n", ((struct ipc_client*) event.origin)->proc_fd);
+#ifdef PONGD_PRINT_MESSAGES
+ printf ("connection: client fd %d, %d clients connected\n"
+ , ((struct ipc_client*) event.origin)->proc_fd, cpt);
+#endif
};
break;
case IPC_EVENT_TYPE_DISCONNECTION:
{
cpt--;
+#ifdef PONGD_PRINT_MESSAGES
printf ("disconnection: %d clients remaining\n", cpt);
+#endif
// free the ipc_client structure
free (event.origin);
@@ -58,9 +63,11 @@ void main_loop ()
case IPC_EVENT_TYPE_MESSAGE:
{
struct ipc_message *m = event.m;
+#ifdef PONGD_PRINT_MESSAGES
if (m->length > 0) {
printf ("message received (type %d): %.*s\n", m->type, m->length, m->payload);
}
+#endif
if (ipc_server_write (event.origin, m) < 0) {
handle_err( "handle_new_msg", "server_write < 0");
}