diff options
Diffstat (limited to 'pjlib/src/pjlib-test/ioq_udp.c')
-rw-r--r-- | pjlib/src/pjlib-test/ioq_udp.c | 72 |
1 files changed, 36 insertions, 36 deletions
diff --git a/pjlib/src/pjlib-test/ioq_udp.c b/pjlib/src/pjlib-test/ioq_udp.c index 6ee90e42..c6a5c5f0 100644 --- a/pjlib/src/pjlib-test/ioq_udp.c +++ b/pjlib/src/pjlib-test/ioq_udp.c @@ -42,34 +42,34 @@ static pj_ioqueue_key_t *callback_read_key, *callback_write_key, *callback_accept_key, *callback_connect_key; -static pj_ioqueue_op_key_t *callback_read_op,
- *callback_write_op,
- *callback_accept_op;
+static pj_ioqueue_op_key_t *callback_read_op, + *callback_write_op, + *callback_accept_op; -static void on_ioqueue_read(pj_ioqueue_key_t *key,
- pj_ioqueue_op_key_t *op_key,
+static void on_ioqueue_read(pj_ioqueue_key_t *key, + pj_ioqueue_op_key_t *op_key, pj_ssize_t bytes_read) { - callback_read_key = key;
+ callback_read_key = key; callback_read_op = op_key; callback_read_size = bytes_read; } -static void on_ioqueue_write(pj_ioqueue_key_t *key,
- pj_ioqueue_op_key_t *op_key,
+static void on_ioqueue_write(pj_ioqueue_key_t *key, + pj_ioqueue_op_key_t *op_key, pj_ssize_t bytes_written) { - callback_write_key = key;
+ callback_write_key = key; callback_write_op = op_key; callback_write_size = bytes_written; } -static void on_ioqueue_accept(pj_ioqueue_key_t *key,
- pj_ioqueue_op_key_t *op_key,
+static void on_ioqueue_accept(pj_ioqueue_key_t *key, + pj_ioqueue_op_key_t *op_key, pj_sock_t sock, int status) { PJ_UNUSED_ARG(sock); - callback_accept_key = key;
+ callback_accept_key = key; callback_accept_op = op_key; callback_accept_status = status; } @@ -107,7 +107,7 @@ static int compliance_test(void) pj_pool_t *pool = NULL; char *send_buf, *recv_buf; pj_ioqueue_t *ioque = NULL; - pj_ioqueue_key_t *skey, *ckey;
+ pj_ioqueue_key_t *skey, *ckey; pj_ioqueue_op_key_t read_op, write_op; int bufsize = BUF_MIN_SIZE; pj_ssize_t bytes, status = -1; @@ -183,11 +183,11 @@ static int compliance_test(void) // Register reading from ioqueue. TRACE_("start recvfrom..."); - addrlen = sizeof(addr);
+ addrlen = sizeof(addr); bytes = bufsize; rc = pj_ioqueue_recvfrom(skey, &read_op, recv_buf, &bytes, 0, &addr, &addrlen); - if (rc != PJ_SUCCESS && rc != PJ_EPENDING) {
+ if (rc != PJ_SUCCESS && rc != PJ_EPENDING) { app_perror("...error: pj_ioqueue_recvfrom", rc); status=-28; goto on_error; } else if (rc == PJ_EPENDING) { @@ -201,11 +201,11 @@ static int compliance_test(void) } // Write must return the number of bytes. - TRACE_("start sendto...");
+ TRACE_("start sendto..."); bytes = bufsize; rc = pj_ioqueue_sendto(ckey, &write_op, send_buf, &bytes, 0, &addr, sizeof(addr)); - if (rc != PJ_SUCCESS && rc != PJ_EPENDING) {
+ if (rc != PJ_SUCCESS && rc != PJ_EPENDING) { app_perror("...error: pj_ioqueue_sendto", rc); status=-30; goto on_error; } else if (rc == PJ_EPENDING) { @@ -223,7 +223,7 @@ static int compliance_test(void) callback_accept_status = callback_connect_status = -2; callback_read_key = callback_write_key = callback_accept_key = callback_connect_key = NULL; - callback_read_op = callback_write_op = NULL;
+ callback_read_op = callback_write_op = NULL; // Poll if pending. while (send_pending || recv_pending) { @@ -247,9 +247,9 @@ static int compliance_test(void) } if (callback_read_key != skey) { status=-65; goto on_error; - }
- if (callback_read_op != &read_op) {
- status=-66; goto on_error;
+ } + if (callback_read_op != &read_op) { + status=-66; goto on_error; } if (memcmp(send_buf, recv_buf, bufsize) != 0) { @@ -266,9 +266,9 @@ static int compliance_test(void) } if (callback_write_key != ckey) { status=-75; goto on_error; - }
- if (callback_write_op != &write_op) {
- status=-76; goto on_error;
+ } + if (callback_write_op != &write_op) { + status=-76; goto on_error; } send_pending = 0; @@ -386,7 +386,7 @@ static int bench_test(int bufsize, int inactive_sock_count) pj_sock_t ssock=-1, csock=-1; pj_sockaddr_in addr; pj_pool_t *pool = NULL; - pj_sock_t *inactive_sock=NULL;
+ pj_sock_t *inactive_sock=NULL; pj_ioqueue_op_key_t *inactive_read_op; char *send_buf, *recv_buf; pj_ioqueue_t *ioque = NULL; @@ -433,13 +433,13 @@ static int bench_test(int bufsize, int inactive_sock_count) // Allocate inactive sockets, and bind them to some arbitrary address. // Then register them to the I/O queue, and start a read operation. inactive_sock = (pj_sock_t*)pj_pool_alloc(pool, - inactive_sock_count*sizeof(pj_sock_t));
- inactive_read_op = (pj_ioqueue_op_key_t*)pj_pool_alloc(pool,
+ inactive_sock_count*sizeof(pj_sock_t)); + inactive_read_op = (pj_ioqueue_op_key_t*)pj_pool_alloc(pool, inactive_sock_count*sizeof(pj_ioqueue_op_key_t)); memset(&addr, 0, sizeof(addr)); addr.sin_family = PJ_AF_INET; - for (i=0; i<inactive_sock_count; ++i) {
- pj_ssize_t bytes;
+ for (i=0; i<inactive_sock_count; ++i) { + pj_ssize_t bytes; rc = pj_sock_socket(PJ_AF_INET, PJ_SOCK_DGRAM, 0, &inactive_sock[i]); if (rc != PJ_SUCCESS || inactive_sock[i] < 0) { @@ -460,7 +460,7 @@ static int bench_test(int bufsize, int inactive_sock_count) app_perror("...error(1): pj_ioqueue_register_sock()", rc); PJ_LOG(3,(THIS_FILE, "....i=%d", i)); goto on_error; - }
+ } bytes = bufsize; rc = pj_ioqueue_recv(key, &inactive_read_op[i], recv_buf, &bytes, 0); if ( rc < 0 && rc != PJ_EPENDING) { @@ -494,13 +494,13 @@ static int bench_test(int bufsize, int inactive_sock_count) // Test loop. t_elapsed.u64 = 0; for (i=0; i<LOOP; ++i) { - pj_ssize_t bytes;
+ pj_ssize_t bytes; pj_ioqueue_op_key_t read_op, write_op; // Randomize send buffer. pj_create_random_string(send_buf, bufsize); - // Start reading on the server side.
+ // Start reading on the server side. bytes = bufsize; rc = pj_ioqueue_recv(skey, &read_op, recv_buf, &bytes, 0); if (rc < 0 && rc != PJ_EPENDING) { @@ -508,7 +508,7 @@ static int bench_test(int bufsize, int inactive_sock_count) break; } - // Starts send on the client side.
+ // Starts send on the client side. bytes = bufsize; rc = pj_ioqueue_sendto(ckey, &write_op, send_buf, &bytes, 0, &addr, sizeof(addr)); @@ -587,7 +587,7 @@ on_error: pj_sock_close(csock); for (i=0; i<inactive_sock_count && inactive_sock && inactive_sock[i]!=PJ_INVALID_SOCKET; ++i) - {
+ { pj_sock_close(inactive_sock[i]); } if (ioque != NULL) @@ -601,7 +601,7 @@ int udp_ioqueue_test() int status; int bufsize, sock_count; - PJ_LOG(3, (THIS_FILE, "...compliance test")); + PJ_LOG(3, (THIS_FILE, "...compliance test (%s)", pj_ioqueue_name())); if ((status=compliance_test()) != 0) { return status; } @@ -615,7 +615,7 @@ int udp_ioqueue_test() PJ_LOG(4, (THIS_FILE, "... note: buf=bytes sent, fds=# of fds, " "elapsed=in timer ticks")); - PJ_LOG(3, (THIS_FILE, "...Benchmarking poll times:")); + PJ_LOG(3, (THIS_FILE, "...Benchmarking poll times for %s:", pj_ioqueue_name())); PJ_LOG(3, (THIS_FILE, "...=====================================")); PJ_LOG(3, (THIS_FILE, "...Buf.size #inactive-socks Time/poll")); PJ_LOG(3, (THIS_FILE, "... (bytes) (nanosec)")); |