Obsolete
/
libipc-old
Archived
3
0
Fork 0

add a #define to quiet pongd

more_to_read
Philippe PITTOLI 2018-11-05 19:01:09 +01:00
parent 498e0509ee
commit 26c1ddafb3
4 changed files with 11 additions and 4 deletions

View File

@ -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) {

View File

@ -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) {

View File

@ -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

View File

@ -7,6 +7,7 @@
#include <unistd.h>
#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");
}