diff options
Diffstat (limited to 'code')
-rwxr-xr-x | code/jasmine/buffer.h | 5 | ||||
-rwxr-xr-x | code/jasmine/client.c | 4 | ||||
-rwxr-xr-x | code/jasmine/server-tcp.c | 13 |
3 files changed, 13 insertions, 9 deletions
diff --git a/code/jasmine/buffer.h b/code/jasmine/buffer.h index e899fe62..c0b527e3 100755 --- a/code/jasmine/buffer.h +++ b/code/jasmine/buffer.h @@ -21,7 +21,7 @@ /* Exclude padding */ #define PACKET_PAYLOAD_SIZE (((PACKET_SIZE) - sizeof(struct packet_ctl)) & ~0x3) -#define PACKETS_PER_BUFFER 1024 +#define PACKETS_PER_BUFFER 65536 #define DEF_PORT 18383 /* for both UDP and TCP */ @@ -51,6 +51,9 @@ struct request_ctl { uint32_t req_count; /* Requested packet slot count */ }; +#define MAX_REQ_SIZE (sizeof(struct request_ctl) + \ + PACKETS_PER_BUFFER * sizeof(uint32_t)) + extern struct buffer_ctl buffctl; extern struct packet_ctl *packetctl[PACKETS_PER_BUFFER]; diff --git a/code/jasmine/client.c b/code/jasmine/client.c index 20bd3585..4f51ab6e 100755 --- a/code/jasmine/client.c +++ b/code/jasmine/client.c @@ -107,7 +107,7 @@ void tcp_retransmition(int tcp_socket, { struct request_ctl *reqctl; uint32_t *reqbody; - uint8_t rqbuf[sizeof(struct request_ctl) + PACKETS_PER_BUFFER * sizeof(uint32_t)]; + uint8_t rqbuf[MAX_REQ_SIZE]; uint32_t l; reqctl = (struct request_ctl *)rqbuf; @@ -174,7 +174,7 @@ int recv_mcast(int tcp_socket, int udp_socket, do { FD_SET(tcp_socket, &rfds); FD_SET(udp_socket, &rfds); - tv.tv_sec = 5; + tv.tv_sec = 20; tv.tv_usec = 0; res = select(maxfd, &rfds, 0, 0, &tv); diff --git a/code/jasmine/server-tcp.c b/code/jasmine/server-tcp.c index c48de77d..49fa4e5e 100755 --- a/code/jasmine/server-tcp.c +++ b/code/jasmine/server-tcp.c @@ -25,7 +25,6 @@ #include "server.h" #define MAX_CLIENTS 128 /* Clients per TCP server */ -#define TCP_BUFF_SIZE 65536 struct cdata { struct tcpq *tx; @@ -219,8 +218,9 @@ void accept_clients_may_spawn(struct server_status_data *sdata) void keep_on_receiving_client_request(struct server_status_data *sdata) { - char buf[TCP_BUFF_SIZE]; + char buf[MAX_REQ_SIZE]; void *cpy; + void *anscpy; struct request_ctl *req; uint32_t *rqb; struct packet_ctl *ans; @@ -270,10 +270,11 @@ void keep_on_receiving_client_request(struct server_status_data *sdata) total_sz = ans->data_size + sizeof(struct packet_ctl); log(6, "Send packet %u (%u bytes) on %d", rqb[rq_index], ans->data_size, sdata->cindex); - cpy = wrapper_malloc(total_sz); - memcpy(cpy, ans, total_sz); - tcpq_queue_tail(cd->tx, cpy, total_sz); + anscpy = wrapper_malloc(total_sz); + memcpy(anscpy, ans, total_sz); + tcpq_queue_tail(cd->tx, anscpy, total_sz); } + free(cpy); if (rq_index > 0) { /* Data need to be sent out */ @@ -394,7 +395,7 @@ void handle_pullin_event(struct server_status_data *sdata) void handle_pullout_event(struct server_status_data *sdata) { - char buf[TCP_BUFF_SIZE]; + char buf[PACKET_SIZE]; struct pollfd *ds; struct cdata *cd; long transmit_sz; |