summaryrefslogtreecommitdiff
path: root/pjlib
diff options
context:
space:
mode:
authorLiong Sauw Ming <ming@teluu.com>2010-09-22 13:11:11 +0000
committerLiong Sauw Ming <ming@teluu.com>2010-09-22 13:11:11 +0000
commit26a27f32ac0d829e0bdd98edb5e71f6c33c2ce58 (patch)
tree9f5232e68fb5219e513cf99fd8859a3b5bb63702 /pjlib
parent4403b5a47952bba812334611972469737c8635d5 (diff)
Fixed #1130
Since the problem may not be iOS4 specific, a general approach is adopted to fix the problem. git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@3316 74dad513-b988-da41-8d7b-12977e46ad98
Diffstat (limited to 'pjlib')
-rw-r--r--pjlib/include/pj/config.h10
-rw-r--r--pjlib/src/pj/activesock.c16
2 files changed, 26 insertions, 0 deletions
diff --git a/pjlib/include/pj/config.h b/pjlib/include/pj/config.h
index 0f47a1a0..6d5e17bc 100644
--- a/pjlib/include/pj/config.h
+++ b/pjlib/include/pj/config.h
@@ -507,6 +507,16 @@
#endif
/**
+ * Maximum consecutive identical error for accept() operation before
+ * activesock stops calling the next ioqueue accept.
+ *
+ * Default: 50
+ */
+#ifndef PJ_ACTIVESOCK_MAX_CONSECUTIVE_ACCEPT_ERROR
+# define PJ_ACTIVESOCK_MAX_CONSECUTIVE_ACCEPT_ERROR 50
+#endif
+
+/**
* Constants for declaring the maximum handles that can be supported by
* a single IOQ framework. This constant might not be relevant to the
* underlying I/O queue impelementation, but still, developers should be
diff --git a/pjlib/src/pj/activesock.c b/pjlib/src/pj/activesock.c
index 0ba1a790..016c1d34 100644
--- a/pjlib/src/pj/activesock.c
+++ b/pjlib/src/pj/activesock.c
@@ -84,6 +84,9 @@ struct pj_activesock_t
CFReadStreamRef readStream;
#endif
+ unsigned err_counter;
+ pj_status_t last_err;
+
struct send_data send_data;
struct read_op *read_op;
@@ -790,6 +793,19 @@ static void ioqueue_on_accept_complete(pj_ioqueue_key_t *key,
PJ_UNUSED_ARG(new_sock);
do {
+ if (status == asock->last_err && status != PJ_SUCCESS) {
+ asock->err_counter++;
+ if (asock->err_counter >= PJ_ACTIVESOCK_MAX_CONSECUTIVE_ACCEPT_ERROR) {
+ PJ_LOG(3, ("", "Received %d consecutive errors: %d for the accept()"
+ " operation, stopping further ioqueue accepts.",
+ asock->err_counter, asock->last_err));
+ return;
+ }
+ } else {
+ asock->err_counter = 0;
+ asock->last_err = status;
+ }
+
if (status==PJ_SUCCESS && asock->cb.on_accept_complete) {
pj_bool_t ret;