| | |
| | | { |
| | | int i; |
| | | pool.nready--; |
| | | for (i = 0; i < FD_SETSIZE; i++) /* Find an available slot */ |
| | | for (i = 0; i < FD_SETSIZE; i++) {/* Find an available slot */ |
| | | if (pool.clientfd[i] < 0) |
| | | { |
| | | /* Add connected descriptor to the pool */ |
| | |
| | | pool.maxi = i; //line:conc:echoservers:endmaxi |
| | | break; |
| | | } |
| | | if (i == FD_SETSIZE) /* Couldn't find an empty slot */ |
| | | err_msg(errno, "add_client error: Too many clients"); |
| | | } |
| | | if (i == FD_SETSIZE) { |
| | | /* Couldn't find an empty slot */ |
| | | LoggerFactory::getLogger()->error(errno, "add_client error: Too many clients"); |
| | | |
| | | } |
| | | } |
| | | /* $end add_client */ |
| | | |
| | |
| | | net_mod_response_head_t response_head; |
| | | char request_head_bs[NET_MODE_REQUEST_HEAD_LENGTH]; |
| | | void *recv_buf; |
| | | |
| | | char tmp[8196]; |
| | | int recv_size; |
| | | |
| | | // if(buf == NULL) { |
| | | // buf = malloc(max_buf); |
| | | // if(buf == NULL) { |
| | | // err_exit(errno, "process_client malloc"); |
| | | // } |
| | | // } |
| | | |
| | | |
| | | if (rio_readn(connfd, request_head_bs, NET_MODE_REQUEST_HEAD_LENGTH) != NET_MODE_REQUEST_HEAD_LENGTH) |
| | | { |
| | | return -1; |
| | |
| | | for (i = 0; (i <= pool.maxi) && (pool.nready > 0); i++) |
| | | { |
| | | connfd = pool.clientfd[i]; |
| | | //rio = &pool.clientrio[i]; |
| | | |
| | | /* If the descriptor is ready, echo a text line from it */ |
| | | if ((connfd > 0) && (FD_ISSET(connfd, &pool.ready_set))) |