void handle_connection(int sock_con) { int read_val, ret; char buf[1024]; if ((read_val = read(sock_con, buf, 1024)) < 0) { syslog(LOG_ERR, "clacksidd: Couldn't read from dom socket: %d", errno); } else if (strcmp(buf, CL_ID_GET) == 0) { if ((ret = send_uuid(sock_con)) <= 0) { syslog(LOG_ERR, "Problem sending UUID: %d", errno); } } else if (strcmp(buf, CL_ID_TAG) == 0) { handle_tag_operation(sock_con); } }
int agent_connected_event(agent_t *agent, event_info_t *event_info) { int optval; socklen_t val = sizeof(optval); client_t *new_client = event_info->client; getsockopt(new_client->agent_sock[event_info->fd],SOL_SOCKET, SO_ERROR, &optval, &val); if(!optval) { new_client->num_parallel_connections++; new_client->agent_fd_poll[event_info->fd] = IN; send_uuid(new_client->agent_sock[event_info->fd], new_client->uuid); } else { printf("%d\n", errno); perror(""); printf("%s %d\n", __FILE__, __LINE__); } if(epoll_ctl(agent->event_pool, EPOLL_CTL_DEL, new_client->agent_sock[event_info->fd], NULL)) { perror(""); printf("%s %d\n", __FILE__, __LINE__); exit(1); } if(new_client->allowed_connections && new_client->num_parallel_connections == new_client->allowed_connections && new_client->host_fd_poll == IN) { //set time back so it will be expired next time time is checked new_client->client_hash.accept_start.tv_sec -= TIMEOUT; } return EXIT_SUCCESS; }