diff options
Diffstat (limited to 'pjlib/src/pjlib-test/ioq_perf.c')
-rw-r--r-- | pjlib/src/pjlib-test/ioq_perf.c | 76 |
1 files changed, 38 insertions, 38 deletions
diff --git a/pjlib/src/pjlib-test/ioq_perf.c b/pjlib/src/pjlib-test/ioq_perf.c index 3305fb60..a4ee005c 100644 --- a/pjlib/src/pjlib-test/ioq_perf.c +++ b/pjlib/src/pjlib-test/ioq_perf.c @@ -38,9 +38,9 @@ typedef struct test_item client_fd; pj_ioqueue_t *ioqueue; pj_ioqueue_key_t *server_key, - *client_key;
- pj_ioqueue_op_key_t recv_op,
- send_op;
+ *client_key; + pj_ioqueue_op_key_t recv_op, + send_op; int has_pending_send; pj_size_t buffer_size; char *outgoing_buffer; @@ -52,16 +52,16 @@ typedef struct test_item /* Callback when data has been read. * Increment item->bytes_recv and ready to read the next data. */ -static void on_read_complete(pj_ioqueue_key_t *key,
- pj_ioqueue_op_key_t *op_key,
+static void on_read_complete(pj_ioqueue_key_t *key, + pj_ioqueue_op_key_t *op_key, pj_ssize_t bytes_read) { test_item *item = pj_ioqueue_get_user_data(key); - pj_status_t rc;
+ pj_status_t rc; int data_is_available = 1; //TRACE_((THIS_FILE, " read complete, bytes_read=%d", bytes_read)); -
+ do { if (thread_quit_flag) return; @@ -76,7 +76,7 @@ static void on_read_complete(pj_ioqueue_key_t *key, PJ_LOG(3,(THIS_FILE, "...error: read error, bytes_read=%d (%s)", bytes_read, errmsg)); PJ_LOG(3,(THIS_FILE, - ".....additional info: total read=%u, total written=%u", + ".....additional info: total read=%u, total sent=%u", item->bytes_recv, item->bytes_sent)); } else { last_error_counter++; @@ -94,44 +94,44 @@ static void on_read_complete(pj_ioqueue_key_t *key, */ if (item->bytes_recv > item->buffer_size * 10000) thread_quit_flag = 1; -
+ bytes_read = item->buffer_size; rc = pj_ioqueue_recv( key, op_key, item->incoming_buffer, &bytes_read, 0 ); - if (rc == PJ_SUCCESS) {
- data_is_available = 1;
- } else if (rc == PJ_EPENDING) {
- data_is_available = 0;
- } else {
+ if (rc == PJ_SUCCESS) { + data_is_available = 1; + } else if (rc == PJ_EPENDING) { + data_is_available = 0; + } else { data_is_available = 0; if (rc != last_error) { last_error = rc; - app_perror("...error: read error", rc); + app_perror("...error: read error(1)", rc); } else { last_error_counter++; } - }
-
- if (!item->has_pending_send) {
- pj_ssize_t sent = item->buffer_size;
- rc = pj_ioqueue_send(item->client_key, &item->send_op,
- item->outgoing_buffer, &sent, 0);
- if (rc != PJ_SUCCESS && rc != PJ_EPENDING) {
- app_perror("...error: write error", rc);
- }
-
- item->has_pending_send = (rc==PJ_EPENDING);
- }
-
+ } + + if (!item->has_pending_send) { + pj_ssize_t sent = item->buffer_size; + rc = pj_ioqueue_send(item->client_key, &item->send_op, + item->outgoing_buffer, &sent, 0); + if (rc != PJ_SUCCESS && rc != PJ_EPENDING) { + app_perror("...error: write error", rc); + } + + item->has_pending_send = (rc==PJ_EPENDING); + } + } while (data_is_available); } /* Callback when data has been written. * Increment item->bytes_sent and write the next data. */ -static void on_write_complete(pj_ioqueue_key_t *key,
- pj_ioqueue_op_key_t *op_key,
+static void on_write_complete(pj_ioqueue_key_t *key, + pj_ioqueue_op_key_t *op_key, pj_ssize_t bytes_sent) { test_item *item = pj_ioqueue_get_user_data(key); @@ -140,7 +140,7 @@ static void on_write_complete(pj_ioqueue_key_t *key, if (thread_quit_flag) return; -
+ item->has_pending_send = 0; item->bytes_sent += bytes_sent; @@ -150,14 +150,14 @@ static void on_write_complete(pj_ioqueue_key_t *key, } else { pj_status_t rc; -
+ bytes_sent = item->buffer_size; rc = pj_ioqueue_send( item->client_key, op_key, item->outgoing_buffer, &bytes_sent, 0); if (rc != PJ_SUCCESS && rc != PJ_EPENDING) { app_perror("...error: write error", rc); - }
-
+ } + item->has_pending_send = (rc==PJ_EPENDING); } } @@ -231,7 +231,7 @@ static int perform_test(int sock_type, const char *type_name, /* Initialize each producer-consumer pair. */ for (i=0; i<sockpair_cnt; ++i) { - pj_ssize_t bytes;
+ pj_ssize_t bytes; items[i].ioqueue = ioqueue; items[i].buffer_size = buffer_size; @@ -274,7 +274,7 @@ static int perform_test(int sock_type, const char *type_name, } /* Start reading. */ - TRACE_((THIS_FILE, " pj_ioqueue_recv.."));
+ TRACE_((THIS_FILE, " pj_ioqueue_recv..")); bytes = items[i].buffer_size; rc = pj_ioqueue_recv(items[i].server_key, &items[i].recv_op, items[i].incoming_buffer, &bytes, @@ -285,7 +285,7 @@ static int perform_test(int sock_type, const char *type_name, } /* Start writing. */ - TRACE_((THIS_FILE, " pj_ioqueue_write.."));
+ TRACE_((THIS_FILE, " pj_ioqueue_write..")); bytes = items[i].buffer_size; rc = pj_ioqueue_send(items[i].client_key, &items[i].recv_op, items[i].outgoing_buffer, &bytes, 0); @@ -293,7 +293,7 @@ static int perform_test(int sock_type, const char *type_name, app_perror("...error: pj_ioqueue_write", rc); return -76; } -
+ items[i].has_pending_send = (rc==PJ_EPENDING); } |