let me try a little something...
This commit is contained in:
parent
70023cb48f
commit
2ca8e9ada3
2 changed files with 5 additions and 4 deletions
2
ipc.h
2
ipc.h
|
|
@ -40,4 +40,4 @@ typedef struct ipc {
|
||||||
|
|
||||||
} ipc_t;
|
} ipc_t;
|
||||||
|
|
||||||
#define SERVER_PATH "/tmp/rogue-enemy.sock"
|
#define SERVER_PATH "/home/rogue-enemy.sock"
|
||||||
|
|
@ -110,15 +110,16 @@ int main(int argc, char ** argv) {
|
||||||
|
|
||||||
// here the client_fd is good
|
// here the client_fd is good
|
||||||
if (pthread_mutex_lock(&dev_out_thread_data.communication.endpoint.ssocket.mutex) == 0) {
|
if (pthread_mutex_lock(&dev_out_thread_data.communication.endpoint.ssocket.mutex) == 0) {
|
||||||
int i;
|
bool found = false;
|
||||||
for (i = 0; i < MAX_CONNECTED_CLIENTS; ++i) {
|
for (size_t i = 0; i < MAX_CONNECTED_CLIENTS; ++i) {
|
||||||
if (dev_out_thread_data.communication.endpoint.ssocket.clients[i] < 0) {
|
if (dev_out_thread_data.communication.endpoint.ssocket.clients[i] < 0) {
|
||||||
dev_out_thread_data.communication.endpoint.ssocket.clients[i] = client_fd;
|
dev_out_thread_data.communication.endpoint.ssocket.clients[i] = client_fd;
|
||||||
|
found = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (i == MAX_CONNECTED_CLIENTS) {
|
if (!found) {
|
||||||
fprintf(stderr, "Could not find a free spot fot the incoming client -- client will be rejected\n");
|
fprintf(stderr, "Could not find a free spot fot the incoming client -- client will be rejected\n");
|
||||||
close(client_fd);
|
close(client_fd);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue