summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenny Prijono <bennylp@teluu.com>2008-08-26 17:10:51 +0000
committerBenny Prijono <bennylp@teluu.com>2008-08-26 17:10:51 +0000
commit784001b0b48afc195cfe156f38384b2f0cabebfc (patch)
treefca70d882def97a7f739d6c40fd86ed214bb3e48
parentc288275068ad548e105bc5aa9baeec109ed53b0f (diff)
Fixed ticket #603: Crash in ICE with IoCompletionPort ioqueue with the test framework because active socket calls the callback with NULL packet
git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@2243 74dad513-b988-da41-8d7b-12977e46ad98
-rw-r--r--pjlib/src/pj/activesock.c18
1 files changed, 15 insertions, 3 deletions
diff --git a/pjlib/src/pj/activesock.c b/pjlib/src/pj/activesock.c
index 9e53aef1..1d65fe76 100644
--- a/pjlib/src/pj/activesock.c
+++ b/pjlib/src/pj/activesock.c
@@ -467,8 +467,15 @@ static void ioqueue_on_read_complete(pj_ioqueue_key_t *key,
* anything useful in the source_addr, so just put NULL
* there too.
*/
- ret = (*asock->cb.on_data_recvfrom)(asock, NULL, 0,
- NULL, 0, status);
+ /* In some scenarios, status may be PJ_SUCCESS. The upper
+ * layer application may not expect the callback to be called
+ * with successful status and NULL data, so lets not call the
+ * callback if the status is PJ_SUCCESS.
+ */
+ if (status != PJ_SUCCESS ) {
+ ret = (*asock->cb.on_data_recvfrom)(asock, NULL, 0,
+ NULL, 0, status);
+ }
}
/* If callback returns false, we have been destroyed! */
@@ -503,7 +510,12 @@ static void ioqueue_on_read_complete(pj_ioqueue_key_t *key,
&r->src_addr, &r->src_addr_len);
}
- } while (status != PJ_EPENDING && status != PJ_ECANCELLED);
+ if (status != PJ_EPENDING && status != PJ_ECANCELLED) {
+ bytes_read = -status;
+ } else {
+ break;
+ }
+ } while (1);
}